From 0b6e74eeb099ac045932e5d3603af899268b48d0 Mon Sep 17 00:00:00 2001 From: Thomas Rooijakkers Date: Wed, 13 Sep 2023 15:49:04 +0200 Subject: [PATCH 1/9] Add support for UTF-8 line rendering --- GNUmakefile | 5 +++ docs/INSTALL.md | 1 + include/debug.h | 81 +++++++++++++++++++++++++++++++------------------ 3 files changed, 57 insertions(+), 30 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 88816e85..4a234c51 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -45,6 +45,10 @@ ifdef NO_SPLICING override CFLAGS_OPT += -DNO_SPLICING endif +ifdef UTF + override CFLAGS_OPT += -DFANCY_BOXES_UTF +endif + ifdef ASAN_BUILD $(info Compiling ASAN version of binaries) override CFLAGS += $(ASAN_CFLAGS) @@ -391,6 +395,7 @@ help: @echo INTROSPECTION - compile afl-fuzz with mutation introspection @echo NO_PYTHON - disable python support @echo NO_SPLICING - disables splicing mutation in afl-fuzz, not recommended for normal fuzzing + @echo UTF - use UTF-8 for line rendering in status screen @echo NO_NYX - disable building nyx mode dependencies @echo "NO_CORESIGHT - disable building coresight (arm64 only)" @echo NO_UNICORN_ARM64 - disable building unicorn on arm64 diff --git a/docs/INSTALL.md b/docs/INSTALL.md index 9005a7eb..7c04d7d8 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -87,6 +87,7 @@ These build options exist: * INTROSPECTION - compile afl-fuzz with mutation introspection * NO_PYTHON - disable python support * NO_SPLICING - disables splicing mutation in afl-fuzz, not recommended for normal fuzzing +* UTF - use UTF-8 for line rendering in status screen * NO_NYX - disable building nyx mode dependencies * NO_CORESIGHT - disable building coresight (arm64 only) * NO_UNICORN_ARM64 - disable building unicorn on arm64 diff --git a/include/debug.h b/include/debug.h index cd621a72..a9179329 100644 --- a/include/debug.h +++ b/include/debug.h @@ -116,42 +116,63 @@ * Box drawing sequences * *************************/ -#ifdef FANCY_BOXES - - #define SET_G1 "\x1b)0" /* Set G1 for box drawing */ - #define RESET_G1 "\x1b)B" /* Reset G1 to ASCII */ - #define bSTART "\x0e" /* Enter G1 drawing mode */ - #define bSTOP "\x0f" /* Leave G1 drawing mode */ - #define bH "q" /* Horizontal line */ - #define bV "x" /* Vertical line */ - #define bLT "l" /* Left top corner */ - #define bRT "k" /* Right top corner */ - #define bLB "m" /* Left bottom corner */ - #define bRB "j" /* Right bottom corner */ - #define bX "n" /* Cross */ - #define bVR "t" /* Vertical, branch right */ - #define bVL "u" /* Vertical, branch left */ - #define bHT "v" /* Horizontal, branch top */ - #define bHB "w" /* Horizontal, branch bottom */ - -#else +#ifdef FANCY_BOXES_UTF #define SET_G1 "" #define RESET_G1 "" #define bSTART "" #define bSTOP "" - #define bH "-" - #define bV "|" - #define bLT "+" - #define bRT "+" - #define bLB "+" - #define bRB "+" - #define bX "+" - #define bVR "+" - #define bVL "+" - #define bHT "+" - #define bHB "+" + #define bH "\u2500" /* Horizontal line */ + #define bV "\u2502" /* Vertical line */ + #define bLT "\u250c" /* Left top corner */ + #define bRT "\u2510" /* Right top corner */ + #define bLB "\u2514" /* Left bottom corner */ + #define bRB "\u2518" /* Right bottom corner */ + #define bX "\u253c" /* Cross */ + #define bVR "\u251c" /* Vertical, branch right */ + #define bVL "\u2524" /* Vertical, branch left */ + #define bHT "\u2534" /* Horizontal, branch top */ + #define bHB "\u252c" /* Horizontal, branch bottom */ +#else + + #ifdef FANCY_BOXES + + #define SET_G1 "\x1b)0" /* Set G1 for box drawing */ + #define RESET_G1 "\x1b)B" /* Reset G1 to ASCII */ + #define bSTART "\x0e" /* Enter G1 drawing mode */ + #define bSTOP "\x0f" /* Leave G1 drawing mode */ + #define bH "q" /* Horizontal line */ + #define bV "x" /* Vertical line */ + #define bLT "l" /* Left top corner */ + #define bRT "k" /* Right top corner */ + #define bLB "m" /* Left bottom corner */ + #define bRB "j" /* Right bottom corner */ + #define bX "n" /* Cross */ + #define bVR "t" /* Vertical, branch right */ + #define bVL "u" /* Vertical, branch left */ + #define bHT "v" /* Horizontal, branch top */ + #define bHB "w" /* Horizontal, branch bottom */ + + #else + + #define SET_G1 "" + #define RESET_G1 "" + #define bSTART "" + #define bSTOP "" + #define bH "-" + #define bV "|" + #define bLT "+" + #define bRT "+" + #define bLB "+" + #define bRB "+" + #define bX "+" + #define bVR "+" + #define bVL "+" + #define bHT "+" + #define bHB "+" + + #endif #endif /* ^FANCY_BOXES */ /*********************** From 54f01481571ba3a7c05a5e37b9f5021c1304834e Mon Sep 17 00:00:00 2001 From: Thomas Rooijakkers Date: Tue, 19 Sep 2023 13:31:29 +0200 Subject: [PATCH 2/9] UTF-8 line rendering for status screen as default --- GNUmakefile | 6 ++--- docs/INSTALL.md | 2 +- include/debug.h | 62 ++++++++++++++++++++++++------------------------- 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 4a234c51..fadf20bd 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -45,8 +45,8 @@ ifdef NO_SPLICING override CFLAGS_OPT += -DNO_SPLICING endif -ifdef UTF - override CFLAGS_OPT += -DFANCY_BOXES_UTF +ifdef NO_UTF + override CFLAGS_OPT += -DFANCY_BOXES_NO_UTF endif ifdef ASAN_BUILD @@ -395,7 +395,7 @@ help: @echo INTROSPECTION - compile afl-fuzz with mutation introspection @echo NO_PYTHON - disable python support @echo NO_SPLICING - disables splicing mutation in afl-fuzz, not recommended for normal fuzzing - @echo UTF - use UTF-8 for line rendering in status screen + @echo NO_UTF - do not use UTF-8 for line rendering in status screen (fallback to G1 box drawing, of vanilla AFL) @echo NO_NYX - disable building nyx mode dependencies @echo "NO_CORESIGHT - disable building coresight (arm64 only)" @echo NO_UNICORN_ARM64 - disable building unicorn on arm64 diff --git a/docs/INSTALL.md b/docs/INSTALL.md index 7c04d7d8..41f512ed 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -87,7 +87,7 @@ These build options exist: * INTROSPECTION - compile afl-fuzz with mutation introspection * NO_PYTHON - disable python support * NO_SPLICING - disables splicing mutation in afl-fuzz, not recommended for normal fuzzing -* UTF - use UTF-8 for line rendering in status screen +* NO_UTF - do not use UTF-8 for line rendering in status screen (fallback to G1 box drawing, of vanilla AFL) * NO_NYX - disable building nyx mode dependencies * NO_CORESIGHT - disable building coresight (arm64 only) * NO_UNICORN_ARM64 - disable building unicorn on arm64 diff --git a/include/debug.h b/include/debug.h index a9179329..234d8fc4 100644 --- a/include/debug.h +++ b/include/debug.h @@ -116,43 +116,43 @@ * Box drawing sequences * *************************/ -#ifdef FANCY_BOXES_UTF +#ifdef FANCY_BOXES_NO_UTF - #define SET_G1 "" - #define RESET_G1 "" - #define bSTART "" - #define bSTOP "" - #define bH "\u2500" /* Horizontal line */ - #define bV "\u2502" /* Vertical line */ - #define bLT "\u250c" /* Left top corner */ - #define bRT "\u2510" /* Right top corner */ - #define bLB "\u2514" /* Left bottom corner */ - #define bRB "\u2518" /* Right bottom corner */ - #define bX "\u253c" /* Cross */ - #define bVR "\u251c" /* Vertical, branch right */ - #define bVL "\u2524" /* Vertical, branch left */ - #define bHT "\u2534" /* Horizontal, branch top */ - #define bHB "\u252c" /* Horizontal, branch bottom */ + #define SET_G1 "\x1b)0" /* Set G1 for box drawing */ + #define RESET_G1 "\x1b)B" /* Reset G1 to ASCII */ + #define bSTART "\x0e" /* Enter G1 drawing mode */ + #define bSTOP "\x0f" /* Leave G1 drawing mode */ + #define bH "q" /* Horizontal line */ + #define bV "x" /* Vertical line */ + #define bLT "l" /* Left top corner */ + #define bRT "k" /* Right top corner */ + #define bLB "m" /* Left bottom corner */ + #define bRB "j" /* Right bottom corner */ + #define bX "n" /* Cross */ + #define bVR "t" /* Vertical, branch right */ + #define bVL "u" /* Vertical, branch left */ + #define bHT "v" /* Horizontal, branch top */ + #define bHB "w" /* Horizontal, branch bottom */ #else #ifdef FANCY_BOXES - #define SET_G1 "\x1b)0" /* Set G1 for box drawing */ - #define RESET_G1 "\x1b)B" /* Reset G1 to ASCII */ - #define bSTART "\x0e" /* Enter G1 drawing mode */ - #define bSTOP "\x0f" /* Leave G1 drawing mode */ - #define bH "q" /* Horizontal line */ - #define bV "x" /* Vertical line */ - #define bLT "l" /* Left top corner */ - #define bRT "k" /* Right top corner */ - #define bLB "m" /* Left bottom corner */ - #define bRB "j" /* Right bottom corner */ - #define bX "n" /* Cross */ - #define bVR "t" /* Vertical, branch right */ - #define bVL "u" /* Vertical, branch left */ - #define bHT "v" /* Horizontal, branch top */ - #define bHB "w" /* Horizontal, branch bottom */ + #define SET_G1 "" + #define RESET_G1 "" + #define bSTART "" + #define bSTOP "" + #define bH "\u2500" /* Horizontal line */ + #define bV "\u2502" /* Vertical line */ + #define bLT "\u250c" /* Left top corner */ + #define bRT "\u2510" /* Right top corner */ + #define bLB "\u2514" /* Left bottom corner */ + #define bRB "\u2518" /* Right bottom corner */ + #define bX "\u253c" /* Cross */ + #define bVR "\u251c" /* Vertical, branch right */ + #define bVL "\u2524" /* Vertical, branch left */ + #define bHT "\u2534" /* Horizontal, branch top */ + #define bHB "\u252c" /* Horizontal, branch bottom */ #else From 6dc054be0faa2fe934ec24465f75fb8676798d13 Mon Sep 17 00:00:00 2001 From: Thomas Rooijakkers Date: Tue, 19 Sep 2023 13:42:53 +0200 Subject: [PATCH 3/9] Add usage compilation status print for NO_UTF --- src/afl-fuzz.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c index cf57702f..9aaec2c7 100644 --- a/src/afl-fuzz.c +++ b/src/afl-fuzz.c @@ -381,6 +381,12 @@ static void usage(u8 *argv0, int more_help) { SAYF("Compiled with NO_SPLICING.\n"); #endif +#ifdef NO_UTF + SAYF("Compiled without UTF-8 support for line rendering in status screen.\n"); +#else + SAYF("Compiled with UTF-8 support for line rendering in status screen.\n"); +#endif + #ifdef PROFILING SAYF("Compiled with PROFILING.\n"); #endif From abbdf1c3ac61322e9fd55a78fbb3ad60c6e68971 Mon Sep 17 00:00:00 2001 From: Thomas Rooijakkers Date: Tue, 19 Sep 2023 13:52:36 +0200 Subject: [PATCH 4/9] Use proper ifdef, remove else in line with other compile options --- src/afl-fuzz.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c index 9aaec2c7..86c05223 100644 --- a/src/afl-fuzz.c +++ b/src/afl-fuzz.c @@ -381,10 +381,8 @@ static void usage(u8 *argv0, int more_help) { SAYF("Compiled with NO_SPLICING.\n"); #endif -#ifdef NO_UTF +#ifdef FANCY_BOXES_NO_UTF SAYF("Compiled without UTF-8 support for line rendering in status screen.\n"); -#else - SAYF("Compiled with UTF-8 support for line rendering in status screen.\n"); #endif #ifdef PROFILING From a6b7da880852ab33e54c4c0eb55570eb5ee4aede Mon Sep 17 00:00:00 2001 From: Thomas Rooijakkers Date: Wed, 20 Sep 2023 09:41:49 +0200 Subject: [PATCH 5/9] Remove Android specifics --- include/config.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/config.h b/include/config.h index 6a75737f..988e536e 100644 --- a/include/config.h +++ b/include/config.h @@ -120,9 +120,9 @@ // #define _WANT_ORIGINAL_AFL_ALLOC -/* Comment out to disable fancy ANSI boxes and use poor man's 7-bit UI: */ +/* Comment out to disable fancy boxes and use poor man's 7-bit UI: */ -#ifndef ANDROID_DISABLE_FANCY // Fancy boxes are ugly from adb +#ifndef DISABLE_FANCY #define FANCY_BOXES #endif From 762fe0aad860c0c0fa3c9e19103c3df799498c72 Mon Sep 17 00:00:00 2001 From: Thomas Rooijakkers Date: Wed, 20 Sep 2023 11:00:17 +0200 Subject: [PATCH 6/9] forgot removal of compiler flag --- utils/qbdi_mode/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/qbdi_mode/build.sh b/utils/qbdi_mode/build.sh index 29fe0ee4..a92d81bd 100755 --- a/utils/qbdi_mode/build.sh +++ b/utils/qbdi_mode/build.sh @@ -52,6 +52,6 @@ ${compiler_prefix}${CC} -shared -o libdemo.so demo-so.c -w -g echo "[+] Building afl-fuzz for Android" # build afl-fuzz cd ../.. -${compiler_prefix}${CC} -DANDROID_DISABLE_FANCY=1 -O3 -funroll-loops -Wall -D_FORTIFY_SOURCE=2 -g -Wno-pointer-sign -I include/ -DAFL_PATH=\"/usr/local/lib/afl\" -DBIN_PATH=\"/usr/local/bin\" -DDOC_PATH=\"/usr/local/share/doc/afl\" -Wno-unused-function src/afl-fuzz*.c src/afl-common.c src/afl-sharedmem.c src/afl-forkserver.c src/afl-performance.c -o utils/qbdi_mode/afl-fuzz -ldl -lm -w +${compiler_prefix}${CC} -O3 -funroll-loops -Wall -D_FORTIFY_SOURCE=2 -g -Wno-pointer-sign -I include/ -DAFL_PATH=\"/usr/local/lib/afl\" -DBIN_PATH=\"/usr/local/bin\" -DDOC_PATH=\"/usr/local/share/doc/afl\" -Wno-unused-function src/afl-fuzz*.c src/afl-common.c src/afl-sharedmem.c src/afl-forkserver.c src/afl-performance.c -o utils/qbdi_mode/afl-fuzz -ldl -lm -w echo "[+] All done. Enjoy!" From c762b6a3054b1a264101b66641681de974e4c806 Mon Sep 17 00:00:00 2001 From: vanhauser-thc Date: Fri, 22 Sep 2023 07:06:18 +0200 Subject: [PATCH 7/9] fix afl-persistent-config for Debian --- afl-persistent-config | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/afl-persistent-config b/afl-persistent-config index 6d96c196..3abcb866 100755 --- a/afl-persistent-config +++ b/afl-persistent-config @@ -98,9 +98,9 @@ if [[ "$PLATFORM" = "Linux" ]] ; then echo "Checks passed." test -d /etc/sysctl.d || echo Error: /etc/sysctl.d directory not found, cannot install shmem config - test -d /etc/sysctl.d -a '!' -e /etc/sysctl.d/99-fuzzing && { - echo "Installing /etc/sysctl.d/99-fuzzing" - cat << EOF > /etc/sysctl.d/99-fuzzing + test -d /etc/sysctl.d -a '!' -e /etc/sysctl.d/99-fuzzing.conf && { + echo "Installing /etc/sysctl.d/99-fuzzing.conf" + cat << EOF > /etc/sysctl.d/99-fuzzing.conf kernel.core_uses_pid=0 kernel.core_pattern=core kernel.randomize_va_space=0 From bd90283d0f1f0888ec2673e7b19bd6689ba8f4a6 Mon Sep 17 00:00:00 2001 From: vanhauser-thc Date: Fri, 22 Sep 2023 07:17:23 +0200 Subject: [PATCH 8/9] update todo --- TODO.md | 1 + 1 file changed, 1 insertion(+) diff --git a/TODO.md b/TODO.md index eb934e3f..ac24fe07 100644 --- a/TODO.md +++ b/TODO.md @@ -4,6 +4,7 @@ - afl-showmap -f support - afl-fuzz multicore wrapper script + - add value_profile but only enable after 15 minutes without finds - afl-crash-analysis - support persistent and deferred fork server in afl-showmap? - better autodetection of shifting runtime timeout values From 5f7c3a1ee0d6f20e42a207a7e75e0f19e726a0f5 Mon Sep 17 00:00:00 2001 From: vanhauser-thc Date: Wed, 27 Sep 2023 16:32:55 +0200 Subject: [PATCH 9/9] fix afl-cc help output --- src/afl-cc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/afl-cc.c b/src/afl-cc.c index 12707007..037a5c30 100644 --- a/src/afl-cc.c +++ b/src/afl-cc.c @@ -2118,6 +2118,8 @@ int main(int argc, char **argv, char **envp) { " [LLVM] LLVM: %s%s\n" " PCGUARD %s yes yes module yes yes " "yes\n" + " NATIVE AVAILABLE no yes no no " + "part. yes\n" " CLASSIC %s no yes module yes yes " "yes\n" " - NORMAL\n" @@ -2137,10 +2139,10 @@ int main(int argc, char **argv, char **envp) { "no\n\n", have_llvm ? "AVAILABLE" : "unavailable!", compiler_mode == LLVM ? " [SELECTED]" : "", + have_llvm ? "AVAILABLE" : "unavailable!", + have_llvm ? "AVAILABLE" : "unavailable!", have_lto ? "AVAILABLE" : "unavailable!", compiler_mode == LTO ? " [SELECTED]" : "", - LLVM_MAJOR >= 7 ? "DEFAULT" : " ", - LLVM_MAJOR >= 7 ? " " : "DEFAULT", have_gcc_plugin ? "AVAILABLE" : "unavailable!", compiler_mode == GCC_PLUGIN ? " [SELECTED]" : "", have_gcc ? "AVAILABLE" : "unavailable!",