mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-17 20:28:08 +00:00
add AFL autodict capability to Nyx mode
This commit is contained in:
@ -1 +1 @@
|
||||
8842549
|
||||
76100c5
|
||||
|
Submodule nyx_mode/packer updated: 8842549b56...76100c52db
@ -425,6 +425,7 @@ void afl_fsrv_start(afl_forkserver_t *fsrv, char **argv,
|
||||
}
|
||||
|
||||
}
|
||||
ck_free(x);
|
||||
|
||||
if (fsrv->nyx_runner == NULL) { FATAL("Something went wrong ..."); }
|
||||
|
||||
@ -464,6 +465,61 @@ void afl_fsrv_start(afl_forkserver_t *fsrv, char **argv,
|
||||
|
||||
}
|
||||
|
||||
/* autodict in Nyx mode */
|
||||
if (!ignore_autodict) {
|
||||
x = alloc_printf("%s/workdir/dump/afl_autodict.txt", fsrv->out_dir_path);
|
||||
int nyx_autodict_fd = open(x, O_RDONLY);
|
||||
ck_free(x);
|
||||
|
||||
if (nyx_autodict_fd >= 0) {
|
||||
struct stat st;
|
||||
if (fstat(nyx_autodict_fd, &st) >= 0) {
|
||||
u32 f_len = st.st_size;
|
||||
u8 *dict = ck_alloc(f_len);
|
||||
if (dict == NULL) {
|
||||
FATAL("Could not allocate %u bytes of autodictionary memory", f_len);
|
||||
}
|
||||
|
||||
u32 offset = 0, count = 0;
|
||||
u32 len = f_len;
|
||||
|
||||
while (len != 0) {
|
||||
|
||||
rlen = read(nyx_autodict_fd, dict + offset, len);
|
||||
if (rlen > 0) {
|
||||
|
||||
len -= rlen;
|
||||
offset += rlen;
|
||||
|
||||
} else {
|
||||
|
||||
FATAL(
|
||||
"Reading autodictionary fail at position %u with %u bytes "
|
||||
"left.",
|
||||
offset, len);
|
||||
}
|
||||
|
||||
}
|
||||
close(nyx_autodict_fd);
|
||||
|
||||
offset = 0;
|
||||
while (offset < (u32)f_len &&
|
||||
(u8)dict[offset] + offset < (u32)f_len) {
|
||||
|
||||
fsrv->add_extra_func(fsrv->afl_ptr, dict + offset + 1,
|
||||
(u8)dict[offset]);
|
||||
offset += (1 + dict[offset]);
|
||||
count++;
|
||||
|
||||
}
|
||||
|
||||
if (!be_quiet) { ACTF("Loaded %u autodictionary entries", count); }
|
||||
ck_free(dict);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user