From 73f7164048e005aa4a29e49eaf9e05b4fe8215b7 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Mon, 4 May 2020 09:53:59 +0200 Subject: add GNUmakefile --- examples/afl_network_proxy/GNUmakefile | 47 ++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 examples/afl_network_proxy/GNUmakefile (limited to 'examples/afl_network_proxy/GNUmakefile') diff --git a/examples/afl_network_proxy/GNUmakefile b/examples/afl_network_proxy/GNUmakefile new file mode 100644 index 00000000..8eb91727 --- /dev/null +++ b/examples/afl_network_proxy/GNUmakefile @@ -0,0 +1,47 @@ +PREFIX ?= /usr/local +BIN_PATH = $(PREFIX)/bin +DOC_PATH = $(PREFIX)/share/doc/afl + +PROGRAMS = afl-network-client afl-network-server + +HASH=\# + +ifdef STATIC + CFLAGS += -static +endif + +ifdef USE_DEFLATE + CFLAGS += -ldeflate -DUSE_DEFLATE=1 + $(info activating libdeflate-dev for compressing) +endif + +# Disables because compression is slower +# sending 64kb instead of compressing to 112bytes is slower? weird ... +#ifeq "$(shell echo '$(HASH)include @int main() { struct libdeflate_compressor *d = libdeflate_alloc_compressor(1); return 0;}' | tr @ '\n' | $(CC) $(CFLAGS) -x c - -o .test2 -ldeflate 2>/dev/null && echo 1 || echo 0 ; rm -f .test2 )" "1" +# CFLAGS += -ldeflate -DUSE_DEFLATE=1 +# $(info libdeflate-dev was detected, using compressing) +#else +# $(warn did not find libdeflate-dev, cannot use compression) +#endif + +all: $(PROGRAMS) + +help: + @echo make options: + echo STATIC - build as static binaries + echo USE_DEFLATE - build with compression library + +afl-network-client: afl-network-client.c + $(CC) $(CFLAGS) -I../../include -o afl-network-client afl-network-client.c -ldeflate + +afl-network-server: afl-network-server.c + $(CC) $(CFLAGS) -I../../include -o afl-network-server afl-network-server.c ../../src/afl-forkserver.c ../../src/afl-sharedmem.c ../../src/afl-common.c -DBIN_PATH=\"$(BIN_PATH)\" -ldeflate + +clean: + rm -f $(PROGRAMS) *~ core + +install: all + install -d -m 755 $${DESTDIR}$(BIN_PATH) $${DESTDIR}$(DOC_PATH) + install -m 755 $(PROGRAMS) $${DESTDIR}$(BIN_PATH) + install -m 644 README.md $${DESTDIR}$(DOC_PATH)/README.network_proxy.md + -- cgit 1.4.1 From 13a32e9595c09d14f3c5178e7480a3bb3b6c2587 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Mon, 4 May 2020 10:08:29 +0200 Subject: fix makefile --- examples/afl_network_proxy/GNUmakefile | 4 ++-- examples/afl_network_proxy/afl-network-server.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'examples/afl_network_proxy/GNUmakefile') diff --git a/examples/afl_network_proxy/GNUmakefile b/examples/afl_network_proxy/GNUmakefile index 8eb91727..014f4aef 100644 --- a/examples/afl_network_proxy/GNUmakefile +++ b/examples/afl_network_proxy/GNUmakefile @@ -32,10 +32,10 @@ help: echo USE_DEFLATE - build with compression library afl-network-client: afl-network-client.c - $(CC) $(CFLAGS) -I../../include -o afl-network-client afl-network-client.c -ldeflate + $(CC) $(CFLAGS) -I../../include -o afl-network-client afl-network-client.c afl-network-server: afl-network-server.c - $(CC) $(CFLAGS) -I../../include -o afl-network-server afl-network-server.c ../../src/afl-forkserver.c ../../src/afl-sharedmem.c ../../src/afl-common.c -DBIN_PATH=\"$(BIN_PATH)\" -ldeflate + $(CC) $(CFLAGS) -I../../include -o afl-network-server afl-network-server.c ../../src/afl-forkserver.c ../../src/afl-sharedmem.c ../../src/afl-common.c -DBIN_PATH=\"$(BIN_PATH)\" clean: rm -f $(PROGRAMS) *~ core diff --git a/examples/afl_network_proxy/afl-network-server.c b/examples/afl_network_proxy/afl-network-server.c index e4c3bc6d..ffe37447 100644 --- a/examples/afl_network_proxy/afl-network-server.c +++ b/examples/afl_network_proxy/afl-network-server.c @@ -400,7 +400,7 @@ int recv_testcase(int s, void **buf, size_t *max_len) { // fprintf(stderr, "receiving testcase %p %p max %u\n", buf, *buf, *max_len); if (received != size) - FATAL("did not receive testcase data %u != %u, %d", received, size, ret); + FATAL("did not receive testcase data %lu != %u, %d", received, size, ret); // fprintf(stderr, "received testcase\n"); return size; -- cgit 1.4.1 From 96ef2d382159b926adc4a21f644d21ef960041c0 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Mon, 4 May 2020 10:24:29 +0200 Subject: makefile fix --- examples/afl_network_proxy/GNUmakefile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'examples/afl_network_proxy/GNUmakefile') diff --git a/examples/afl_network_proxy/GNUmakefile b/examples/afl_network_proxy/GNUmakefile index 014f4aef..93eee4c1 100644 --- a/examples/afl_network_proxy/GNUmakefile +++ b/examples/afl_network_proxy/GNUmakefile @@ -11,7 +11,8 @@ ifdef STATIC endif ifdef USE_DEFLATE - CFLAGS += -ldeflate -DUSE_DEFLATE=1 + CFLAGS += -DUSE_DEFLATE=1 + LDFLAGS += -ldeflate $(info activating libdeflate-dev for compressing) endif @@ -32,10 +33,10 @@ help: echo USE_DEFLATE - build with compression library afl-network-client: afl-network-client.c - $(CC) $(CFLAGS) -I../../include -o afl-network-client afl-network-client.c + $(CC) $(CFLAGS) -I../../include -o afl-network-client afl-network-client.c $(LDFLAGS) afl-network-server: afl-network-server.c - $(CC) $(CFLAGS) -I../../include -o afl-network-server afl-network-server.c ../../src/afl-forkserver.c ../../src/afl-sharedmem.c ../../src/afl-common.c -DBIN_PATH=\"$(BIN_PATH)\" + $(CC) $(CFLAGS) -I../../include -o afl-network-server afl-network-server.c ../../src/afl-forkserver.c ../../src/afl-sharedmem.c ../../src/afl-common.c -DBIN_PATH=\"$(BIN_PATH)\" $(LDFLAGS) clean: rm -f $(PROGRAMS) *~ core -- cgit 1.4.1 From 945e00b73fde56f98235a03472b4af1539983f80 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Mon, 4 May 2020 12:51:38 +0200 Subject: final touches for afl_network_proxy --- examples/afl_network_proxy/GNUmakefile | 24 ++++++++---------------- examples/afl_network_proxy/README.md | 11 +++++++---- 2 files changed, 15 insertions(+), 20 deletions(-) (limited to 'examples/afl_network_proxy/GNUmakefile') diff --git a/examples/afl_network_proxy/GNUmakefile b/examples/afl_network_proxy/GNUmakefile index 93eee4c1..99221d10 100644 --- a/examples/afl_network_proxy/GNUmakefile +++ b/examples/afl_network_proxy/GNUmakefile @@ -10,27 +10,19 @@ ifdef STATIC CFLAGS += -static endif -ifdef USE_DEFLATE - CFLAGS += -DUSE_DEFLATE=1 - LDFLAGS += -ldeflate - $(info activating libdeflate-dev for compressing) +ifeq "$(shell echo '$(HASH)include @int main() { struct libdeflate_compressor *d = libdeflate_alloc_compressor(1); return 0;}' | tr @ '\n' | $(CC) $(CFLAGS) -x c - -o .test2 -ldeflate 2>/dev/null && echo 1 || echo 0 ; rm -f .test2 )" "1" + CFLAGS += -ldeflate -DUSE_DEFLATE=1 + $(info libdeflate-dev was detected, using compressing) +else + $(warn did not find libdeflate-dev, cannot use compression) endif -# Disables because compression is slower -# sending 64kb instead of compressing to 112bytes is slower? weird ... -#ifeq "$(shell echo '$(HASH)include @int main() { struct libdeflate_compressor *d = libdeflate_alloc_compressor(1); return 0;}' | tr @ '\n' | $(CC) $(CFLAGS) -x c - -o .test2 -ldeflate 2>/dev/null && echo 1 || echo 0 ; rm -f .test2 )" "1" -# CFLAGS += -ldeflate -DUSE_DEFLATE=1 -# $(info libdeflate-dev was detected, using compressing) -#else -# $(warn did not find libdeflate-dev, cannot use compression) -#endif - all: $(PROGRAMS) help: @echo make options: - echo STATIC - build as static binaries - echo USE_DEFLATE - build with compression library + @echo STATIC - build as static binaries + @echo COMPRESS_TESTCASES - compress test cases afl-network-client: afl-network-client.c $(CC) $(CFLAGS) -I../../include -o afl-network-client afl-network-client.c $(LDFLAGS) @@ -44,5 +36,5 @@ clean: install: all install -d -m 755 $${DESTDIR}$(BIN_PATH) $${DESTDIR}$(DOC_PATH) install -m 755 $(PROGRAMS) $${DESTDIR}$(BIN_PATH) - install -m 644 README.md $${DESTDIR}$(DOC_PATH)/README.network_proxy.md + install -T -m 644 README.md $${DESTDIR}$(DOC_PATH)/README.network_proxy.md diff --git a/examples/afl_network_proxy/README.md b/examples/afl_network_proxy/README.md index 84ebfa48..255be0d8 100644 --- a/examples/afl_network_proxy/README.md +++ b/examples/afl_network_proxy/README.md @@ -16,9 +16,12 @@ Note that the impact on fuzzing speed will be huge, expect a loss of 90%. Just type `make` and let the autodetection do everything for you. -Note that compression is supported but currently disabled. It seems that -sending 64kb of map data over TCP is faster than compressing it with the -fastest algorithm and options to 112 byte and sending this. Weird. +Note that you will get a 40-50% performance increase if you have libdeflate-dev +installed. The GNUmakefile will autodetect it if present. + +If your target has large test cases (10+kb) that are ascii only or large chunks +of zero blocks then set `CFLAGS=-DCOMPRESS_TESTCASES=1` to compress them. +For most targets this hurts performance though so it is disabled by default. ### on the target @@ -29,7 +32,7 @@ e.g.: $ afl-network-server -i 1111 -m 25M -t 1000 -- /bin/target -f @@ ``` -### on the fuzzing master +### on the (afl-fuzz) master Just run afl-fuzz with your normal options, however the target should be `afl-network-client` with the IP and PORT of the `afl-network-server` and -- cgit 1.4.1 From ad3960580d4b462e53c98f82283cd11037558642 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Tue, 5 May 2020 20:19:04 +0200 Subject: fixed typos --- docs/Changelog.md | 4 ++-- docs/env_variables.md | 7 ++++--- examples/afl_network_proxy/GNUmakefile | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) (limited to 'examples/afl_network_proxy/GNUmakefile') diff --git a/docs/Changelog.md b/docs/Changelog.md index e4ac8783..54564a5d 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -22,9 +22,9 @@ sending a mail to . - fixes to LTO mode if instrumented edges > MAP_SIZE - CTX and NGRAM can now be used together - CTX and NGRAM are now also supported in CFG/INSTRIM mode - - AFL_LLVM_LAF_TRANSFORM_COMPARES could, fixed + - AFL_LLVM_LAF_TRANSFORM_COMPARES could crash, fixed - added AFL_LLVM_SKIP_NEVERZERO to skip the never zero coverage counter - implmentation. For targets with little or no loops or heavy called + implementation. For targets with few or no loops or heavily called functions. Gives a small performance boost. - qemu_mode: - add information on PIE/PIC load addresses for 32 bit diff --git a/docs/env_variables.md b/docs/env_variables.md index ab5808ec..ed81c8a3 100644 --- a/docs/env_variables.md +++ b/docs/env_variables.md @@ -102,9 +102,10 @@ Then there are a few specific features that are only available in llvm_mode: LTO - LTO instrumentation (see below) CTX - context sensitive instrumentation (see below) NGRAM-x - deeper previous location coverage (from NGRAM-2 up to NGRAM-16) - In CLASSIC (default) can can also specify CTX and/nor NGRAM, seperate - the options with a comma "," then, e.g.: - AFL_LLVM_INSTRUMENT=CLASSIC,CTX,NGRAM-4 + In CLASSIC (default) and CFG/INSTRIM you can also specify CTX and/or + NGRAM, seperate the options with a comma "," then, e.g.: + AFL_LLVM_INSTRUMENT=CFG,CTX,NGRAM-4 + Not that this is a good idea to use both CTX and NGRAM :) ### LTO diff --git a/examples/afl_network_proxy/GNUmakefile b/examples/afl_network_proxy/GNUmakefile index 99221d10..eafc5249 100644 --- a/examples/afl_network_proxy/GNUmakefile +++ b/examples/afl_network_proxy/GNUmakefile @@ -12,7 +12,7 @@ endif ifeq "$(shell echo '$(HASH)include @int main() { struct libdeflate_compressor *d = libdeflate_alloc_compressor(1); return 0;}' | tr @ '\n' | $(CC) $(CFLAGS) -x c - -o .test2 -ldeflate 2>/dev/null && echo 1 || echo 0 ; rm -f .test2 )" "1" CFLAGS += -ldeflate -DUSE_DEFLATE=1 - $(info libdeflate-dev was detected, using compressing) + $(info libdeflate-dev was detected, using compression) else $(warn did not find libdeflate-dev, cannot use compression) endif -- cgit 1.4.1 From 0e5027d8d82526ee30f23efdc77abd2876cda1d0 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Tue, 5 May 2020 21:46:31 +0200 Subject: maybe_grow->ck_maybe_grow --- examples/afl_network_proxy/GNUmakefile | 3 ++- examples/afl_network_proxy/afl-network-server.c | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'examples/afl_network_proxy/GNUmakefile') diff --git a/examples/afl_network_proxy/GNUmakefile b/examples/afl_network_proxy/GNUmakefile index eafc5249..cf1cbad5 100644 --- a/examples/afl_network_proxy/GNUmakefile +++ b/examples/afl_network_proxy/GNUmakefile @@ -11,7 +11,8 @@ ifdef STATIC endif ifeq "$(shell echo '$(HASH)include @int main() { struct libdeflate_compressor *d = libdeflate_alloc_compressor(1); return 0;}' | tr @ '\n' | $(CC) $(CFLAGS) -x c - -o .test2 -ldeflate 2>/dev/null && echo 1 || echo 0 ; rm -f .test2 )" "1" - CFLAGS += -ldeflate -DUSE_DEFLATE=1 + CFLAGS += -DUSE_DEFLATE=1 + LDFLAGS += -ldeflate $(info libdeflate-dev was detected, using compression) else $(warn did not find libdeflate-dev, cannot use compression) diff --git a/examples/afl_network_proxy/afl-network-server.c b/examples/afl_network_proxy/afl-network-server.c index 01501cc9..2de91cbd 100644 --- a/examples/afl_network_proxy/afl-network-server.c +++ b/examples/afl_network_proxy/afl-network-server.c @@ -356,7 +356,7 @@ int recv_testcase(int s, void **buf, size_t *max_len) { if ((size & 0xff000000) != 0xff000000) { - *buf = maybe_grow(buf, max_len, size); + *buf = ck_maybe_grow(buf, max_len, size); received = 0; // fprintf(stderr, "unCOMPRESS (%u)\n", size); while (received < size && @@ -368,7 +368,7 @@ int recv_testcase(int s, void **buf, size_t *max_len) { #ifdef USE_DEFLATE u32 clen; size -= 0xff000000; - *buf = maybe_grow(buf, max_len, size); + *buf = ck_maybe_grow(buf, max_len, size); received = 0; while (received < 4 && (ret = recv(s, &clen + received, 4 - received, 0)) > 0) @@ -377,7 +377,7 @@ int recv_testcase(int s, void **buf, size_t *max_len) { // fprintf(stderr, "received clen information of %d\n", clen); if (clen < 1) FATAL("did not receive valid compressed len information: %u", clen); - buf2 = maybe_grow((void **)&buf2, &buf2_len, clen); + buf2 = ck_maybe_grow((void **)&buf2, &buf2_len, clen); received = 0; while (received < clen && (ret = recv(s, buf2 + received, clen - received, 0)) > 0) @@ -566,7 +566,7 @@ int main(int argc, char **argv_orig, char **envp) { sharedmem_t shm = {0}; fsrv->trace_bits = afl_shm_init(&shm, map_size, 0); - in_data = maybe_grow((void **)&in_data, &max_len, 65536); + in_data = ck_maybe_grow((void **)&in_data, &max_len, 65536); atexit(at_exit_handler); setup_signal_handlers(); @@ -637,7 +637,7 @@ int main(int argc, char **argv_orig, char **envp) { #ifdef USE_DEFLATE compressor = libdeflate_alloc_compressor(1); decompressor = libdeflate_alloc_decompressor(); - buf2 = maybe_grow((void **)&buf2, &buf2_len, map_size + 16); + buf2 = ck_maybe_grow((void **)&buf2, &buf2_len, map_size + 16); lenptr = (u32 *)(buf2 + 4); fprintf(stderr, "Compiled with compression support\n"); #endif -- cgit 1.4.1