better ui banner
MODIFY
docs/Changelog.md
docs/Changelog.md
@@ -17,6 +17,7 @@ sending a mail to <afl-users+subscribe@googlegroups.com>.
coverage being detected. thanks to Collin May for reporting!
- fix -n dumb mode (nobody should use this)
- fix stability issue with LTO and cmplog
+ - better banner
- frida_mode: David Carlier added Android support :)
- afl-showmap, afl-tmin and afl-analyze now honor persistent mode
for more speed. thanks to dloffre-snl for reporting!

MODIFY
include/afl-fuzz.h
include/afl-fuzz.h
@@ -1130,7 +1130,6 @@ void get_core_count(afl_state_t *);
void fix_up_sync(afl_state_t *);
void check_asan_opts(afl_state_t *);
void check_binary(afl_state_t *, u8 *);
-void fix_up_banner(afl_state_t *, u8 *);
void check_if_tty(afl_state_t *);
void setup_signal_handlers(void);
void save_cmdline(afl_state_t *, u32, char **);

MODIFY
src/afl-fuzz-init.c
src/afl-fuzz-init.c
@@ -2815,43 +2815,6 @@ void check_binary(afl_state_t *afl, u8 *fname) {
}
-/* Trim and possibly create a banner for the run. */
-
-void fix_up_banner(afl_state_t *afl, u8 *name) {
-
- if (!afl->use_banner) {
-
- if (afl->sync_id) {
-
- afl->use_banner = afl->sync_id;
-
- } else {
-
- u8 *trim = strrchr(name, '/');
- if (!trim) {
-
- afl->use_banner = name;
-
- } else {
-
- afl->use_banner = trim + 1;
-
- }
-
- }
-
- }
-
- if (strlen(afl->use_banner) > 32) {
-
- u8 *tmp = ck_alloc(36);
- sprintf(tmp, "%.32s...", afl->use_banner);
- afl->use_banner = tmp;
-
- }
-
-}
-
/* Check if we're on TTY. */
void check_if_tty(afl_state_t *afl) {

MODIFY
src/afl-fuzz-stats.c
src/afl-fuzz-stats.c
@@ -441,6 +441,7 @@ void show_stats(afl_state_t *afl) {
u64 cur_ms;
u32 t_bytes, t_bits;
+ static u8 banner[128];
u32 banner_len, banner_pad;
u8 tmp[256];
u8 time_tmp[64];
@@ -656,26 +657,34 @@ void show_stats(afl_state_t *afl) {
}
/* Let's start by drawing a centered banner. */
+ if (unlikely(!banner[0])) {
- banner_len = (afl->crash_mode ? 24 : 22) + strlen(VERSION) +
- strlen(afl->use_banner) + strlen(afl->power_name) + 3 + 5;
+ 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(tmp, ' ', banner_pad);
+ memset(banner, ' ', banner_pad);
-#ifdef HAVE_AFFINITY
- sprintf(
- tmp + banner_pad,
- "%s " cLCY VERSION cLGN " (%s) " cPIN "[%s]" cBLU " {%d}",
- afl->crash_mode ? cPIN "peruvian were-rabbit" : cYEL "american fuzzy lop",
- afl->use_banner, afl->power_name, afl->cpu_aff);
-#else
- sprintf(
- tmp + banner_pad, "%s " cLCY VERSION cLGN " (%s) " cPIN "[%s]",
- afl->crash_mode ? cPIN "peruvian were-rabbit" : cYEL "american fuzzy lop",
- afl->use_banner, afl->power_name);
-#endif /* HAVE_AFFINITY */
+ sprintf(banner + banner_pad,
+ "%s " cLCY VERSION cLBL " {%s} " cLGN "(%s) " cPIN "[%s]",
+ afl->crash_mode ? cPIN "peruvian were-rabbit"
+ : cYEL "american fuzzy lop",
+ si, afl->use_banner, afl->power_name);
+
+ }
- SAYF("\n%s\n", tmp);
+ SAYF("\n%s\n", banner);
/* "Handy" shortcuts for drawing boxes... */

MODIFY
src/afl-fuzz.c
src/afl-fuzz.c
@@ -1189,7 +1189,17 @@ int main(int argc, char **argv_orig, char **envp) {
}
- if (afl->sync_id) { fix_up_sync(afl); }
+ if (afl->sync_id) {
+
+ if (strlen(afl->sync_id) > 24) {
+
+ FATAL("sync_id max length is 24 characters");
+
+ }
+
+ fix_up_sync(afl);
+
+ }
if (!strcmp(afl->in_dir, afl->out_dir)) {
@@ -1218,6 +1228,8 @@ int main(int argc, char **argv_orig, char **envp) {
if (unlikely(afl->afl_env.afl_statsd)) { statsd_setup_format(afl); }
+ if (!afl->use_banner) { afl->use_banner = argv[optind]; }
+
if (strchr(argv[optind], '/') == NULL && !afl->unicorn_mode) {
WARNF(cLRD
@@ -1486,9 +1498,6 @@ int main(int argc, char **argv_orig, char **envp) {
}
save_cmdline(afl, argc, argv);
-
- fix_up_banner(afl, argv[optind]);
-
check_if_tty(afl);
if (afl->afl_env.afl_force_ui) { afl->not_on_tty = 0; }

better ui banner