Add initial CoreSight mode support

The original code is:
https://github.com/RICSecLab/AFLplusplus-cs/tree/retrage/coresight-mode-pr

Signed-off-by: Akira Moroo <retrage01@gmail.com>
This commit is contained in:
Akira Moroo
2021-06-22 05:34:20 +00:00
parent 2623851680
commit 9100f3c416
19 changed files with 397 additions and 17 deletions

View File

@ -204,6 +204,35 @@ void argv_cpy_free(char **argv) {
}
/* Rewrite argv for CoreSight process tracer. */
char **get_cs_argv(u8 *own_loc, u8 **target_path_p, int argc, char **argv) {
if (unlikely(getenv("AFL_CS_CUSTOM_BIN"))) {
WARNF(
"AFL_CS_CUSTOM_BIN is enabled. "
"You must run your target under afl-cs-proxy on your own!");
return argv;
}
char **new_argv = ck_alloc(sizeof(char *) * (argc + 4));
if (unlikely(!new_argv)) { FATAL("Illegal amount of arguments specified"); }
memcpy(&new_argv[3], &argv[1], (int)(sizeof(char *)) * (argc - 1));
new_argv[argc + 3] = NULL;
new_argv[2] = *target_path_p;
new_argv[1] = "--";
/* Now we need to actually find the cs-proxy binary to put in argv[0]. */
*target_path_p = new_argv[0] = find_afl_binary(own_loc, "afl-cs-proxy");
return new_argv;
}
/* Rewrite argv for QEMU. */
char **get_qemu_argv(u8 *own_loc, u8 **target_path_p, int argc, char **argv) {