mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-17 12:18:08 +00:00
afl-showmap custom mutator support
This commit is contained in:
@ -453,7 +453,7 @@ afl-fuzz: $(COMM_HDR) include/afl-fuzz.h $(AFL_FUZZ_FILES) src/afl-common.o src/
|
|||||||
$(CC) $(CFLAGS) $(COMPILE_STATIC) $(CFLAGS_FLTO) $(AFL_FUZZ_FILES) src/afl-common.o src/afl-sharedmem.o src/afl-forkserver.o src/afl-performance.o -o $@ $(PYFLAGS) $(LDFLAGS) -lm
|
$(CC) $(CFLAGS) $(COMPILE_STATIC) $(CFLAGS_FLTO) $(AFL_FUZZ_FILES) src/afl-common.o src/afl-sharedmem.o src/afl-forkserver.o src/afl-performance.o -o $@ $(PYFLAGS) $(LDFLAGS) -lm
|
||||||
|
|
||||||
afl-showmap: src/afl-showmap.c src/afl-common.o src/afl-sharedmem.o src/afl-forkserver.o src/afl-performance.o $(COMM_HDR) | test_x86
|
afl-showmap: src/afl-showmap.c src/afl-common.o src/afl-sharedmem.o src/afl-forkserver.o src/afl-performance.o $(COMM_HDR) | test_x86
|
||||||
$(CC) $(CFLAGS) $(COMPILE_STATIC) $(CFLAGS_FLTO) src/$@.c src/afl-common.o src/afl-sharedmem.o src/afl-forkserver.o src/afl-performance.o -o $@ $(LDFLAGS)
|
$(CC) $(CFLAGS) $(COMPILE_STATIC) $(CFLAGS_FLTO) src/$@.c src/afl-fuzz-mutators.c src/afl-fuzz-python.c src/afl-common.o src/afl-sharedmem.o src/afl-forkserver.o src/afl-performance.o -o $@ $(PYFLAGS) $(LDFLAGS)
|
||||||
|
|
||||||
afl-tmin: src/afl-tmin.c src/afl-common.o src/afl-sharedmem.o src/afl-forkserver.o src/afl-performance.o $(COMM_HDR) | test_x86
|
afl-tmin: src/afl-tmin.c src/afl-common.o src/afl-sharedmem.o src/afl-forkserver.o src/afl-performance.o $(COMM_HDR) | test_x86
|
||||||
$(CC) $(CFLAGS) $(COMPILE_STATIC) $(CFLAGS_FLTO) src/$@.c src/afl-common.o src/afl-sharedmem.o src/afl-forkserver.o src/afl-performance.o -o $@ $(LDFLAGS)
|
$(CC) $(CFLAGS) $(COMPILE_STATIC) $(CFLAGS_FLTO) src/$@.c src/afl-common.o src/afl-sharedmem.o src/afl-forkserver.o src/afl-performance.o -o $@ $(LDFLAGS)
|
||||||
|
4
TODO.md
4
TODO.md
@ -3,14 +3,14 @@
|
|||||||
## Should
|
## Should
|
||||||
|
|
||||||
- splicing selection weighted?
|
- splicing selection weighted?
|
||||||
- support afl_custom_{send,post_process}, persistent and deferred fork
|
- support persistent and deferred fork server in afl-showmap?
|
||||||
server in afl-showmap
|
|
||||||
- better autodetection of shifting runtime timeout values
|
- better autodetection of shifting runtime timeout values
|
||||||
- Update afl->pending_not_fuzzed for MOpt
|
- Update afl->pending_not_fuzzed for MOpt
|
||||||
- afl-plot to support multiple plot_data
|
- afl-plot to support multiple plot_data
|
||||||
- parallel builds for source-only targets
|
- parallel builds for source-only targets
|
||||||
- get rid of check_binary, replace with more forkserver communication
|
- get rid of check_binary, replace with more forkserver communication
|
||||||
- first fuzzer should be a main automatically? not sure.
|
- first fuzzer should be a main automatically? not sure.
|
||||||
|
- reload fuzz binary on signal
|
||||||
|
|
||||||
## Maybe
|
## Maybe
|
||||||
|
|
||||||
|
2
afl-cmin
2
afl-cmin
@ -133,6 +133,8 @@ function usage() {
|
|||||||
"AFL_PRINT_FILENAMES: If set, the filename currently processed will be " \
|
"AFL_PRINT_FILENAMES: If set, the filename currently processed will be " \
|
||||||
"printed to stdout\n" \
|
"printed to stdout\n" \
|
||||||
"AFL_SKIP_BIN_CHECK: skip afl instrumentation checks for target binary\n"
|
"AFL_SKIP_BIN_CHECK: skip afl instrumentation checks for target binary\n"
|
||||||
|
"AFL_CUSTOM_MUTATOR_LIBRARY: custom mutator library (post_process and send)\n"
|
||||||
|
"AFL_PYTHON_MODULE: custom mutator library (post_process and send)\n"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,6 +151,8 @@ AFL_KEEP_TRACES: leave the temporary <out_dir>\.traces directory
|
|||||||
AFL_NO_FORKSRV: run target via execve instead of using the forkserver
|
AFL_NO_FORKSRV: run target via execve instead of using the forkserver
|
||||||
AFL_PATH: last resort location to find the afl-showmap binary
|
AFL_PATH: last resort location to find the afl-showmap binary
|
||||||
AFL_SKIP_BIN_CHECK: skip check for target binary
|
AFL_SKIP_BIN_CHECK: skip check for target binary
|
||||||
|
AFL_CUSTOM_MUTATOR_LIBRARY: custom mutator library (post_process and send)
|
||||||
|
AFL_PYTHON_MODULE: custom mutator library (post_process and send)
|
||||||
_EOF_
|
_EOF_
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
@ -4,7 +4,8 @@
|
|||||||
release of the tool. See README.md for the general instruction manual.
|
release of the tool. See README.md for the general instruction manual.
|
||||||
|
|
||||||
### Version ++4.07a (dev)
|
### Version ++4.07a (dev)
|
||||||
- soon :)
|
- afl-showmap:
|
||||||
|
- added custom mutator post_process and send support
|
||||||
|
|
||||||
|
|
||||||
### Version ++4.06c (release)
|
### Version ++4.06c (release)
|
||||||
|
@ -1103,7 +1103,6 @@ u32 count_bits(afl_state_t *, u8 *);
|
|||||||
u32 count_bytes(afl_state_t *, u8 *);
|
u32 count_bytes(afl_state_t *, u8 *);
|
||||||
u32 count_non_255_bytes(afl_state_t *, u8 *);
|
u32 count_non_255_bytes(afl_state_t *, u8 *);
|
||||||
void simplify_trace(afl_state_t *, u8 *);
|
void simplify_trace(afl_state_t *, u8 *);
|
||||||
void classify_counts(afl_forkserver_t *);
|
|
||||||
#ifdef WORD_SIZE_64
|
#ifdef WORD_SIZE_64
|
||||||
void discover_word(u8 *ret, u64 *current, u64 *virgin);
|
void discover_word(u8 *ret, u64 *current, u64 *virgin);
|
||||||
#else
|
#else
|
||||||
@ -1117,6 +1116,9 @@ u8 *describe_op(afl_state_t *, u8, size_t);
|
|||||||
u8 save_if_interesting(afl_state_t *, void *, u32, u8);
|
u8 save_if_interesting(afl_state_t *, void *, u32, u8);
|
||||||
u8 has_new_bits(afl_state_t *, u8 *);
|
u8 has_new_bits(afl_state_t *, u8 *);
|
||||||
u8 has_new_bits_unclassified(afl_state_t *, u8 *);
|
u8 has_new_bits_unclassified(afl_state_t *, u8 *);
|
||||||
|
#ifndef AFL_SHOWMAP
|
||||||
|
void classify_counts(afl_forkserver_t *);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Extras */
|
/* Extras */
|
||||||
|
|
||||||
@ -1192,11 +1194,13 @@ void fix_up_sync(afl_state_t *);
|
|||||||
void check_asan_opts(afl_state_t *);
|
void check_asan_opts(afl_state_t *);
|
||||||
void check_binary(afl_state_t *, u8 *);
|
void check_binary(afl_state_t *, u8 *);
|
||||||
void check_if_tty(afl_state_t *);
|
void check_if_tty(afl_state_t *);
|
||||||
void setup_signal_handlers(void);
|
|
||||||
void save_cmdline(afl_state_t *, u32, char **);
|
void save_cmdline(afl_state_t *, u32, char **);
|
||||||
void read_foreign_testcases(afl_state_t *, int);
|
void read_foreign_testcases(afl_state_t *, int);
|
||||||
void write_crash_readme(afl_state_t *afl);
|
void write_crash_readme(afl_state_t *afl);
|
||||||
u8 check_if_text_buf(u8 *buf, u32 len);
|
u8 check_if_text_buf(u8 *buf, u32 len);
|
||||||
|
#ifndef AFL_SHOWMAP
|
||||||
|
void setup_signal_handlers(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* CmpLog */
|
/* CmpLog */
|
||||||
|
|
||||||
|
@ -30,8 +30,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define AFL_MAIN
|
#define AFL_MAIN
|
||||||
|
#define AFL_SHOWMAP
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "afl-fuzz.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "alloc-inl.h"
|
#include "alloc-inl.h"
|
||||||
@ -62,6 +64,8 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
|
|
||||||
|
static afl_state_t *afl;
|
||||||
|
|
||||||
static char *stdin_file; /* stdin file */
|
static char *stdin_file; /* stdin file */
|
||||||
|
|
||||||
static u8 *in_dir = NULL, /* input folder */
|
static u8 *in_dir = NULL, /* input folder */
|
||||||
@ -308,12 +312,73 @@ static u32 write_results_to_file(afl_forkserver_t *fsrv, u8 *outfile) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pre_afl_fsrv_write_to_testcase(afl_forkserver_t *fsrv, u8 *mem, u32 len) {
|
||||||
|
|
||||||
|
static u8 buf[MAX_FILE];
|
||||||
|
u32 sent = 0;
|
||||||
|
|
||||||
|
if (unlikely(afl->custom_mutators_count)) {
|
||||||
|
|
||||||
|
ssize_t new_size = len;
|
||||||
|
u8 *new_mem = mem;
|
||||||
|
u8 *new_buf = NULL;
|
||||||
|
|
||||||
|
LIST_FOREACH(&afl->custom_mutator_list, struct custom_mutator, {
|
||||||
|
|
||||||
|
if (el->afl_custom_post_process) {
|
||||||
|
|
||||||
|
new_size =
|
||||||
|
el->afl_custom_post_process(el->data, new_mem, new_size, &new_buf);
|
||||||
|
|
||||||
|
if (unlikely(!new_buf || new_size <= 0)) {
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
new_mem = new_buf;
|
||||||
|
len = new_size;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
if (new_mem != mem && new_mem != NULL) {
|
||||||
|
|
||||||
|
mem = buf;
|
||||||
|
memcpy(mem, new_mem, new_size);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (unlikely(afl->custom_mutators_count)) {
|
||||||
|
|
||||||
|
LIST_FOREACH(&afl->custom_mutator_list, struct custom_mutator, {
|
||||||
|
|
||||||
|
if (el->afl_custom_fuzz_send) {
|
||||||
|
|
||||||
|
el->afl_custom_fuzz_send(el->data, mem, len);
|
||||||
|
sent = 1;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (likely(!sent)) { afl_fsrv_write_to_testcase(fsrv, mem, len); }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/* Execute target application. */
|
/* Execute target application. */
|
||||||
|
|
||||||
static void showmap_run_target_forkserver(afl_forkserver_t *fsrv, u8 *mem,
|
static void showmap_run_target_forkserver(afl_forkserver_t *fsrv, u8 *mem,
|
||||||
u32 len) {
|
u32 len) {
|
||||||
|
|
||||||
afl_fsrv_write_to_testcase(fsrv, mem, len);
|
pre_afl_fsrv_write_to_testcase(fsrv, mem, len);
|
||||||
|
|
||||||
if (!quiet_mode) { SAYF("-- Program output begins --\n" cRST); }
|
if (!quiet_mode) { SAYF("-- Program output begins --\n" cRST); }
|
||||||
|
|
||||||
@ -835,6 +900,10 @@ static void usage(u8 *argv0) {
|
|||||||
"This tool displays raw tuple data captured by AFL instrumentation.\n"
|
"This tool displays raw tuple data captured by AFL instrumentation.\n"
|
||||||
"For additional help, consult %s/README.md.\n\n"
|
"For additional help, consult %s/README.md.\n\n"
|
||||||
|
|
||||||
|
"If you use -i mode, then custom mutator post_process send send "
|
||||||
|
"functionality\n"
|
||||||
|
"is supported.\n\n"
|
||||||
|
|
||||||
"Environment variables used:\n"
|
"Environment variables used:\n"
|
||||||
"LD_BIND_LAZY: do not set LD_BIND_NOW env var for target\n"
|
"LD_BIND_LAZY: do not set LD_BIND_NOW env var for target\n"
|
||||||
"AFL_CMIN_CRASHES_ONLY: (cmin_mode) only write tuples for crashing "
|
"AFL_CMIN_CRASHES_ONLY: (cmin_mode) only write tuples for crashing "
|
||||||
@ -1266,6 +1335,8 @@ int main(int argc, char **argv_orig, char **envp) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
afl = calloc(1, sizeof(afl_state_t));
|
||||||
|
|
||||||
if (getenv("AFL_FORKSRV_INIT_TMOUT")) {
|
if (getenv("AFL_FORKSRV_INIT_TMOUT")) {
|
||||||
|
|
||||||
s32 forksrv_init_tmout = atoi(getenv("AFL_FORKSRV_INIT_TMOUT"));
|
s32 forksrv_init_tmout = atoi(getenv("AFL_FORKSRV_INIT_TMOUT"));
|
||||||
@ -1380,6 +1451,26 @@ int main(int argc, char **argv_orig, char **envp) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (in_dir) {
|
||||||
|
|
||||||
|
afl->fsrv.dev_urandom_fd = open("/dev/urandom", O_RDONLY);
|
||||||
|
afl->afl_env.afl_custom_mutator_library =
|
||||||
|
getenv("AFL_CUSTOM_MUTATOR_LIBRARY");
|
||||||
|
afl->afl_env.afl_python_module = getenv("AFL_PYTHON_MODULE");
|
||||||
|
setup_custom_mutators(afl);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if (getenv("AFL_CUSTOM_MUTATOR_LIBRARY") || getenv("AFL_PYTHON_MODULE")) {
|
||||||
|
|
||||||
|
WARNF(
|
||||||
|
"Custom mutator environment detected, this is only supported in -i "
|
||||||
|
"mode!\n");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (in_dir) {
|
if (in_dir) {
|
||||||
|
|
||||||
DIR *dir_in, *dir_out = NULL;
|
DIR *dir_in, *dir_out = NULL;
|
||||||
|
Reference in New Issue
Block a user