From 26f3ec28eef78f3a57bc3c308de9a3105cb63538 Mon Sep 17 00:00:00 2001 From: Carlo Maragno Date: Sat, 2 Apr 2022 13:11:39 +0200 Subject: Fix dyslexia and clang format --- src/afl-fuzz.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/afl-fuzz.c') diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c index c73ab38b..8cc2a62e 100644 --- a/src/afl-fuzz.c +++ b/src/afl-fuzz.c @@ -2516,8 +2516,17 @@ stop_fuzzing: write_bitmap(afl); save_auto(afl); - SAYF(CURSOR_SHOW cLRD "\n\n+++ Testing aborted %s +++\n" cRST, - afl->stop_soon == 2 ? "programmatically" : "by user"); + if (afl->afl_env.afl_pizza_mode) { + + SAYF(CURSOR_SHOW cLRD "\n\n+++ Baking aborted %s +++\n" cRST, + afl->stop_soon == 2 ? "programmatically" : "by the chef"); + + } else { + + SAYF(CURSOR_SHOW cLRD "\n\n+++ Testing aborted %s +++\n" cRST, + afl->stop_soon == 2 ? "programmatically" : "by user"); + + } if (afl->most_time_key == 2) { -- cgit 1.4.1 From d9fa6af1b1d97ed4af4a0d015fce035dfd3bb738 Mon Sep 17 00:00:00 2001 From: vanhauser-thc Date: Sun, 3 Apr 2022 09:50:18 +0200 Subject: pizza mode on 1st of april --- TODO.md | 2 ++ src/afl-fuzz-stats.c | 12 ++++++------ src/afl-fuzz.c | 15 +++++++++++++++ 3 files changed, 23 insertions(+), 6 deletions(-) (limited to 'src/afl-fuzz.c') diff --git a/TODO.md b/TODO.md index f3192e10..8e77ee10 100644 --- a/TODO.md +++ b/TODO.md @@ -10,6 +10,8 @@ ## Maybe + - forkserver tells afl-fuzz if cmplog is supported and if so enable + it by default, with AFL_CMPLOG_NO=1 (?) set to skip? - afl_custom_fuzz_splice_optin() - afl_custom_splice() - cmdline option from-to range for mutations diff --git a/src/afl-fuzz-stats.c b/src/afl-fuzz-stats.c index 689f9c5d..80c22c34 100644 --- a/src/afl-fuzz-stats.c +++ b/src/afl-fuzz-stats.c @@ -1583,7 +1583,7 @@ void show_stats_pizza(afl_state_t *afl) { afl->in_bitmap || afl->crash_mode)) { u_stringify_time_diff(time_tmp, cur_ms, afl->last_find_time); - SAYF(bV bSTOP " last pizza baked : " cRST "%-33s ", + SAYF(bV bSTOP " last pizza baked : " cRST "%-37s ", time_tmp); } else { @@ -1629,9 +1629,9 @@ void show_stats_pizza(afl_state_t *afl) { "\n", time_tmp, tmp); - SAYF(bVR bH bSTOP cCYA + SAYF(bVR bH bSTOP cCYA " Baking progress " bSTG bH30 bH20 bH5 bH bX bH bSTOP cCYA - " Pizzeria busyness" bSTG bH30 bH5 bH bH bVL "\n"); + " Pizzeria busyness" bSTG bH30 bH5 bH bH bVL "\n"); /* This gets funny because we want to print several variable-length variables together, but then cram them into a fixed-width field - so we need to @@ -1754,8 +1754,8 @@ void show_stats_pizza(afl_state_t *afl) { /* Aaaalmost there... hold on! */ SAYF(bVR bH cCYA bSTOP " Promotional campaign on TikTok yields " bSTG bH30 bH2 - bH bH2 bX bH bSTOP cCYA " Customer type " bSTG bH5 bH2 bH30 bH2 bH bVL - "\n"); + bH bH2 bX bH bSTOP cCYA + " Customer type " bSTG bH5 bH2 bH30 bH2 bH bVL "\n"); if (unlikely(afl->custom_only)) { @@ -1999,7 +1999,7 @@ void show_stats_pizza(afl_state_t *afl) { if (afl->cpu_core_count) { - char *spacing = SP10, snap[24] = " " cLGN "Pizzaioli's busyness " cRST " "; + char *spacing = SP10, snap[80] = " " cLGN "Pizzaioli's busyness " cRST " "; double cur_runnable = get_runnable_processes(); u32 cur_utilization = cur_runnable * 100 / afl->cpu_core_count; diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c index cc1240e7..5c5ce0fb 100644 --- a/src/afl-fuzz.c +++ b/src/afl-fuzz.c @@ -2269,6 +2269,21 @@ int main(int argc, char **argv_orig, char **envp) { runs_in_current_cycle = (u32)-1; afl->cur_skipped_items = 0; + // 1st april fool joke - enable pizza mode + // to not waste time on checking the date we only do this when the + // queue is fully cycled. + time_t cursec = time(NULL); + struct tm *curdate = localtime(&cursec); + if (curdate->tm_mon == 3 && curdate->tm_mday == 1) { + + afl->afl_env.afl_pizza_mode = 1; + + } else { + + afl->afl_env.afl_pizza_mode = 0; + + } + if (unlikely(afl->old_seed_selection)) { afl->current_entry = 0; -- cgit 1.4.1 From 15b43e6ce1866b369700aed306d75090facc08d6 Mon Sep 17 00:00:00 2001 From: vanhauser-thc Date: Sun, 3 Apr 2022 19:14:59 +0200 Subject: fix pizza mode --- docs/Changelog.md | 1 + docs/env_variables.md | 3 +++ include/afl-fuzz.h | 3 ++- src/afl-fuzz-state.c | 9 +++++++++ src/afl-fuzz-stats.c | 2 +- src/afl-fuzz.c | 13 +++++++++---- 6 files changed, 25 insertions(+), 6 deletions(-) (limited to 'src/afl-fuzz.c') diff --git a/docs/Changelog.md b/docs/Changelog.md index 74631a88..d50a679b 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -23,6 +23,7 @@ sending a mail to . - add AFL_EARY_FORKSERVER to install the forkserver as earliest as possible in the target (for afl-gcc-fast/afl-clang-fast/ afl-clang-lto) + - document and auto-activate pizza mode on condition - afl-cc: - converted all passed to use the new llvm pass manager for llvm 11+ - AFL++ PCGUARD mode is not available for 10.0.1 anymore (11+ only) diff --git a/docs/env_variables.md b/docs/env_variables.md index edd57fb6..9ffb08e7 100644 --- a/docs/env_variables.md +++ b/docs/env_variables.md @@ -549,6 +549,9 @@ checks or alter some of the more exotic semantics of the tool: constructors in your target you can set `AFL_EARLY_FORKSERVER`. Note that this is not a compile time option but a runtime option :-) + - set `AFL_PIZZA_MODE` to 1 to enable the April 1st stats menu, set to 0 + to disable although it is 1st of April. + ## 5) Settings for afl-qemu-trace The QEMU wrapper used to instrument binary-only code supports several settings: diff --git a/include/afl-fuzz.h b/include/afl-fuzz.h index 6cde7695..4f4d63b2 100644 --- a/include/afl-fuzz.h +++ b/include/afl-fuzz.h @@ -483,7 +483,8 @@ typedef struct afl_state { debug, /* Debug mode */ custom_only, /* Custom mutator only mode */ is_main_node, /* if this is the main node */ - is_secondary_node; /* if this is a secondary instance */ + is_secondary_node, /* if this is a secondary instance */ + pizza_is_served; /* pizza mode */ u32 stats_update_freq; /* Stats update frequency (execs) */ diff --git a/src/afl-fuzz-state.c b/src/afl-fuzz-state.c index 507ddb46..5924dd7b 100644 --- a/src/afl-fuzz-state.c +++ b/src/afl-fuzz-state.c @@ -502,6 +502,15 @@ void read_afl_environment(afl_state_t *afl, char **envp) { afl->afl_env.afl_pizza_mode = atoi((u8 *)get_afl_env(afl_environment_variables[i])); + if (afl->afl_env.afl_pizza_mode == 0) { + + afl->afl_env.afl_pizza_mode = 1; + + } else { + + afl->pizza_is_served = 1; + + } } diff --git a/src/afl-fuzz-stats.c b/src/afl-fuzz-stats.c index 80c22c34..9737c692 100644 --- a/src/afl-fuzz-stats.c +++ b/src/afl-fuzz-stats.c @@ -437,7 +437,7 @@ static void check_term_size(afl_state_t *afl) { void show_stats(afl_state_t *afl) { - if (afl->afl_env.afl_pizza_mode) { + if (afl->pizza_is_served) { show_stats_pizza(afl); diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c index 5c5ce0fb..92243fbb 100644 --- a/src/afl-fuzz.c +++ b/src/afl-fuzz.c @@ -259,6 +259,7 @@ static void usage(u8 *argv0, int more_help) { "AFL_IGNORE_PROBLEMS: do not abort fuzzing if an incorrect setup is detected during a run\n" "AFL_IMPORT_FIRST: sync and import test cases from other fuzzer instances first\n" "AFL_INPUT_LEN_MIN/AFL_INPUT_LEN_MAX: like -g/-G set min/max fuzz length produced\n" + "AFL_PIZZA_MODE: 1 - enforce pizza mode, 0 - disable for April 1st\n" "AFL_KILL_SIGNAL: Signal ID delivered to child processes on timeout, etc. (default: SIGKILL)\n" "AFL_MAP_SIZE: the shared memory size for that target. must be >= the size\n" " the target was compiled for\n" @@ -2274,13 +2275,17 @@ int main(int argc, char **argv_orig, char **envp) { // queue is fully cycled. time_t cursec = time(NULL); struct tm *curdate = localtime(&cursec); - if (curdate->tm_mon == 3 && curdate->tm_mday == 1) { + if (likely(!afl->afl_env.afl_pizza_mode)) { - afl->afl_env.afl_pizza_mode = 1; + if (unlikely(curdate->tm_mon == 3 && curdate->tm_mday == 1)) { - } else { + afl->pizza_is_served = 1; + + } else { - afl->afl_env.afl_pizza_mode = 0; + afl->pizza_is_served = 0; + + } } -- cgit 1.4.1