added -N no_unlink option

This commit is contained in:
van Hauser 2019-12-02 15:25:17 +01:00
parent 60c8121c1d
commit f8bc9b54da
5 changed files with 48 additions and 12 deletions

View File

@ -20,7 +20,10 @@ Version ++2.58d (dev):
- qbdi_mode: fuzz android native libraries via QBDI framework - qbdi_mode: fuzz android native libraries via QBDI framework
- afl-analyze: added AFL_SKIP_BIN_CHECK support - afl-analyze: added AFL_SKIP_BIN_CHECK support
- better random numbers for gcc_plugin and llvm_mode (thanks to devnexen) - better random numbers for gcc_plugin and llvm_mode (thanks to devnexen)
- afl-fuzz: CPU affinity support for DragonFly - afl-fuzz:
- added Radamsa and an optional radamsa stage (-R)
- CPU affinity support for DragonFly
- added -u command line option to not unlink the fuzz input file
- llvm_mode: float splitting is now configured via AFL_LLVM_LAF_SPLIT_FLOATS - llvm_mode: float splitting is now configured via AFL_LLVM_LAF_SPLIT_FLOATS
- libtokencap: support for *BSD/OSX added - libtokencap: support for *BSD/OSX added
- compcov: floating point splitting support for QEMU on x86 targets - compcov: floating point splitting support for QEMU on x86 targets
@ -30,7 +33,6 @@ Version ++2.58d (dev):
download succeeded. f*ckin travis fails downloading 40% of the time! download succeeded. f*ckin travis fails downloading 40% of the time!
- added the few Android stuff we didnt have already from Google afl repository - added the few Android stuff we didnt have already from Google afl repository
- removed unnecessary warnings - removed unnecessary warnings
- added the radamsa stage
-------------------------- --------------------------

View File

@ -265,7 +265,9 @@ extern u32 hang_tmout; /* Timeout used for hang det (ms) */
extern u64 mem_limit; /* Memory cap for child (MB) */ extern u64 mem_limit; /* Memory cap for child (MB) */
extern u8 cal_cycles, /* Calibration cycles defaults */ extern u8 cal_cycles, /* Calibration cycles defaults */
cal_cycles_long, debug, /* Debug mode */ cal_cycles_long, /* Calibration cycles defaults */
no_unlink, /* do not unlink cur_input */
debug, /* Debug mode */
custom_only, /* Custom mutator only mode */ custom_only, /* Custom mutator only mode */
python_only; /* Python-only mode */ python_only; /* Python-only mode */

View File

@ -83,7 +83,9 @@ u32 hang_tmout = EXEC_TIMEOUT; /* Timeout used for hang det (ms) */
u64 mem_limit = MEM_LIMIT; /* Memory cap for child (MB) */ u64 mem_limit = MEM_LIMIT; /* Memory cap for child (MB) */
u8 cal_cycles = CAL_CYCLES, /* Calibration cycles defaults */ u8 cal_cycles = CAL_CYCLES, /* Calibration cycles defaults */
cal_cycles_long = CAL_CYCLES_LONG, debug, /* Debug mode */ cal_cycles_long = CAL_CYCLES_LONG, /* Calibration cycles defaults */
debug, /* Debug mode */
no_unlink, /* do not unlink cur_input */
custom_only, /* Custom mutator only mode */ custom_only, /* Custom mutator only mode */
python_only; /* Python-only mode */ python_only; /* Python-only mode */

View File

@ -288,10 +288,17 @@ void write_to_testcase(void* mem, u32 len) {
if (out_file) { if (out_file) {
unlink(out_file); /* Ignore errors. */ if (no_unlink) {
fd = open(out_file, O_WRONLY | O_CREAT | O_TRUNC, 0600);
} else {
unlink(out_file); /* Ignore errors. */
fd = open(out_file, O_WRONLY | O_CREAT | O_EXCL, 0600); fd = open(out_file, O_WRONLY | O_CREAT | O_EXCL, 0600);
}
if (fd < 0) PFATAL("Unable to create '%s'", out_file); if (fd < 0) PFATAL("Unable to create '%s'", out_file);
} else } else
@ -330,10 +337,17 @@ void write_with_gap(void* mem, u32 len, u32 skip_at, u32 skip_len) {
if (out_file) { if (out_file) {
unlink(out_file); /* Ignore errors. */ if (no_unlink) {
fd = open(out_file, O_WRONLY | O_CREAT | O_TRUNC, 0600);
} else {
unlink(out_file); /* Ignore errors. */
fd = open(out_file, O_WRONLY | O_CREAT | O_EXCL, 0600); fd = open(out_file, O_WRONLY | O_CREAT | O_EXCL, 0600);
}
if (fd < 0) PFATAL("Unable to create '%s'", out_file); if (fd < 0) PFATAL("Unable to create '%s'", out_file);
} else } else
@ -760,10 +774,17 @@ u8 trim_case(char** argv, struct queue_entry* q, u8* in_buf) {
s32 fd; s32 fd;
unlink(q->fname); /* ignore errors */ if (no_unlink) {
fd = open(q->fname, O_WRONLY | O_CREAT | O_TRUNC, 0600);
} else {
unlink(q->fname); /* ignore errors */
fd = open(q->fname, O_WRONLY | O_CREAT | O_EXCL, 0600); fd = open(q->fname, O_WRONLY | O_CREAT | O_EXCL, 0600);
}
if (fd < 0) PFATAL("Unable to create '%s'", q->fname); if (fd < 0) PFATAL("Unable to create '%s'", q->fname);
ck_write(fd, in_buf, q->len, q->fname); ck_write(fd, in_buf, q->len, q->fname);

View File

@ -122,9 +122,11 @@ static void usage(u8* argv0) {
" a recommended value is 10-60. see docs/README.MOpt\n\n" " a recommended value is 10-60. see docs/README.MOpt\n\n"
"Fuzzing behavior settings:\n" "Fuzzing behavior settings:\n"
" -N - do not unlink the fuzzing input file\n"
" -d - quick & dirty mode (skips deterministic steps)\n" " -d - quick & dirty mode (skips deterministic steps)\n"
" -n - fuzz without instrumentation (dumb mode)\n" " -n - fuzz without instrumentation (dumb mode)\n"
" -x dir - optional fuzzer dictionary (see README)\n\n" " -x dir - optional fuzzer dictionary (see README, its really "
"good!)\n\n"
"Testing settings:\n" "Testing settings:\n"
" -s seed - use a fixed seed for the RNG\n" " -s seed - use a fixed seed for the RNG\n"
@ -195,7 +197,7 @@ int main(int argc, char** argv) {
init_seed = tv.tv_sec ^ tv.tv_usec ^ getpid(); init_seed = tv.tv_sec ^ tv.tv_usec ^ getpid();
while ((opt = getopt(argc, argv, while ((opt = getopt(argc, argv,
"+i:I:o:f:m:t:T:dnCB:S:M:x:QUWe:p:s:V:E:L:hR")) > 0) "+i:I:o:f:m:t:T:dnCB:S:M:x:QNUWe:p:s:V:E:L:hR")) > 0)
switch (opt) { switch (opt) {
@ -426,6 +428,13 @@ int main(int argc, char** argv) {
break; break;
case 'N': /* Unicorn mode */
if (no_unlink) FATAL("Multiple -N options not supported");
no_unlink = 1;
break;
case 'U': /* Unicorn mode */ case 'U': /* Unicorn mode */
if (unicorn_mode) FATAL("Multiple -U options not supported"); if (unicorn_mode) FATAL("Multiple -U options not supported");