From 29f0bb1c6a6e689f41bd3c92b1d4a607983cce80 Mon Sep 17 00:00:00 2001 From: Carlo Maragno Date: Fri, 1 Apr 2022 13:23:01 +0200 Subject: Add basic support for Italian users --- src/afl-fuzz-state.c | 7 + src/afl-fuzz-stats.c | 793 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 800 insertions(+) (limited to 'src') diff --git a/src/afl-fuzz-state.c b/src/afl-fuzz-state.c index 129e4c8b..5299e9e5 100644 --- a/src/afl-fuzz-state.c +++ b/src/afl-fuzz-state.c @@ -496,6 +496,13 @@ void read_afl_environment(afl_state_t *afl, char **envp) { afl->max_length = atoi((u8 *)get_afl_env(afl_environment_variables[i])); + }else if (!strncmp(env, "AFL_PIZZA_MODE", + + afl_environment_variable_len)) { + + afl->afl_env.afl_pizza_mode = + atoi((u8 *)get_afl_env(afl_environment_variables[i])); + } } else { diff --git a/src/afl-fuzz-stats.c b/src/afl-fuzz-stats.c index 1170bdb8..c5561414 100644 --- a/src/afl-fuzz-stats.c +++ b/src/afl-fuzz-stats.c @@ -435,7 +435,18 @@ static void check_term_size(afl_state_t *afl) { /* A spiffy retro stats screen! This is called every afl->stats_update_freq execve() calls, plus in several other circumstances. */ + void show_stats(afl_state_t *afl) { + if(afl->afl_env.afl_pizza_mode){ + show_stats_pizza(afl); + } + else{ + show_stats_normal(afl); + } +} + + +void show_stats_normal(afl_state_t *afl) { double t_byte_ratio, stab_ratio; @@ -1219,6 +1230,788 @@ void show_stats(afl_state_t *afl) { } + +void show_stats_pizza(afl_state_t *afl) { + + double t_byte_ratio, stab_ratio; + + u64 cur_ms; + u32 t_bytes, t_bits; + + static u8 banner[128]; + u32 banner_len, banner_pad; + u8 tmp[256]; + u8 time_tmp[64]; + + u8 val_buf[8][STRINGIFY_VAL_SIZE_MAX]; +#define IB(i) (val_buf[(i)]) + + cur_ms = get_cur_time(); + + if (afl->most_time_key) { + + if (afl->most_time * 1000 < cur_ms - afl->start_time) { + + afl->most_time_key = 2; + afl->stop_soon = 2; + + } + + } + + if (afl->most_execs_key == 1) { + + if (afl->most_execs <= afl->fsrv.total_execs) { + + afl->most_execs_key = 2; + afl->stop_soon = 2; + + } + + } + + /* If not enough time has passed since last UI update, bail out. */ + + if (cur_ms - afl->stats_last_ms < 1000 / UI_TARGET_HZ && + !afl->force_ui_update) { + + return; + + } + + /* Check if we're past the 10 minute mark. */ + + if (cur_ms - afl->start_time > 10 * 60 * 1000) { afl->run_over10m = 1; } + + /* Calculate smoothed exec speed stats. */ + + if (unlikely(!afl->stats_last_execs)) { + + if (likely(cur_ms != afl->start_time)) { + + afl->stats_avg_exec = ((double)afl->fsrv.total_execs) * 1000 / + (afl->prev_run_time + cur_ms - afl->start_time); + + } + + } else { + + if (likely(cur_ms != afl->stats_last_ms)) { + + double cur_avg = + ((double)(afl->fsrv.total_execs - afl->stats_last_execs)) * 1000 / + (cur_ms - afl->stats_last_ms); + + /* If there is a dramatic (5x+) jump in speed, reset the indicator + more quickly. */ + + if (cur_avg * 5 < afl->stats_avg_exec || + cur_avg / 5 > afl->stats_avg_exec) { + + afl->stats_avg_exec = cur_avg; + + } + + afl->stats_avg_exec = afl->stats_avg_exec * (1.0 - 1.0 / AVG_SMOOTHING) + + cur_avg * (1.0 / AVG_SMOOTHING); + + } + + } + + afl->stats_last_ms = cur_ms; + afl->stats_last_execs = afl->fsrv.total_execs; + + /* Tell the callers when to contact us (as measured in execs). */ + + afl->stats_update_freq = afl->stats_avg_exec / (UI_TARGET_HZ * 10); + if (!afl->stats_update_freq) { afl->stats_update_freq = 1; } + + /* Do some bitmap stats. */ + + t_bytes = count_non_255_bytes(afl, afl->virgin_bits); + t_byte_ratio = ((double)t_bytes * 100) / afl->fsrv.real_map_size; + + if (unlikely(t_bytes > afl->fsrv.real_map_size)) { + + if (unlikely(!afl->afl_env.afl_ignore_problems)) { + + FATAL( + "This is what happens when you speak italian to the rabbit " + "Don't speak italian to the rabbit"); + } + + } + + if (likely(t_bytes) && unlikely(afl->var_byte_count)) { + + stab_ratio = 100 - (((double)afl->var_byte_count * 100) / t_bytes); + + } else { + + stab_ratio = 100; + + } + + /* Roughly every minute, update fuzzer stats and save auto tokens. */ + + if (unlikely(!afl->non_instrumented_mode && + (afl->force_ui_update || + cur_ms - afl->stats_last_stats_ms > STATS_UPDATE_SEC * 1000))) { + + afl->stats_last_stats_ms = cur_ms; + write_stats_file(afl, t_bytes, t_byte_ratio, stab_ratio, + afl->stats_avg_exec); + save_auto(afl); + write_bitmap(afl); + + } + + if (unlikely(afl->afl_env.afl_statsd)) { + + if (unlikely(afl->force_ui_update || cur_ms - afl->statsd_last_send_ms > + STATSD_UPDATE_SEC * 1000)) { + + /* reset counter, even if send failed. */ + afl->statsd_last_send_ms = cur_ms; + if (statsd_send_metric(afl)) { WARNF("could not order tomato sauce from statsd."); } + + } + + } + + /* Every now and then, write plot data. */ + + if (unlikely(afl->force_ui_update || + cur_ms - afl->stats_last_plot_ms > PLOT_UPDATE_SEC * 1000)) { + + afl->stats_last_plot_ms = cur_ms; + maybe_update_plot_file(afl, t_bytes, t_byte_ratio, afl->stats_avg_exec); + + } + + /* Honor AFL_EXIT_WHEN_DONE and AFL_BENCH_UNTIL_CRASH. */ + + if (unlikely(!afl->non_instrumented_mode && afl->cycles_wo_finds > 100 && + !afl->pending_not_fuzzed && afl->afl_env.afl_exit_when_done)) { + + afl->stop_soon = 2; + + } + + /* AFL_EXIT_ON_TIME. */ + + if (unlikely(afl->last_find_time && !afl->non_instrumented_mode && + afl->afl_env.afl_exit_on_time && + (cur_ms - afl->last_find_time) > afl->exit_on_time)) { + + afl->stop_soon = 2; + + } + + if (unlikely(afl->total_crashes && afl->afl_env.afl_bench_until_crash)) { + + afl->stop_soon = 2; + + } + + /* If we're not on TTY, bail out. */ + + if (afl->not_on_tty) { return; } + + /* If we haven't started doing things, bail out. */ + + if (unlikely(!afl->queue_cur)) { return; } + + /* Compute some mildly useful bitmap stats. */ + + t_bits = (afl->fsrv.map_size << 3) - count_bits(afl, afl->virgin_bits); + + /* Now, for the visuals... */ + + if (afl->clear_screen) { + + SAYF(TERM_CLEAR CURSOR_HIDE); + afl->clear_screen = 0; + + check_term_size(afl); + + } + + SAYF(TERM_HOME); + + if (unlikely(afl->term_too_small)) { + + SAYF(cBRI + "Our pizzeria can't host this many guests.\n" + "Please call Pizzeria Caravaggio. They have tables of at least 79x24.\n" cRST); + + return; + + } + + /* Let's start by drawing a centered banner. */ + if (unlikely(!banner[0])) { + + char *si = ""; + if (afl->sync_id) { si = afl->sync_id; } + memset(banner, 0, sizeof(banner)); + banner_len = (afl->crash_mode ? 20 : 18) + strlen(VERSION) + strlen(si) + + strlen(afl->power_name) + 4 + 6; + + if (strlen(afl->use_banner) + banner_len > 75) { + + afl->use_banner += (strlen(afl->use_banner) + banner_len) - 76; + memset(afl->use_banner, '.', 3); + + } + + banner_len += strlen(afl->use_banner); + banner_pad = (79 - banner_len) / 2; + memset(banner, ' ', banner_pad); + +#ifdef __linux__ + if (afl->fsrv.nyx_mode) { + + sprintf(banner + banner_pad, + "%s " cLCY VERSION cLBL " {%s} " cLGN "(%s) " cPIN "[%s] - Nyx", + afl->crash_mode ? cPIN "Mozzarbella Pizzeria table booking system" + : cYEL "Mozzarbella Pizzeria managment system", + si, afl->use_banner, afl->power_name); + + } else { + +#endif + sprintf(banner + banner_pad, + "%s " cLCY VERSION cLBL " {%s} " cLGN "(%s) " cPIN "[%s]", + afl->crash_mode ? cPIN "Mozzarbella Pizzeria table booking system" + : cYEL "Mozzarbella Pizzeria managment system", + si, afl->use_banner, afl->power_name); + +#ifdef __linux__ + + } + +#endif + + } + + SAYF("\n%s\n", banner); + + /* "Handy" shortcuts for drawing boxes... */ + +#define bSTG bSTART cGRA +#define bH2 bH bH +#define bH5 bH2 bH2 bH +#define bH10 bH5 bH5 +#define bH20 bH10 bH10 +#define bH30 bH20 bH10 +#define SP5 " " +#define SP10 SP5 SP5 +#define SP20 SP10 SP10 + + /* Since `total_crashes` does not get reloaded from disk on restart, + it indicates if we found crashes this round already -> paint red. + If it's 0, but `saved_crashes` is set from a past run, paint in yellow. */ + char *crash_color = afl->total_crashes ? cLRD + : afl->saved_crashes ? cYEL + : cRST; + + /* Lord, forgive me this. */ + + SAYF(SET_G1 bSTG bLT bH bSTOP cCYA + " Mozzarbella has been proudly serving pizzas since " bSTG bH30 bH5 bH bHB bH bSTOP cCYA + " In this time, we served " bSTG bH2 bH2 bRT "\n"); + + if (afl->non_instrumented_mode) { + + strcpy(tmp, cRST); + + } else { + + u64 min_wo_finds = (cur_ms - afl->last_find_time) / 1000 / 60; + + /* First queue cycle: don't stop now! */ + if (afl->queue_cycle == 1 || min_wo_finds < 15) { + + strcpy(tmp, cMGN); + + } else + + /* Subsequent cycles, but we're still making finds. */ + if (afl->cycles_wo_finds < 25 || min_wo_finds < 30) { + + strcpy(tmp, cYEL); + + } else + + /* No finds for a long time and no test cases to try. */ + if (afl->cycles_wo_finds > 100 && !afl->pending_not_fuzzed && + min_wo_finds > 120) { + + strcpy(tmp, cLGN); + + /* Default: cautiously OK to stop? */ + + } else { + + strcpy(tmp, cLBL); + + } + + } + + u_stringify_time_diff(time_tmp, afl->prev_run_time + cur_ms, afl->start_time); + SAYF(bV bSTOP " open time : " cRST "%-33s " bSTG bV bSTOP + " seasons done : %s%-5s " bSTG bV "\n", + time_tmp, tmp, u_stringify_int(IB(0), afl->queue_cycle - 1)); + + /* We want to warn people about not seeing new paths after a full cycle, + except when resuming fuzzing or running in non-instrumented mode. */ + + if (!afl->non_instrumented_mode && + (afl->last_find_time || afl->resuming_fuzz || afl->queue_cycle == 1 || + 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 ", time_tmp); + + } else { + + if (afl->non_instrumented_mode) { + + SAYF(bV bSTOP " last pizza baked : " cPIN "n/a" cRST + " (non-instrumented mode) "); + + } else { + + SAYF(bV bSTOP " last pizza baked : " cRST "none yet " cLRD + "(odd, check Gennarino, he might be slacking!) "); + + } + + } + + SAYF(bSTG bV bSTOP " pizzas on the menu : " cRST "%-5s " bSTG bV "\n", + u_stringify_int(IB(0), afl->queued_items)); + + /* Highlight crashes in red if found, denote going over the KEEP_UNIQUE_CRASH + limit with a '+' appended to the count. */ + + sprintf(tmp, "%s%s", u_stringify_int(IB(0), afl->saved_crashes), + (afl->saved_crashes >= KEEP_UNIQUE_CRASH) ? "+" : ""); + + u_stringify_time_diff(time_tmp, cur_ms, afl->last_crash_time); + SAYF(bV bSTOP "last ordered pizza : " cRST "%-33s " bSTG bV bSTOP + "at table : %s%-6s" bSTG bV "\n", + time_tmp, crash_color, tmp); + + sprintf(tmp, "%s%s", u_stringify_int(IB(0), afl->saved_hangs), + (afl->saved_hangs >= KEEP_UNIQUE_HANG) ? "+" : ""); + + u_stringify_time_diff(time_tmp, cur_ms, afl->last_hang_time); + SAYF(bV bSTOP " last conversation with customers : " cRST "%-33s " bSTG bV bSTOP + " at table : " cRST "%-6s" bSTG bV "\n", + time_tmp, tmp); + + SAYF(bVR bH bSTOP cCYA + " baked progress " bSTG bH10 bH5 bH2 bH2 bH2 bHB bH bSTOP cCYA + " pizzeria busyness" bSTG bHT bH20 bH2 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 + put them in a temporary buffer first. */ + + sprintf(tmp, "%s%s%u (%0.01f%%)", u_stringify_int(IB(0), afl->current_entry), + afl->queue_cur->favored ? "." : "*", afl->queue_cur->fuzz_level, + ((double)afl->current_entry * 100) / afl->queued_items); + + SAYF(bV bSTOP " now baking : " cRST "%-18s " bSTG bV bSTOP, tmp); + + sprintf(tmp, "%0.02f%% / %0.02f%%", + ((double)afl->queue_cur->bitmap_size) * 100 / afl->fsrv.real_map_size, + t_byte_ratio); + + SAYF(" table full : %s%-19s" bSTG bV "\n", + t_byte_ratio > 70 + ? cLRD + : ((t_bytes < 200 && !afl->non_instrumented_mode) ? cPIN : cRST), + tmp); + + sprintf(tmp, "%s (%0.02f%%)", u_stringify_int(IB(0), afl->cur_skipped_items), + ((double)afl->cur_skipped_items * 100) / afl->queued_items); + + SAYF(bV bSTOP " burned pizzas : " cRST "%-18s " bSTG bV, tmp); + + sprintf(tmp, "%0.02f bits/tuple", t_bytes ? (((double)t_bits) / t_bytes) : 0); + + SAYF(bSTOP " count coverage : " cRST "%-19s" bSTG bV "\n", tmp); + + SAYF(bVR bH bSTOP cCYA + " pizzas almost ready " bSTG bH10 bH5 bH2 bH2 bH2 bX bH bSTOP cCYA + " types of pizzas cooking " bSTG bH10 bH5 bH2 bVL "\n"); + + sprintf(tmp, "%s (%0.02f%%)", u_stringify_int(IB(0), afl->queued_favored), + ((double)afl->queued_favored) * 100 / afl->queued_items); + + /* Yeah... it's still going on... halp? */ + + SAYF(bV bSTOP " now preparing : " cRST "%-22s " bSTG bV bSTOP + " favourite topping : " cRST "%-20s" bSTG bV "\n", + afl->stage_name, tmp); + + if (!afl->stage_max) { + + sprintf(tmp, "%s/-", u_stringify_int(IB(0), afl->stage_cur)); + + } else { + + sprintf(tmp, "%s/%s (%0.02f%%)", u_stringify_int(IB(0), afl->stage_cur), + u_stringify_int(IB(1), afl->stage_max), + ((double)afl->stage_cur) * 100 / afl->stage_max); + + } + + SAYF(bV bSTOP " number of pizzas : " cRST "%-23s" bSTG bV bSTOP, tmp); + + sprintf(tmp, "%s (%0.02f%%)", u_stringify_int(IB(0), afl->queued_with_cov), + ((double)afl->queued_with_cov) * 100 / afl->queued_items); + + SAYF(" new pizza type seen on Instagram : " cRST "%-20s" bSTG bV "\n", tmp); + + sprintf(tmp, "%s (%s%s saved)", u_stringify_int(IB(0), afl->total_crashes), + u_stringify_int(IB(1), afl->saved_crashes), + (afl->saved_crashes >= KEEP_UNIQUE_CRASH) ? "+" : ""); + + if (afl->crash_mode) { + + SAYF(bV bSTOP " total pizzas : " cRST "%-22s " bSTG bV bSTOP + " pizzas with pineapple : %s%-20s" bSTG bV "\n", + u_stringify_int(IB(0), afl->fsrv.total_execs), crash_color, tmp); + + } else { + + SAYF(bV bSTOP " total pizzas : " cRST "%-22s " bSTG bV bSTOP + " total pizzas with pineapple : %s%-20s" bSTG bV "\n", + u_stringify_int(IB(0), afl->fsrv.total_execs), crash_color, tmp); + + } + + /* Show a warning about slow execution. */ + + if (afl->stats_avg_exec < 100) { + + sprintf(tmp, "%s/sec (%s)", u_stringify_float(IB(0), afl->stats_avg_exec), + afl->stats_avg_exec < 20 ? "zzzz..." : "Gennarino is at it again!"); + + SAYF(bV bSTOP " pizza making speed : " cLRD "%-22s ", tmp); + + } else { + + sprintf(tmp, "%s/sec", u_stringify_float(IB(0), afl->stats_avg_exec)); + SAYF(bV bSTOP " pizza making speed : " cRST "%-22s ", tmp); + + } + + sprintf(tmp, "%s (%s%s saved)", u_stringify_int(IB(0), afl->total_tmouts), + u_stringify_int(IB(1), afl->saved_tmouts), + (afl->saved_hangs >= KEEP_UNIQUE_HANG) ? "+" : ""); + + SAYF(bSTG bV bSTOP " burned pizzas : " cRST "%-20s" bSTG bV "\n", tmp); + + /* Aaaalmost there... hold on! */ + + SAYF(bVR bH cCYA bSTOP " promotional campaign on Facebook yields " bSTG bH10 bH2 bHT bH10 bH2 + bH bHB bH bSTOP cCYA " customer type " bSTG bH5 bH2 bVL "\n"); + + if (unlikely(afl->custom_only)) { + + strcpy(tmp, "oven off (custom-mutator-only mode)"); + + } else if (likely(afl->skip_deterministic)) { + + strcpy(tmp, "oven off (default, enable with -D)"); + + } else { + + sprintf(tmp, "%s/%s, %s/%s, %s/%s", + u_stringify_int(IB(0), afl->stage_finds[STAGE_FLIP1]), + u_stringify_int(IB(1), afl->stage_cycles[STAGE_FLIP1]), + u_stringify_int(IB(2), afl->stage_finds[STAGE_FLIP2]), + u_stringify_int(IB(3), afl->stage_cycles[STAGE_FLIP2]), + u_stringify_int(IB(4), afl->stage_finds[STAGE_FLIP4]), + u_stringify_int(IB(5), afl->stage_cycles[STAGE_FLIP4])); + + } + + SAYF(bV bSTOP " pizzas for celiac : " cRST "%-36s " bSTG bV bSTOP + " levels : " cRST "%-10s" bSTG bV "\n", + tmp, u_stringify_int(IB(0), afl->max_depth)); + + if (unlikely(!afl->skip_deterministic)) { + + sprintf(tmp, "%s/%s, %s/%s, %s/%s", + u_stringify_int(IB(0), afl->stage_finds[STAGE_FLIP8]), + u_stringify_int(IB(1), afl->stage_cycles[STAGE_FLIP8]), + u_stringify_int(IB(2), afl->stage_finds[STAGE_FLIP16]), + u_stringify_int(IB(3), afl->stage_cycles[STAGE_FLIP16]), + u_stringify_int(IB(4), afl->stage_finds[STAGE_FLIP32]), + u_stringify_int(IB(5), afl->stage_cycles[STAGE_FLIP32])); + + } + + SAYF(bV bSTOP " pizzas for kids : " cRST "%-36s " bSTG bV bSTOP + " pizzas to make : " cRST "%-10s" bSTG bV "\n", + tmp, u_stringify_int(IB(0), afl->pending_not_fuzzed)); + + if (unlikely(!afl->skip_deterministic)) { + + sprintf(tmp, "%s/%s, %s/%s, %s/%s", + u_stringify_int(IB(0), afl->stage_finds[STAGE_ARITH8]), + u_stringify_int(IB(1), afl->stage_cycles[STAGE_ARITH8]), + u_stringify_int(IB(2), afl->stage_finds[STAGE_ARITH16]), + u_stringify_int(IB(3), afl->stage_cycles[STAGE_ARITH16]), + u_stringify_int(IB(4), afl->stage_finds[STAGE_ARITH32]), + u_stringify_int(IB(5), afl->stage_cycles[STAGE_ARITH32])); + + } + + SAYF(bV bSTOP " pizza bianca : " cRST "%-36s " bSTG bV bSTOP + " nice table : " cRST "%-10s" bSTG bV "\n", + tmp, u_stringify_int(IB(0), afl->pending_favored)); + + if (unlikely(!afl->skip_deterministic)) { + + sprintf(tmp, "%s/%s, %s/%s, %s/%s", + u_stringify_int(IB(0), afl->stage_finds[STAGE_INTEREST8]), + u_stringify_int(IB(1), afl->stage_cycles[STAGE_INTEREST8]), + u_stringify_int(IB(2), afl->stage_finds[STAGE_INTEREST16]), + u_stringify_int(IB(3), afl->stage_cycles[STAGE_INTEREST16]), + u_stringify_int(IB(4), afl->stage_finds[STAGE_INTEREST32]), + u_stringify_int(IB(5), afl->stage_cycles[STAGE_INTEREST32])); + + } + + SAYF(bV bSTOP " recurring customers : " cRST "%-36s " bSTG bV bSTOP + " new customers : " cRST "%-10s" bSTG bV "\n", + tmp, u_stringify_int(IB(0), afl->queued_discovered)); + + if (unlikely(!afl->skip_deterministic)) { + + sprintf(tmp, "%s/%s, %s/%s, %s/%s", + u_stringify_int(IB(0), afl->stage_finds[STAGE_EXTRAS_UO]), + u_stringify_int(IB(1), afl->stage_cycles[STAGE_EXTRAS_UO]), + u_stringify_int(IB(2), afl->stage_finds[STAGE_EXTRAS_UI]), + u_stringify_int(IB(3), afl->stage_cycles[STAGE_EXTRAS_UI]), + u_stringify_int(IB(4), afl->stage_finds[STAGE_EXTRAS_AO]), + u_stringify_int(IB(5), afl->stage_cycles[STAGE_EXTRAS_AO])); + + } else if (unlikely(!afl->extras_cnt || afl->custom_only)) { + + strcpy(tmp, "n/a"); + + } else { + + strcpy(tmp, "18 year aniversary mode"); + + } + + SAYF(bV bSTOP " dictionary : " cRST "%-36s " bSTG bV bSTOP + " patrons from old resturant : " cRST "%-10s" bSTG bV "\n", + tmp, + afl->sync_id ? u_stringify_int(IB(0), afl->queued_imported) + : (u8 *)"n/a"); + + sprintf(tmp, "%s/%s, %s/%s", + u_stringify_int(IB(0), afl->stage_finds[STAGE_HAVOC]), + u_stringify_int(IB(2), afl->stage_cycles[STAGE_HAVOC]), + u_stringify_int(IB(3), afl->stage_finds[STAGE_SPLICE]), + u_stringify_int(IB(4), afl->stage_cycles[STAGE_SPLICE])); + + SAYF(bV bSTOP "18 year aniversary mode/cleaning : " cRST "%-36s " bSTG bV bSTOP, tmp); + + if (t_bytes) { + + sprintf(tmp, "%0.02f%%", stab_ratio); + + } else { + + strcpy(tmp, "n/a"); + + } + + SAYF(" oven flameout : %s%-10s" bSTG bV "\n", + (stab_ratio < 85 && afl->var_byte_count > 40) + ? cLRD + : ((afl->queued_variable && + (!afl->persistent_mode || afl->var_byte_count > 20)) + ? cMGN + : cRST), + tmp); + + if (unlikely(afl->afl_env.afl_python_module)) { + + sprintf(tmp, "%s/%s,", + u_stringify_int(IB(0), afl->stage_finds[STAGE_PYTHON]), + u_stringify_int(IB(1), afl->stage_cycles[STAGE_PYTHON])); + + } else { + + strcpy(tmp, "unused,"); + + } + + if (unlikely(afl->afl_env.afl_custom_mutator_library)) { + + strcat(tmp, " "); + strcat(tmp, u_stringify_int(IB(2), afl->stage_finds[STAGE_CUSTOM_MUTATOR])); + strcat(tmp, "/"); + strcat(tmp, + u_stringify_int(IB(3), afl->stage_cycles[STAGE_CUSTOM_MUTATOR])); + strcat(tmp, ","); + + } else { + + strcat(tmp, " unused,"); + + } + + if (unlikely(afl->shm.cmplog_mode)) { + + strcat(tmp, " "); + strcat(tmp, u_stringify_int(IB(4), afl->stage_finds[STAGE_COLORIZATION])); + strcat(tmp, "/"); + strcat(tmp, u_stringify_int(IB(5), afl->stage_cycles[STAGE_COLORIZATION])); + strcat(tmp, ", "); + strcat(tmp, u_stringify_int(IB(6), afl->stage_finds[STAGE_ITS])); + strcat(tmp, "/"); + strcat(tmp, u_stringify_int(IB(7), afl->stage_cycles[STAGE_ITS])); + + } else { + + strcat(tmp, " unused, unused"); + + } + + SAYF(bV bSTOP "py/custom/rq : " cRST "%-36s " bSTG bVR bH20 bH2 bH bRB "\n", + tmp); + + if (likely(afl->disable_trim)) { + + sprintf(tmp, "disabled, "); + + } else if (unlikely(!afl->bytes_trim_out)) { + + sprintf(tmp, "n/a, "); + + } else { + + sprintf(tmp, "%0.02f%%/%s, ", + ((double)(afl->bytes_trim_in - afl->bytes_trim_out)) * 100 / + afl->bytes_trim_in, + u_stringify_int(IB(0), afl->trim_execs)); + + } + + if (likely(afl->skip_deterministic)) { + + strcat(tmp, "disabled"); + + } else if (unlikely(!afl->blocks_eff_total)) { + + strcat(tmp, "n/a"); + + } else { + + u8 tmp2[128]; + + sprintf(tmp2, "%0.02f%%", + ((double)(afl->blocks_eff_total - afl->blocks_eff_select)) * 100 / + afl->blocks_eff_total); + + strcat(tmp, tmp2); + + } + + // if (afl->custom_mutators_count) { + + // + // sprintf(tmp, "%s/%s", + // u_stringify_int(IB(0), afl->stage_finds[STAGE_CUSTOM_MUTATOR]), + // u_stringify_int(IB(1), afl->stage_cycles[STAGE_CUSTOM_MUTATOR])); + // SAYF(bV bSTOP " custom mut. : " cRST "%-36s " bSTG bV RESET_G1, tmp); + // + //} else { + + SAYF(bV bSTOP " toilets clogged : " cRST "%-36s " bSTG bV RESET_G1, tmp); + + //} + + /* Provide some CPU utilization stats. */ + + if (afl->cpu_core_count) { + + char *spacing = SP10, snap[24] = " " cLGN "Pizzaioli's busyness " cRST " "; + + double cur_runnable = get_runnable_processes(); + u32 cur_utilization = cur_runnable * 100 / afl->cpu_core_count; + + u8 *cpu_color = cCYA; + + /* If we could still run one or more processes, use green. */ + + if (afl->cpu_core_count > 1 && cur_runnable + 1 <= afl->cpu_core_count) { + + cpu_color = cLGN; + + } + + /* If we're clearly oversubscribed, use red. */ + + if (!afl->no_cpu_meter_red && cur_utilization >= 150) { cpu_color = cLRD; } + + if (afl->fsrv.snapshot) { spacing = snap; } + +#ifdef HAVE_AFFINITY + + if (afl->cpu_aff >= 0) { + + SAYF("%s" cGRA "[cpu%03u:%s%3u%%" cGRA "]\r" cRST, spacing, + MIN(afl->cpu_aff, 999), cpu_color, MIN(cur_utilization, (u32)999)); + + } else { + + SAYF("%s" cGRA " [cpu:%s%3u%%" cGRA "]\r" cRST, spacing, cpu_color, + MIN(cur_utilization, (u32)999)); + + } + +#else + + SAYF("%s" cGRA " [cpu:%s%3u%%" cGRA "]\r" cRST, spacing, cpu_color, + MIN(cur_utilization, (u32)999)); + +#endif /* ^HAVE_AFFINITY */ + + } else { + + SAYF("\r"); + + } + + /* Last line */ + SAYF(SET_G1 "\n" bSTG bLB bH30 bH20 bH2 bRB bSTOP cRST RESET_G1); + +#undef IB + + /* Hallelujah! */ + + fflush(0); + +} + + + /* Display quick statistics at the end of processing the input directory, plus a bunch of warnings. Some calibration stuff also ended up here, along with several hardcoded constants. Maybe clean up eventually. */ -- cgit 1.4.1 From 657e4cc81234967495792174856605e4c29fcf35 Mon Sep 17 00:00:00 2001 From: Carlo Maragno Date: Fri, 1 Apr 2022 14:56:27 +0200 Subject: Fix layout --- include/afl-fuzz.h | 2 ++ include/envs.h | 1 + src/afl-fuzz-stats.c | 100 +++++++++++++++++++++++++-------------------------- 3 files changed, 53 insertions(+), 50 deletions(-) (limited to 'src') diff --git a/include/afl-fuzz.h b/include/afl-fuzz.h index 9eac502f..9fddac32 100644 --- a/include/afl-fuzz.h +++ b/include/afl-fuzz.h @@ -1082,6 +1082,8 @@ void write_setup_file(afl_state_t *, u32, char **); void write_stats_file(afl_state_t *, u32, double, double, double); void maybe_update_plot_file(afl_state_t *, u32, double, double); void show_stats(afl_state_t *); +void show_stats_normal(afl_state_t *); +void show_stats_pizza(afl_state_t *); void show_init_stats(afl_state_t *); /* StatsD */ diff --git a/include/envs.h b/include/envs.h index f4327d8c..2c9305f6 100644 --- a/include/envs.h +++ b/include/envs.h @@ -221,6 +221,7 @@ static char *afl_environment_variables[] = { "AFL_USE_FASAN", "AFL_USE_QASAN", "AFL_PRINT_FILENAMES", + "AFL_PIZZA_MODE", NULL }; diff --git a/src/afl-fuzz-stats.c b/src/afl-fuzz-stats.c index c5561414..88ca53eb 100644 --- a/src/afl-fuzz-stats.c +++ b/src/afl-fuzz-stats.c @@ -1374,7 +1374,7 @@ void show_stats_pizza(afl_state_t *afl) { /* reset counter, even if send failed. */ afl->statsd_last_send_ms = cur_ms; - if (statsd_send_metric(afl)) { WARNF("could not order tomato sauce from statsd."); } + if (statsd_send_metric(afl)) { WARNF("Could not order tomato sauce from statsd."); } } @@ -1520,8 +1520,8 @@ void show_stats_pizza(afl_state_t *afl) { /* Lord, forgive me this. */ SAYF(SET_G1 bSTG bLT bH bSTOP cCYA - " Mozzarbella has been proudly serving pizzas since " bSTG bH30 bH5 bH bHB bH bSTOP cCYA - " In this time, we served " bSTG bH2 bH2 bRT "\n"); + " Mozzarbella has been proudly serving pizzas since " bSTG bH20 bH bH bH bHB bH bSTOP cCYA + " In this time, we served " bSTG bH30 bRT "\n"); if (afl->non_instrumented_mode) { @@ -1562,8 +1562,8 @@ void show_stats_pizza(afl_state_t *afl) { } u_stringify_time_diff(time_tmp, afl->prev_run_time + cur_ms, afl->start_time); - SAYF(bV bSTOP " open time : " cRST "%-33s " bSTG bV bSTOP - " seasons done : %s%-5s " bSTG bV "\n", + SAYF(bV bSTOP " open time : " cRST "%-37s " bSTG bV bSTOP + " seasons done : %s%-5s " bSTG bV "\n", time_tmp, tmp, u_stringify_int(IB(0), afl->queue_cycle - 1)); /* We want to warn people about not seeing new paths after a full cycle, @@ -1574,25 +1574,25 @@ 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 ", time_tmp); + SAYF(bV bSTOP " last pizza baked : " cRST "%-33s ", time_tmp); } else { if (afl->non_instrumented_mode) { - SAYF(bV bSTOP " last pizza baked : " cPIN "n/a" cRST - " (non-instrumented mode) "); + SAYF(bV bSTOP " last pizza baked : " cPIN "n/a" cRST + " (non-instrumented mode) "); } else { - SAYF(bV bSTOP " last pizza baked : " cRST "none yet " cLRD + SAYF(bV bSTOP " last pizza baked : " cRST "none yet " cLRD "(odd, check Gennarino, he might be slacking!) "); } } - SAYF(bSTG bV bSTOP " pizzas on the menu : " cRST "%-5s " bSTG bV "\n", + SAYF(bSTG bV bSTOP " pizzas on the menu : " cRST "%-5s " bSTG bV "\n", u_stringify_int(IB(0), afl->queued_items)); /* Highlight crashes in red if found, denote going over the KEEP_UNIQUE_CRASH @@ -1602,21 +1602,21 @@ void show_stats_pizza(afl_state_t *afl) { (afl->saved_crashes >= KEEP_UNIQUE_CRASH) ? "+" : ""); u_stringify_time_diff(time_tmp, cur_ms, afl->last_crash_time); - SAYF(bV bSTOP "last ordered pizza : " cRST "%-33s " bSTG bV bSTOP - "at table : %s%-6s" bSTG bV "\n", + SAYF(bV bSTOP " last ordered pizza : " cRST "%-33s " bSTG bV bSTOP + " at table : %s%-6s " bSTG bV "\n", time_tmp, crash_color, tmp); sprintf(tmp, "%s%s", u_stringify_int(IB(0), afl->saved_hangs), (afl->saved_hangs >= KEEP_UNIQUE_HANG) ? "+" : ""); u_stringify_time_diff(time_tmp, cur_ms, afl->last_hang_time); - SAYF(bV bSTOP " last conversation with customers : " cRST "%-33s " bSTG bV bSTOP - " at table : " cRST "%-6s" bSTG bV "\n", + SAYF(bV bSTOP " last conversation with customers : " cRST "%-33s " bSTG bV bSTOP + " at table : " cRST "%-6s " bSTG bV "\n", time_tmp, tmp); SAYF(bVR bH bSTOP cCYA - " baked progress " bSTG bH10 bH5 bH2 bH2 bH2 bHB bH bSTOP cCYA - " pizzeria busyness" bSTG bHT bH20 bH2 bVL "\n"); + " Backing progress " bSTG bH30 bH20 bH5 bX bH bSTOP cCYA + " 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 @@ -1626,13 +1626,13 @@ void show_stats_pizza(afl_state_t *afl) { afl->queue_cur->favored ? "." : "*", afl->queue_cur->fuzz_level, ((double)afl->current_entry * 100) / afl->queued_items); - SAYF(bV bSTOP " now baking : " cRST "%-18s " bSTG bV bSTOP, tmp); + SAYF(bV bSTOP " now baking : " cRST "%-18s " bSTG bV bSTOP, tmp); sprintf(tmp, "%0.02f%% / %0.02f%%", ((double)afl->queue_cur->bitmap_size) * 100 / afl->fsrv.real_map_size, t_byte_ratio); - SAYF(" table full : %s%-19s" bSTG bV "\n", + SAYF(" table full : %s%-19s " bSTG bV "\n", t_byte_ratio > 70 ? cLRD : ((t_bytes < 200 && !afl->non_instrumented_mode) ? cPIN : cRST), @@ -1641,23 +1641,23 @@ void show_stats_pizza(afl_state_t *afl) { sprintf(tmp, "%s (%0.02f%%)", u_stringify_int(IB(0), afl->cur_skipped_items), ((double)afl->cur_skipped_items * 100) / afl->queued_items); - SAYF(bV bSTOP " burned pizzas : " cRST "%-18s " bSTG bV, tmp); + SAYF(bV bSTOP " burned pizzas : " cRST "%-18s " bSTG bV, tmp); sprintf(tmp, "%0.02f bits/tuple", t_bytes ? (((double)t_bits) / t_bytes) : 0); - SAYF(bSTOP " count coverage : " cRST "%-19s" bSTG bV "\n", tmp); + SAYF(bSTOP " count coverage : " cRST "%-19s " bSTG bV "\n", tmp); SAYF(bVR bH bSTOP cCYA - " pizzas almost ready " bSTG bH10 bH5 bH2 bH2 bH2 bX bH bSTOP cCYA - " types of pizzas cooking " bSTG bH10 bH5 bH2 bVL "\n"); + " Pizzas almost ready " bSTG bH30 bH20 bH2 bH bX bH bSTOP cCYA + " Types of pizzas cooking " bSTG bH10 bH5 bH2 bH10 bH2 bH bVL "\n"); sprintf(tmp, "%s (%0.02f%%)", u_stringify_int(IB(0), afl->queued_favored), ((double)afl->queued_favored) * 100 / afl->queued_items); /* Yeah... it's still going on... halp? */ - SAYF(bV bSTOP " now preparing : " cRST "%-22s " bSTG bV bSTOP - " favourite topping : " cRST "%-20s" bSTG bV "\n", + SAYF(bV bSTOP " now preparing : " cRST "%-22s " bSTG bV bSTOP + " favourite topping : " cRST "%-20s" bSTG bV "\n", afl->stage_name, tmp); if (!afl->stage_max) { @@ -1672,12 +1672,12 @@ void show_stats_pizza(afl_state_t *afl) { } - SAYF(bV bSTOP " number of pizzas : " cRST "%-23s" bSTG bV bSTOP, tmp); + SAYF(bV bSTOP " number of pizzas : " cRST "%-23s " bSTG bV bSTOP, tmp); sprintf(tmp, "%s (%0.02f%%)", u_stringify_int(IB(0), afl->queued_with_cov), ((double)afl->queued_with_cov) * 100 / afl->queued_items); - SAYF(" new pizza type seen on Instagram : " cRST "%-20s" bSTG bV "\n", tmp); + SAYF(" new pizza type seen on Instagram : " cRST "%-20s" bSTG bV "\n", tmp); sprintf(tmp, "%s (%s%s saved)", u_stringify_int(IB(0), afl->total_crashes), u_stringify_int(IB(1), afl->saved_crashes), @@ -1685,14 +1685,14 @@ void show_stats_pizza(afl_state_t *afl) { if (afl->crash_mode) { - SAYF(bV bSTOP " total pizzas : " cRST "%-22s " bSTG bV bSTOP - " pizzas with pineapple : %s%-20s" bSTG bV "\n", + SAYF(bV bSTOP " total pizzas : " cRST "%-22s " bSTG bV bSTOP + " pizzas with pineapple : %s%-20s" bSTG bV "\n", u_stringify_int(IB(0), afl->fsrv.total_execs), crash_color, tmp); } else { - SAYF(bV bSTOP " total pizzas : " cRST "%-22s " bSTG bV bSTOP - " total pizzas with pineapple : %s%-20s" bSTG bV "\n", + SAYF(bV bSTOP " total pizzas : " cRST "%-22s " bSTG bV bSTOP + " total pizzas with pineapple : %s%-20s" bSTG bV "\n", u_stringify_int(IB(0), afl->fsrv.total_execs), crash_color, tmp); } @@ -1704,12 +1704,12 @@ void show_stats_pizza(afl_state_t *afl) { sprintf(tmp, "%s/sec (%s)", u_stringify_float(IB(0), afl->stats_avg_exec), afl->stats_avg_exec < 20 ? "zzzz..." : "Gennarino is at it again!"); - SAYF(bV bSTOP " pizza making speed : " cLRD "%-22s ", tmp); + SAYF(bV bSTOP " pizza making speed : " cLRD "%-22s ", tmp); } else { sprintf(tmp, "%s/sec", u_stringify_float(IB(0), afl->stats_avg_exec)); - SAYF(bV bSTOP " pizza making speed : " cRST "%-22s ", tmp); + SAYF(bV bSTOP " pizza making speed : " cRST "%-22s ", tmp); } @@ -1717,12 +1717,12 @@ void show_stats_pizza(afl_state_t *afl) { u_stringify_int(IB(1), afl->saved_tmouts), (afl->saved_hangs >= KEEP_UNIQUE_HANG) ? "+" : ""); - SAYF(bSTG bV bSTOP " burned pizzas : " cRST "%-20s" bSTG bV "\n", tmp); + SAYF(bSTG bV bSTOP " burned pizzas : " cRST "%-20s" bSTG bV "\n", tmp); /* Aaaalmost there... hold on! */ - SAYF(bVR bH cCYA bSTOP " promotional campaign on Facebook yields " bSTG bH10 bH2 bHT bH10 bH2 - bH bHB bH bSTOP cCYA " customer type " bSTG bH5 bH2 bVL "\n"); + SAYF(bVR bH cCYA bSTOP " Promotional campaign on Facebook yields " bSTG bH30 bH2 + bH bX bH bSTOP cCYA " Customer type " bSTG bH5 bH2 bH30 bH2 bH bVL "\n"); if (unlikely(afl->custom_only)) { @@ -1744,8 +1744,8 @@ void show_stats_pizza(afl_state_t *afl) { } - SAYF(bV bSTOP " pizzas for celiac : " cRST "%-36s " bSTG bV bSTOP - " levels : " cRST "%-10s" bSTG bV "\n", + SAYF(bV bSTOP " pizzas for celiac : " cRST "%-36s " bSTG bV bSTOP + " levels : " cRST "%-10s " bSTG bV "\n", tmp, u_stringify_int(IB(0), afl->max_depth)); if (unlikely(!afl->skip_deterministic)) { @@ -1760,8 +1760,8 @@ void show_stats_pizza(afl_state_t *afl) { } - SAYF(bV bSTOP " pizzas for kids : " cRST "%-36s " bSTG bV bSTOP - " pizzas to make : " cRST "%-10s" bSTG bV "\n", + SAYF(bV bSTOP " pizzas for kids : " cRST "%-36s " bSTG bV bSTOP + " pizzas to make : " cRST "%-10s " bSTG bV "\n", tmp, u_stringify_int(IB(0), afl->pending_not_fuzzed)); if (unlikely(!afl->skip_deterministic)) { @@ -1776,8 +1776,8 @@ void show_stats_pizza(afl_state_t *afl) { } - SAYF(bV bSTOP " pizza bianca : " cRST "%-36s " bSTG bV bSTOP - " nice table : " cRST "%-10s" bSTG bV "\n", + SAYF(bV bSTOP " pizza bianca : " cRST "%-36s " bSTG bV bSTOP + " nice table : " cRST "%-10s " bSTG bV "\n", tmp, u_stringify_int(IB(0), afl->pending_favored)); if (unlikely(!afl->skip_deterministic)) { @@ -1792,8 +1792,8 @@ void show_stats_pizza(afl_state_t *afl) { } - SAYF(bV bSTOP " recurring customers : " cRST "%-36s " bSTG bV bSTOP - " new customers : " cRST "%-10s" bSTG bV "\n", + SAYF(bV bSTOP " recurring customers : " cRST "%-36s " bSTG bV bSTOP + " new customers : " cRST "%-10s " bSTG bV "\n", tmp, u_stringify_int(IB(0), afl->queued_discovered)); if (unlikely(!afl->skip_deterministic)) { @@ -1816,8 +1816,8 @@ void show_stats_pizza(afl_state_t *afl) { } - SAYF(bV bSTOP " dictionary : " cRST "%-36s " bSTG bV bSTOP - " patrons from old resturant : " cRST "%-10s" bSTG bV "\n", + SAYF(bV bSTOP " dictionary : " cRST "%-36s " bSTG bV bSTOP + " patrons from old resturant : " cRST "%-10s " bSTG bV "\n", tmp, afl->sync_id ? u_stringify_int(IB(0), afl->queued_imported) : (u8 *)"n/a"); @@ -1828,7 +1828,7 @@ void show_stats_pizza(afl_state_t *afl) { u_stringify_int(IB(3), afl->stage_finds[STAGE_SPLICE]), u_stringify_int(IB(4), afl->stage_cycles[STAGE_SPLICE])); - SAYF(bV bSTOP "18 year aniversary mode/cleaning : " cRST "%-36s " bSTG bV bSTOP, tmp); + SAYF(bV bSTOP " 18 year aniversary mode/cleaning : " cRST "%-36s " bSTG bV bSTOP, tmp); if (t_bytes) { @@ -1840,7 +1840,7 @@ void show_stats_pizza(afl_state_t *afl) { } - SAYF(" oven flameout : %s%-10s" bSTG bV "\n", + SAYF(" oven flameout : %s%-10s " bSTG bV "\n", (stab_ratio < 85 && afl->var_byte_count > 40) ? cLRD : ((afl->queued_variable && @@ -1893,7 +1893,7 @@ void show_stats_pizza(afl_state_t *afl) { } - SAYF(bV bSTOP "py/custom/rq : " cRST "%-36s " bSTG bVR bH20 bH2 bH bRB "\n", + SAYF(bV bSTOP " py/custom/rq : " cRST "%-36s " bSTG bVR bH20 bH2 bH30 bH2 bH bH bRB "\n", tmp); if (likely(afl->disable_trim)) { @@ -1943,7 +1943,7 @@ void show_stats_pizza(afl_state_t *afl) { // //} else { - SAYF(bV bSTOP " toilets clogged : " cRST "%-36s " bSTG bV RESET_G1, tmp); + SAYF(bV bSTOP " toilets clogged : " cRST "%-36s " bSTG bV RESET_G1, tmp); //} @@ -2000,7 +2000,7 @@ void show_stats_pizza(afl_state_t *afl) { } /* Last line */ - SAYF(SET_G1 "\n" bSTG bLB bH30 bH20 bH2 bRB bSTOP cRST RESET_G1); + SAYF(SET_G1 "\n" bSTG bLB bH30 bH20 bH2 bH20 bH2 bH bRB bSTOP cRST RESET_G1); #undef IB -- cgit 1.4.1 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 --- include/afl-fuzz.h | 3 +- src/afl-fuzz-state.c | 2 +- src/afl-fuzz-stats.c | 158 +++++++++++++++++++++++++++++++++------------------ src/afl-fuzz.c | 13 ++++- 4 files changed, 116 insertions(+), 60 deletions(-) (limited to 'src') diff --git a/include/afl-fuzz.h b/include/afl-fuzz.h index 9fddac32..6cde7695 100644 --- a/include/afl-fuzz.h +++ b/include/afl-fuzz.h @@ -384,7 +384,8 @@ typedef struct afl_env_vars { afl_force_ui, afl_i_dont_care_about_missing_crashes, afl_bench_just_one, afl_bench_until_crash, afl_debug_child, afl_autoresume, afl_cal_fast, afl_cycle_schedules, afl_expand_havoc, afl_statsd, afl_cmplog_only_new, - afl_exit_on_seed_issues, afl_try_affinity, afl_ignore_problems, afl_pizza_mode; + afl_exit_on_seed_issues, afl_try_affinity, afl_ignore_problems, + afl_pizza_mode; u8 *afl_tmpdir, *afl_custom_mutator_library, *afl_python_module, *afl_path, *afl_hang_tmout, *afl_forksrv_init_tmout, *afl_preload, diff --git a/src/afl-fuzz-state.c b/src/afl-fuzz-state.c index 5299e9e5..507ddb46 100644 --- a/src/afl-fuzz-state.c +++ b/src/afl-fuzz-state.c @@ -496,7 +496,7 @@ void read_afl_environment(afl_state_t *afl, char **envp) { afl->max_length = atoi((u8 *)get_afl_env(afl_environment_variables[i])); - }else if (!strncmp(env, "AFL_PIZZA_MODE", + } else if (!strncmp(env, "AFL_PIZZA_MODE", afl_environment_variable_len)) { diff --git a/src/afl-fuzz-stats.c b/src/afl-fuzz-stats.c index 88ca53eb..689f9c5d 100644 --- a/src/afl-fuzz-stats.c +++ b/src/afl-fuzz-stats.c @@ -435,16 +435,19 @@ static void check_term_size(afl_state_t *afl) { /* A spiffy retro stats screen! This is called every afl->stats_update_freq execve() calls, plus in several other circumstances. */ - void show_stats(afl_state_t *afl) { - if(afl->afl_env.afl_pizza_mode){ + + if (afl->afl_env.afl_pizza_mode) { + show_stats_pizza(afl); - } - else{ + + } else { + show_stats_normal(afl); + } -} +} void show_stats_normal(afl_state_t *afl) { @@ -1230,7 +1233,6 @@ void show_stats_normal(afl_state_t *afl) { } - void show_stats_pizza(afl_state_t *afl) { double t_byte_ratio, stab_ratio; @@ -1339,6 +1341,7 @@ void show_stats_pizza(afl_state_t *afl) { FATAL( "This is what happens when you speak italian to the rabbit " "Don't speak italian to the rabbit"); + } } @@ -1374,7 +1377,11 @@ void show_stats_pizza(afl_state_t *afl) { /* reset counter, even if send failed. */ afl->statsd_last_send_ms = cur_ms; - if (statsd_send_metric(afl)) { WARNF("Could not order tomato sauce from statsd."); } + if (statsd_send_metric(afl)) { + + WARNF("Could not order tomato sauce from statsd."); + + } } @@ -1444,7 +1451,8 @@ void show_stats_pizza(afl_state_t *afl) { SAYF(cBRI "Our pizzeria can't host this many guests.\n" - "Please call Pizzeria Caravaggio. They have tables of at least 79x24.\n" cRST); + "Please call Pizzeria Caravaggio. They have tables of at least " + "79x24.\n" cRST); return; @@ -1476,7 +1484,7 @@ void show_stats_pizza(afl_state_t *afl) { sprintf(banner + banner_pad, "%s " cLCY VERSION cLBL " {%s} " cLGN "(%s) " cPIN "[%s] - Nyx", afl->crash_mode ? cPIN "Mozzarbella Pizzeria table booking system" - : cYEL "Mozzarbella Pizzeria managment system", + : cYEL "Mozzarbella Pizzeria management system", si, afl->use_banner, afl->power_name); } else { @@ -1485,7 +1493,7 @@ void show_stats_pizza(afl_state_t *afl) { sprintf(banner + banner_pad, "%s " cLCY VERSION cLBL " {%s} " cLGN "(%s) " cPIN "[%s]", afl->crash_mode ? cPIN "Mozzarbella Pizzeria table booking system" - : cYEL "Mozzarbella Pizzeria managment system", + : cYEL "Mozzarbella Pizzeria management system", si, afl->use_banner, afl->power_name); #ifdef __linux__ @@ -1519,9 +1527,9 @@ void show_stats_pizza(afl_state_t *afl) { /* Lord, forgive me this. */ - SAYF(SET_G1 bSTG bLT bH bSTOP cCYA - " Mozzarbella has been proudly serving pizzas since " bSTG bH20 bH bH bH bHB bH bSTOP cCYA - " In this time, we served " bSTG bH30 bRT "\n"); + SAYF(SET_G1 bSTG bLT bH bSTOP cCYA + " Mozzarbella has been proudly serving pizzas since " bSTG bH20 bH bH bH + bHB bH bSTOP cCYA " In this time, we served " bSTG bH30 bRT "\n"); if (afl->non_instrumented_mode) { @@ -1562,8 +1570,9 @@ void show_stats_pizza(afl_state_t *afl) { } u_stringify_time_diff(time_tmp, afl->prev_run_time + cur_ms, afl->start_time); - SAYF(bV bSTOP " open time : " cRST "%-37s " bSTG bV bSTOP - " seasons done : %s%-5s " bSTG bV "\n", + SAYF(bV bSTOP + " open time : " cRST "%-37s " bSTG bV bSTOP + " seasons done : %s%-5s " bSTG bV "\n", time_tmp, tmp, u_stringify_int(IB(0), afl->queue_cycle - 1)); /* We want to warn people about not seeing new paths after a full cycle, @@ -1574,7 +1583,8 @@ 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 ", time_tmp); + SAYF(bV bSTOP " last pizza baked : " cRST "%-33s ", + time_tmp); } else { @@ -1585,14 +1595,16 @@ void show_stats_pizza(afl_state_t *afl) { } else { - SAYF(bV bSTOP " last pizza baked : " cRST "none yet " cLRD + SAYF(bV bSTOP " last pizza baked : " cRST + "none yet " cLRD "(odd, check Gennarino, he might be slacking!) "); } } - SAYF(bSTG bV bSTOP " pizzas on the menu : " cRST "%-5s " bSTG bV "\n", + SAYF(bSTG bV bSTOP " pizzas on the menu : " cRST + "%-5s " bSTG bV "\n", u_stringify_int(IB(0), afl->queued_items)); /* Highlight crashes in red if found, denote going over the KEEP_UNIQUE_CRASH @@ -1602,21 +1614,24 @@ void show_stats_pizza(afl_state_t *afl) { (afl->saved_crashes >= KEEP_UNIQUE_CRASH) ? "+" : ""); u_stringify_time_diff(time_tmp, cur_ms, afl->last_crash_time); - SAYF(bV bSTOP " last ordered pizza : " cRST "%-33s " bSTG bV bSTOP - " at table : %s%-6s " bSTG bV "\n", + SAYF(bV bSTOP + " last ordered pizza : " cRST "%-33s " bSTG bV bSTOP + " at table : %s%-6s " bSTG bV "\n", time_tmp, crash_color, tmp); sprintf(tmp, "%s%s", u_stringify_int(IB(0), afl->saved_hangs), (afl->saved_hangs >= KEEP_UNIQUE_HANG) ? "+" : ""); u_stringify_time_diff(time_tmp, cur_ms, afl->last_hang_time); - SAYF(bV bSTOP " last conversation with customers : " cRST "%-33s " bSTG bV bSTOP - " at table : " cRST "%-6s " bSTG bV "\n", + SAYF(bV bSTOP + " last conversation with customers : " cRST "%-33s " bSTG bV bSTOP + " number of Peroni : " cRST "%-6s " bSTG bV + "\n", time_tmp, tmp); - SAYF(bVR bH bSTOP cCYA - " Backing progress " bSTG bH30 bH20 bH5 bX bH bSTOP cCYA - " Pizzeria busyness" bSTG bH30 bH5 bH bH bVL "\n"); + 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"); /* 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 @@ -1626,7 +1641,9 @@ void show_stats_pizza(afl_state_t *afl) { afl->queue_cur->favored ? "." : "*", afl->queue_cur->fuzz_level, ((double)afl->current_entry * 100) / afl->queued_items); - SAYF(bV bSTOP " now baking : " cRST "%-18s " bSTG bV bSTOP, tmp); + SAYF(bV bSTOP " now baking : " cRST + "%-18s " bSTG bV bSTOP, + tmp); sprintf(tmp, "%0.02f%% / %0.02f%%", ((double)afl->queue_cur->bitmap_size) * 100 / afl->fsrv.real_map_size, @@ -1641,13 +1658,16 @@ void show_stats_pizza(afl_state_t *afl) { sprintf(tmp, "%s (%0.02f%%)", u_stringify_int(IB(0), afl->cur_skipped_items), ((double)afl->cur_skipped_items * 100) / afl->queued_items); - SAYF(bV bSTOP " burned pizzas : " cRST "%-18s " bSTG bV, tmp); + SAYF(bV bSTOP " burned pizzas : " cRST + "%-18s " bSTG bV, + tmp); sprintf(tmp, "%0.02f bits/tuple", t_bytes ? (((double)t_bits) / t_bytes) : 0); - SAYF(bSTOP " count coverage : " cRST "%-19s " bSTG bV "\n", tmp); + SAYF(bSTOP " count coverage : " cRST "%-19s " bSTG bV "\n", + tmp); - SAYF(bVR bH bSTOP cCYA + SAYF(bVR bH bSTOP cCYA " Pizzas almost ready " bSTG bH30 bH20 bH2 bH bX bH bSTOP cCYA " Types of pizzas cooking " bSTG bH10 bH5 bH2 bH10 bH2 bH bVL "\n"); @@ -1656,8 +1676,10 @@ void show_stats_pizza(afl_state_t *afl) { /* Yeah... it's still going on... halp? */ - SAYF(bV bSTOP " now preparing : " cRST "%-22s " bSTG bV bSTOP - " favourite topping : " cRST "%-20s" bSTG bV "\n", + SAYF(bV bSTOP " now preparing : " cRST + "%-22s " bSTG bV bSTOP + " favourite topping : " cRST "%-20s" bSTG bV + "\n", afl->stage_name, tmp); if (!afl->stage_max) { @@ -1672,7 +1694,9 @@ void show_stats_pizza(afl_state_t *afl) { } - SAYF(bV bSTOP " number of pizzas : " cRST "%-23s " bSTG bV bSTOP, tmp); + SAYF(bV bSTOP " number of pizzas : " cRST + "%-23s " bSTG bV bSTOP, + tmp); sprintf(tmp, "%s (%0.02f%%)", u_stringify_int(IB(0), afl->queued_with_cov), ((double)afl->queued_with_cov) * 100 / afl->queued_items); @@ -1685,14 +1709,16 @@ void show_stats_pizza(afl_state_t *afl) { if (afl->crash_mode) { - SAYF(bV bSTOP " total pizzas : " cRST "%-22s " bSTG bV bSTOP - " pizzas with pineapple : %s%-20s" bSTG bV "\n", + SAYF(bV bSTOP " total pizzas : " cRST + "%-22s " bSTG bV bSTOP + " pizzas with pineapple : %s%-20s" bSTG bV "\n", u_stringify_int(IB(0), afl->fsrv.total_execs), crash_color, tmp); } else { - SAYF(bV bSTOP " total pizzas : " cRST "%-22s " bSTG bV bSTOP - " total pizzas with pineapple : %s%-20s" bSTG bV "\n", + SAYF(bV bSTOP " total pizzas : " cRST + "%-22s " bSTG bV bSTOP + " total pizzas with pineapple : %s%-20s" bSTG bV "\n", u_stringify_int(IB(0), afl->fsrv.total_execs), crash_color, tmp); } @@ -1704,12 +1730,16 @@ void show_stats_pizza(afl_state_t *afl) { sprintf(tmp, "%s/sec (%s)", u_stringify_float(IB(0), afl->stats_avg_exec), afl->stats_avg_exec < 20 ? "zzzz..." : "Gennarino is at it again!"); - SAYF(bV bSTOP " pizza making speed : " cLRD "%-22s ", tmp); + SAYF(bV bSTOP " pizza making speed : " cLRD + "%-22s ", + tmp); } else { sprintf(tmp, "%s/sec", u_stringify_float(IB(0), afl->stats_avg_exec)); - SAYF(bV bSTOP " pizza making speed : " cRST "%-22s ", tmp); + SAYF(bV bSTOP " pizza making speed : " cRST + "%-22s ", + tmp); } @@ -1717,12 +1747,15 @@ void show_stats_pizza(afl_state_t *afl) { u_stringify_int(IB(1), afl->saved_tmouts), (afl->saved_hangs >= KEEP_UNIQUE_HANG) ? "+" : ""); - SAYF(bSTG bV bSTOP " burned pizzas : " cRST "%-20s" bSTG bV "\n", tmp); + SAYF(bSTG bV bSTOP " burned pizzas : " cRST "%-20s" bSTG bV + "\n", + tmp); /* Aaaalmost there... hold on! */ - SAYF(bVR bH cCYA bSTOP " Promotional campaign on Facebook yields " bSTG bH30 bH2 - bH bX bH bSTOP cCYA " Customer type " bSTG bH5 bH2 bH30 bH2 bH bVL "\n"); + 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"); if (unlikely(afl->custom_only)) { @@ -1744,8 +1777,10 @@ void show_stats_pizza(afl_state_t *afl) { } - SAYF(bV bSTOP " pizzas for celiac : " cRST "%-36s " bSTG bV bSTOP - " levels : " cRST "%-10s " bSTG bV "\n", + SAYF(bV bSTOP + " pizzas for celiac : " cRST "%-36s " bSTG bV bSTOP + " levels : " cRST "%-10s " bSTG bV + "\n", tmp, u_stringify_int(IB(0), afl->max_depth)); if (unlikely(!afl->skip_deterministic)) { @@ -1760,8 +1795,10 @@ void show_stats_pizza(afl_state_t *afl) { } - SAYF(bV bSTOP " pizzas for kids : " cRST "%-36s " bSTG bV bSTOP - " pizzas to make : " cRST "%-10s " bSTG bV "\n", + SAYF(bV bSTOP + " pizzas for kids : " cRST "%-36s " bSTG bV bSTOP + " pizzas to make : " cRST "%-10s " bSTG bV + "\n", tmp, u_stringify_int(IB(0), afl->pending_not_fuzzed)); if (unlikely(!afl->skip_deterministic)) { @@ -1776,8 +1813,10 @@ void show_stats_pizza(afl_state_t *afl) { } - SAYF(bV bSTOP " pizza bianca : " cRST "%-36s " bSTG bV bSTOP - " nice table : " cRST "%-10s " bSTG bV "\n", + SAYF(bV bSTOP + " pizza bianca : " cRST "%-36s " bSTG bV bSTOP + " nice table : " cRST "%-10s " bSTG bV + "\n", tmp, u_stringify_int(IB(0), afl->pending_favored)); if (unlikely(!afl->skip_deterministic)) { @@ -1792,8 +1831,10 @@ void show_stats_pizza(afl_state_t *afl) { } - SAYF(bV bSTOP " recurring customers : " cRST "%-36s " bSTG bV bSTOP - " new customers : " cRST "%-10s " bSTG bV "\n", + SAYF(bV bSTOP + " recurring customers : " cRST "%-36s " bSTG bV bSTOP + " new customers : " cRST "%-10s " bSTG bV + "\n", tmp, u_stringify_int(IB(0), afl->queued_discovered)); if (unlikely(!afl->skip_deterministic)) { @@ -1816,8 +1857,10 @@ void show_stats_pizza(afl_state_t *afl) { } - SAYF(bV bSTOP " dictionary : " cRST "%-36s " bSTG bV bSTOP - " patrons from old resturant : " cRST "%-10s " bSTG bV "\n", + SAYF(bV bSTOP + " dictionary : " cRST "%-36s " bSTG bV bSTOP + " patrons from old resturant : " cRST "%-10s " bSTG bV + "\n", tmp, afl->sync_id ? u_stringify_int(IB(0), afl->queued_imported) : (u8 *)"n/a"); @@ -1828,7 +1871,9 @@ void show_stats_pizza(afl_state_t *afl) { u_stringify_int(IB(3), afl->stage_finds[STAGE_SPLICE]), u_stringify_int(IB(4), afl->stage_cycles[STAGE_SPLICE])); - SAYF(bV bSTOP " 18 year aniversary mode/cleaning : " cRST "%-36s " bSTG bV bSTOP, tmp); + SAYF(bV bSTOP " 18 year anniversary mode/cleaning : " cRST + "%-36s " bSTG bV bSTOP, + tmp); if (t_bytes) { @@ -1893,7 +1938,8 @@ void show_stats_pizza(afl_state_t *afl) { } - SAYF(bV bSTOP " py/custom/rq : " cRST "%-36s " bSTG bVR bH20 bH2 bH30 bH2 bH bH bRB "\n", + SAYF(bV bSTOP " py/custom/rq : " cRST + "%-36s " bSTG bVR bH20 bH2 bH30 bH2 bH bH bRB "\n", tmp); if (likely(afl->disable_trim)) { @@ -1943,7 +1989,9 @@ void show_stats_pizza(afl_state_t *afl) { // //} else { - SAYF(bV bSTOP " toilets clogged : " cRST "%-36s " bSTG bV RESET_G1, tmp); + SAYF(bV bSTOP " toilets clogged : " cRST + "%-36s " bSTG bV RESET_G1, + tmp); //} @@ -2010,8 +2058,6 @@ void show_stats_pizza(afl_state_t *afl) { } - - /* Display quick statistics at the end of processing the input directory, plus a bunch of warnings. Some calibration stuff also ended up here, along with several hardcoded constants. Maybe clean up eventually. */ 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