diff options
author | Andrea Fioraldi <andreafioraldi@gmail.com> | 2020-02-03 12:46:01 +0100 |
---|---|---|
committer | Andrea Fioraldi <andreafioraldi@gmail.com> | 2020-02-03 12:46:01 +0100 |
commit | 63fe2977dab3b4fadd919b75e2fb1eb36aa48f20 (patch) | |
tree | fdcc3d44da89207a8def5b250604cb8edae0f8f5 | |
parent | de2771d1266c14e90eeeed581847eb1f1f63c6cf (diff) | |
parent | 37bdda0464fd14a8cd8a0fbdf68a55c8440b1017 (diff) | |
download | afl++-63fe2977dab3b4fadd919b75e2fb1eb36aa48f20.tar.gz |
Merge branch 'master' of github.com:vanhauser-thc/AFLplusplus
-rw-r--r-- | Makefile | 58 | ||||
-rw-r--r-- | docs/ideas.md | 4 | ||||
-rw-r--r-- | docs/python_mutators.txt | 19 | ||||
-rw-r--r-- | src/afl-fuzz.c | 2 | ||||
-rwxr-xr-x | test/test.sh | 6 |
5 files changed, 36 insertions, 53 deletions
diff --git a/Makefile b/Makefile index 459cae5f..dd6c19aa 100644 --- a/Makefile +++ b/Makefile @@ -63,42 +63,20 @@ CFLAGS += -Wall -g -Wno-pointer-sign -I include/ \ AFL_FUZZ_FILES = $(wildcard src/afl-fuzz*.c) -ifneq "$(filter %3.7m, $(shell python3.7m-config --includes 2>/dev/null))" "" - PYTHON_INCLUDE ?= $(shell python3.7m-config --includes) - PYTHON_LIB ?= $(shell python3.7m-config --ldflags) - PYTHON_VERSION = 3.7m -else - ifneq "$(filter %3.7, $(shell python3.7-config --includes 2>/dev/null))" "" - PYTHON_INCLUDE ?= $(shell python3.7-config --includes) - PYTHON_LIB ?= $(shell python3.7-config --ldflags) - PYTHON_VERSION = 3.7 - else - ifneq "$(filter %2.7, $(shell python2.7-config --includes 2>/dev/null))" "" - PYTHON_INCLUDE ?= $(shell python2.7-config --includes) - PYTHON_LIB ?= $(shell python2.7-config --ldflags) - PYTHON_VERSION = 2.7 - endif +ifneq "$(shell which python3)" "" + ifneq "$(shell which python3-config)" "" + PYTHON_INCLUDE ?= $(shell python3-config --includes) + PYTHON_LIB ?= $(shell python3-config --ldflags) + PYTHON_VERSION ?= $(strip $(shell python3 --version 2>&1)) endif endif -PYTHON_INCLUDE ?= $(shell test -e /usr/include/python3.7m && echo /usr/include/python3.7m) -PYTHON_INCLUDE ?= $(shell test -e /usr/include/python3.7 && echo /usr/include/python3.7) -PYTHON_INCLUDE ?= $(shell test -e /usr/include/python2.7 && echo /usr/include/python2.7) - -ifneq "$(filter %3.7m, $(PYTHON_INCLUDE))" "" - PYTHON_VERSION ?= 3.7m - PYTHON_LIB ?= -lpython3.7m -else - ifneq "$(filter %3.7, $(PYTHON_INCLUDE))" "" - PYTHON_VERSION ?= 3.7 - else - ifneq "$(filter %2.7, $(PYTHON_INCLUDE))" "" - PYTHON_VERSION ?= 2.7 - PYTHON_LIB ?= -lpython2.7 - else - PYTHON_VERSION ?= none - endif - endif +ifneq "$(shell which python)" "" + ifneq "$(shell which python-config)" "" + PYTHON_INCLUDE ?= $(shell python-config --includes) + PYTHON_LIB ?= $(shell python-config --ldflags) + PYTHON_VERSION ?= $(strip $(shell python --version 2>&1)) + endif endif ifdef SOURCE_DATE_EPOCH @@ -128,9 +106,9 @@ endif COMM_HDR = include/alloc-inl.h include/config.h include/debug.h include/types.h -ifeq "$(shell echo '\#include <Python.h>@int main() {return 0; }' | tr @ '\n' | $(CC) -x c - -o .test -I$(PYTHON_INCLUDE) $(LDFLAGS) $(PYTHON_LIB) 2>/dev/null && echo 1 || echo 0 ; rm -f .test )" "1" +ifeq "$(shell echo '\#include <Python.h>@int main() {return 0; }' | tr @ '\n' | $(CC) -x c - -o .test $(PYTHON_INCLUDE) $(LDFLAGS) $(PYTHON_LIB) 2>/dev/null && echo 1 || echo 0 ; rm -f .test )" "1" PYTHON_OK=1 - PYFLAGS=-DUSE_PYTHON -I$(PYTHON_INCLUDE) $(LDFLAGS) $(PYTHON_LIB) -DPYTHON_VERSION=\"$(PYTHON_VERSION)\" + PYFLAGS=-DUSE_PYTHON $(PYTHON_INCLUDE) $(LDFLAGS) $(PYTHON_LIB) -DPYTHON_VERSION="\"$(PYTHON_VERSION)\"" else PYTHON_OK=0 PYFLAGS= @@ -161,7 +139,7 @@ ifeq "$(TEST_MMAP)" "1" endif -all: test_x86 test_shm test_python27 ready $(PROGS) afl-as test_build all_done +all: test_x86 test_shm test_python ready $(PROGS) afl-as test_build all_done man: $(MANPAGES) -$(MAKE) -C llvm_mode @@ -229,14 +207,14 @@ endif ifeq "$(PYTHON_OK)" "1" -test_python27: +test_python: @rm -f .test 2> /dev/null - @echo "[+] Python $(PYTHON_VERSION) support seems to be working." + @echo "[+] $(PYTHON_VERSION) support seems to be working." else -test_python27: - @echo "[-] You seem to need to install the package python3.7-dev or python2.7-dev (and perhaps python[23]-apt), but it is optional so we continue" +test_python: + @echo "[-] You seem to need to install the package python3-dev or python2-dev (and perhaps python[23]-apt), but it is optional so we continue" endif diff --git a/docs/ideas.md b/docs/ideas.md new file mode 100644 index 00000000..568b49ce --- /dev/null +++ b/docs/ideas.md @@ -0,0 +1,4 @@ +# Ideas for afl++ + +* flexible Grammar mutator +* LTO based non-colliding edge coverage diff --git a/docs/python_mutators.txt b/docs/python_mutators.txt index 0caa2161..7fd54547 100644 --- a/docs/python_mutators.txt +++ b/docs/python_mutators.txt @@ -9,9 +9,10 @@ Adding custom mutators to AFL using Python modules Implemented by Christian Holler (:decoder) <choller@mozilla.com>. - NOTE: Python 3.7 and 2.7 are supported so far (3.8 upcomming). - Depending on with which version afl-fuzz was compiled, you must use + NOTE: Only cPython 2.7, 3.7 and above are supported, although others may work. + Depending on with which version afl-fuzz was compiled against, you must use python2 or python3 syntax in your scripts! + After a major version upgrade (e.g. 3.7 -> 3.8), a recompilation of afl-fuzz may be needed. For an example and a template see ../python_mutators/ @@ -57,23 +58,21 @@ further information about this feature. 3) How to compile AFLFuzz with Python support --------------------------------------------- -You must install the python 3.7 or 2.7 development package of your Linux +You must install the python 3 or 2 development package of your Linux distribution before this will work. On Debian/Ubuntu/Kali this can be done with either: - apt install python3.7-dev + apt install python3-dev or - apt install python2.7-dev + apt install python-dev Note that for some distributions you might also need the package python[23]-apt A prerequisite for using this mode is to compile AFLFuzz with Python support. -The afl Makefile performs some magic and detects Python 3.7 and 2.7 if it is -in the default path and compiles afl-fuzz with the feature if available (which -is /usr/include/python2.7 for the Python.h include and -/usr/lib/x86_64-linux-gnu for the libpython2.7.a library) +The AFL++ Makefile detects Python 3 and 2 through `python-config` if is is in the PATH +and compiles afl-fuzz with the feature if available. In case your setup is different set the necessary variables like this: -PYTHON_INCLUDE=/path/to/python2.7/include LDFLAGS=-L/path/to/python2.7/lib make +PYTHON_INCLUDE=/path/to/python/include LDFLAGS=-L/path/to/python/lib make 4) How to run AFLFuzz with your custom module diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c index 39e737c2..eae4ba1f 100644 --- a/src/afl-fuzz.c +++ b/src/afl-fuzz.c @@ -145,7 +145,7 @@ static void usage(u8* argv0) { argv0, EXEC_TIMEOUT, MEM_LIMIT); #ifdef USE_PYTHON - SAYF("Compiled with Python %s module support, see docs/python_mutators.txt\n", + SAYF("Compiled with %s module support, see docs/python_mutators.txt\n", (char*)PYTHON_VERSION); #endif diff --git a/test/test.sh b/test/test.sh index 507685db..20e02a83 100755 --- a/test/test.sh +++ b/test/test.sh @@ -519,7 +519,7 @@ test -e ../libradamsa.so && { $ECHO "$BLUE[*] Testing: qemu_mode" test -e ../afl-qemu-trace && { - gcc -o test-instr ../test-instr.c + gcc -pie -fPIE -o test-instr ../test-instr.c gcc -o test-compcov test-compcov.c test -e test-instr -a -e test-compcov && { { @@ -568,7 +568,9 @@ test -e ../afl-qemu-trace && { { export AFL_QEMU_PERSISTENT_ADDR=`expr 0x4$(nm test-instr | grep "T main" | awk '{print $1}' | sed 's/^.......//')` export AFL_QEMU_PERSISTENT_GPR=1 - ../afl-fuzz -V10 -Q -i in -o out -- ./test-instr > /dev/null 2>&1 + $ECHO "Info: AFL_QEMU_PERSISTENT_ADDR=$AFL_QEMU_PERSISTENT_ADDR <= $(nm test-instr | grep "T main" | awk '{print $1}')" + file test-instr + ../afl-fuzz -V10 -Q -i in -o out -- ./test-instr } >>errors 2>&1 test -n "$( ls out/queue/id:000002* 2> /dev/null )" && { $ECHO "$GREEN[+] afl-fuzz is working correctly with persistent qemu_mode" |