aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2022-03-04 09:37:21 +0100
committerGitHub <noreply@github.com>2022-03-04 09:37:21 +0100
commit09123d861731a47cc6474763a0eb5ddd4cc09b6d (patch)
tree5f87fb9784307b84a2bcfa721d58aeaa6f038bfa /src
parent7e67545b9de14ae6e425d184581bec93ccf84c6a (diff)
parent713b069f40094482fb41ef17b44150162c062249 (diff)
downloadafl++-09123d861731a47cc6474763a0eb5ddd4cc09b6d.tar.gz
Merge pull request #1344 from schumilo/dev
support Nyx crash logs
Diffstat (limited to 'src')
-rw-r--r--src/afl-forkserver.c8
-rw-r--r--src/afl-fuzz-bitmap.c16
-rw-r--r--src/afl-fuzz.c4
3 files changed, 27 insertions, 1 deletions
diff --git a/src/afl-forkserver.c b/src/afl-forkserver.c
index 8997781d..54f28852 100644
--- a/src/afl-forkserver.c
+++ b/src/afl-forkserver.c
@@ -450,6 +450,9 @@ void afl_fsrv_start(afl_forkserver_t *fsrv, char **argv,
fsrv->nyx_handlers->nyx_option_set_timeout(fsrv->nyx_runner, 2, 0);
fsrv->nyx_handlers->nyx_option_apply(fsrv->nyx_runner);
+ fsrv->nyx_aux_string = malloc(0x1000);
+ memset(fsrv->nyx_aux_string, 0, 0x1000);
+
/* dry run */
fsrv->nyx_handlers->nyx_set_afl_input(fsrv->nyx_runner, "INIT", 4);
switch (fsrv->nyx_handlers->nyx_exec(fsrv->nyx_runner)) {
@@ -1253,7 +1256,10 @@ void afl_fsrv_kill(afl_forkserver_t *fsrv) {
fsrv->child_pid = -1;
#ifdef __linux__
- if (fsrv->nyx_mode) { fsrv->nyx_handlers->nyx_shutdown(fsrv->nyx_runner); }
+ if (fsrv->nyx_mode) {
+ free(fsrv->nyx_aux_string);
+ fsrv->nyx_handlers->nyx_shutdown(fsrv->nyx_runner);
+ }
#endif
}
diff --git a/src/afl-fuzz-bitmap.c b/src/afl-fuzz-bitmap.c
index b963caf8..226dfa5c 100644
--- a/src/afl-fuzz-bitmap.c
+++ b/src/afl-fuzz-bitmap.c
@@ -771,6 +771,22 @@ save_if_interesting(afl_state_t *afl, void *mem, u32 len, u8 fault) {
ck_write(fd, mem, len, fn);
close(fd);
+#ifdef __linux__
+ if(afl->fsrv.nyx_mode && fault == FSRV_RUN_CRASH) {
+ u8 fn_log[PATH_MAX];
+
+ snprintf(fn_log, PATH_MAX, "%s.log", fn);
+
+ fd = open(fn_log, O_WRONLY | O_CREAT | O_EXCL, DEFAULT_PERMISSION);
+ if (unlikely(fd < 0)) { PFATAL("Unable to create '%s'", fn_log); }
+
+ u32 nyx_aux_string_len = afl->fsrv.nyx_handlers->nyx_get_aux_string(afl->fsrv.nyx_runner, afl->fsrv.nyx_aux_string, 0x1000);
+
+ ck_write(fd, afl->fsrv.nyx_aux_string, nyx_aux_string_len, fn_log);
+ close(fd);
+ }
+#endif
+
return keeping;
}
diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c
index a3f57c1e..df6e5404 100644
--- a/src/afl-fuzz.c
+++ b/src/afl-fuzz.c
@@ -468,6 +468,10 @@ nyx_plugin_handler_t *afl_load_libnyx_plugin(u8 *libnyx_binary) {
dlsym(handle, "nyx_get_bitmap_buffer_size");
if (plugin->nyx_get_bitmap_buffer_size == NULL) { goto fail; }
+ plugin->nyx_get_aux_string =
+ dlsym(handle, "nyx_get_aux_string");
+ if (plugin->nyx_get_aux_string == NULL) { goto fail; }
+
OKF("libnyx plugin is ready!");
return plugin;