about summary refs log tree commit diff
path: root/frida_mode/Makefile
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2021-05-10 13:57:47 +0200
committerGitHub <noreply@github.com>2021-05-10 13:57:47 +0200
commit8b7a7b29c60f11cdf6226b3e418e87a5c3f5caac (patch)
tree6ce9d90644f161d21d802e9cbe48eb38467684e9 /frida_mode/Makefile
parentd0225c2c4d465968660a08c93857fed354e539b1 (diff)
downloadafl++-8b7a7b29c60f11cdf6226b3e418e87a5c3f5caac.tar.gz
Push to stable (#895)
* sync (#886)

* Create FUNDING.yml

* Update FUNDING.yml

* moved custom_mutator examples

* unicorn speedtest makefile cleanup

* fixed example location

* fix qdbi

* update util readme

* Frida persistent (#880)

* Added x64 support for persistent mode (function call only), in-memory teest cases and complog

* Review changes, fix NeverZero and code to parse the .text section of the main executable. Excluded ranges TBC

* Various minor fixes and finished support for AFL_INST_LIBS

* Review changes

Co-authored-by: Your Name <you@example.com>

* nits

* fix frida mode

* Integer overflow/underflow fixes in libdislocator (#889)

* libdislocator: fixing integer overflow in 'max_mem' variable and setting 'max_mem' type to 'size_t'

* libdislocator: fixing potential integer underflow in 'total_mem' variable due to its different values in different threads

* Bumped warnings up to the max and fixed remaining issues (#890)

Co-authored-by: Your Name <you@example.com>

* nits

* frida mode - support non-pie

* nits

* nit

* update grammar mutator

* Fixes for aarch64, OSX and other minor issues (#891)

Co-authored-by: Your Name <you@example.com>

* nits

* nits

* fix PCGUARD, build aflpp_driver with fPIC

* Added representative fuzzbench test and test for libxml (#893)

* Added representative fuzzbench test and test for libxml

* Added support for building FRIDA from source with FRIDA_SOURCE=1

Co-authored-by: Your Name <you@example.com>

* nits

* update changelog

* typos

* fixed potential double free in custom trim (#881)

* error handling, freeing mem

* frida: complog -> cmplog

* fix statsd writing

* let aflpp_qemu_driver_hook.so build fail gracefully

* fix stdin trimming

* Support for AFL_ENTRYPOINT (#898)

Co-authored-by: Your Name <you@example.com>

* remove the input file .cur_input at the end of the fuzzing, if AFL_TMPDIR is used

* reverse push (#901)

* Create FUNDING.yml

* Update FUNDING.yml

* disable QEMU static pie

Co-authored-by: Andrea Fioraldi <andreafioraldi@gmail.com>

* clarify that no modifications are required.

* add new test for frida_mode (please review)

* typos

* fix persistent mode (64-bit)

* set ARCH for linux intel 32-bit for frida-gum-devkit

* prepare for 32-bit support (later)

* not on qemu 3 anymore

* unicorn mips fixes

* instrumentation further move to C++11 (#900)

* unicorn fixes

* more unicorn fixes

* Fix memory errors when trim causes testcase growth (#881) (#903)

* Revert "fixed potential double free in custom trim (#881)"

This reverts commit e9d2f72382cab75832721d859c3e731da071435d.

* Revert "fix custom trim for increasing data"

This reverts commit 86a8ef168dda766d2f25f15c15c4d3ecf21d0667.

* Fix memory errors when trim causes testcase growth

Modify trim_case_custom to avoid writing into in_buf because
some custom mutators can cause the testcase to grow rather than
shrink.

Instead of modifying in_buf directly, we write the update out
to the disk when trimming is complete, and then the caller is
responsible for refreshing the in-memory buffer from the file.

This is still a bit sketchy because it does need to modify q->len in
order to notify the upper layers that something changed, and it could
end up telling upper layer code that the q->len is *bigger* than
the buffer (q->testcase_buf) that contains it, which is asking
for trouble down the line somewhere...

* Fix an unlikely situation

Put back some `unlikely()` calls that were in
the e9d2f72382cab75832721d859c3e731da071435d commit that was
reverted.

* typo

* Exit on time (#904)

* Variable AFL_EXIT_ON_TIME description has been added.
Variables AFL_EXIT_ON_TIME and afl_exit_on_time has been added.
afl->exit_on_time variable initialization has been added.
The asignment of a value to the afl->afl_env.afl_exit_on_time variable from
environment variables has been added.
Code to exit on timeout if new path not found has been added.

* Type of afl_exit_on_time variable has been changed.
Variable exit_on_time has been added to the afl_state_t structure.

* Command `export AFL_EXIT_WHEN_DONE=1` has been added.

* Millisecond to second conversion has been added.
Call get_cur_time() has been added.

* Revert to using the saved current time value.

* Useless check has been removed.

* fix new path to custom-mutators

* ensure crashes/README.txt exists

* fix

* Changes to bump FRIDA version and to clone FRIDA repo in to build directory rather than use a submodule as the FRIDA build scripts don't like it (#906)

Co-authored-by: Your Name <you@example.com>

* Fix numeric overflow in cmplog implementation (#907)

Co-authored-by: Your Name <you@example.com>

* testcase fixes for unicorn

* remove merge conflict artifacts

* fix afl-plot

* Changes to remove binaries from frida_mode (#913)

Co-authored-by: Your Name <you@example.com>

* Frida cmplog fail fast (#914)

* Changes to remove binaries from frida_mode

* Changes to make cmplog fail fast

Co-authored-by: Your Name <you@example.com>

* afl-plot: relative time

* arch linux and mac os support for afl-system-config

* typo

* code-format

* update documentation

Co-authored-by: Dominik Maier <domenukk@gmail.com>
Co-authored-by: WorksButNotTested <62701594+WorksButNotTested@users.noreply.github.com>
Co-authored-by: Your Name <you@example.com>
Co-authored-by: Dmitry Zheregelya <zheregelya.d@gmail.com>
Co-authored-by: hexcoder <hexcoder-@users.noreply.github.com>
Co-authored-by: hexcoder- <heiko@hexco.de>
Co-authored-by: Andrea Fioraldi <andreafioraldi@gmail.com>
Co-authored-by: David CARLIER <devnexen@gmail.com>
Co-authored-by: realmadsci <71108352+realmadsci@users.noreply.github.com>
Co-authored-by: Roman M. Iudichev <SecNotice@ya.ru>
Diffstat (limited to 'frida_mode/Makefile')
-rw-r--r--frida_mode/Makefile349
1 files changed, 5 insertions, 344 deletions
diff --git a/frida_mode/Makefile b/frida_mode/Makefile
index 822f1c6a..b6d64bff 100644
--- a/frida_mode/Makefile
+++ b/frida_mode/Makefile
@@ -1,348 +1,9 @@
-PWD:=$(shell pwd)/
-INC_DIR:=$(PWD)include/
-SRC_DIR:=$(PWD)src/
-INCLUDES:=$(wildcard $(INC_DIR)*.h)
-SOURCES:=$(wildcard $(SRC_DIR)*.c)
-BUILD_DIR:=$(PWD)build/
-CFLAGS+=-fPIC -D_GNU_SOURCE
+all:
+	@echo trying to use GNU make...
+	@gmake all || echo please install GNUmake
 
-FRIDA_BUILD_DIR:=$(BUILD_DIR)frida/
-FRIDA_TRACE:=$(FRIDA_BUILD_DIR)afl-frida-trace.so
-
-ARCH=$(shell uname -m)
-ifeq "$(ARCH)" "aarch64"
- ARCH:=arm64
- TESTINSTR_BASE:=0x0000aaaaaaaaa000
-endif
-
-ifeq "$(ARCH)" "x86_64"
- TESTINSTR_BASE:=0x0000555555554000
-endif
-
-ifeq "$(shell uname)" "Darwin"
- OS:=macos
- AFL_FRIDA_INST_RANGES=0x0000000000001000-0xFFFFFFFFFFFFFFFF
- CFLAGS:=$(CFLAGS) -Wno-deprecated-declarations
- TEST_LDFLAGS:=-undefined dynamic_lookup
-endif
-ifeq "$(shell uname)" "Linux"
- OS:=linux
- AFL_FRIDA_INST_RANGES=$(shell $(PWD)test/testinstr.py -f $(BUILD_DIR)testinstr -s .testinstr -b $(TESTINSTR_BASE))
- CFLAGS:=$(CFLAGS) -Wno-prio-ctor-dtor
- TEST_LDFLAGS:=
-endif
-
-ifndef OS
- $(error "Operating system unsupported")
-endif
-
-VERSION=14.2.13
-GUM_DEVKIT_FILENAME=frida-gum-devkit-$(VERSION)-$(OS)-$(ARCH).tar.xz
-GUM_DEVKIT_URL="https://github.com/frida/frida/releases/download/$(VERSION)/$(GUM_DEVKIT_FILENAME)"
-GUM_DEVKIT_TARBALL:=$(FRIDA_BUILD_DIR)$(GUM_DEVKIT_FILENAME)
-GUM_DEVIT_LIBRARY=$(FRIDA_BUILD_DIR)libfrida-gum.a
-GUM_DEVIT_HEADER=$(FRIDA_BUILD_DIR)frida-gum.h
-
-TEST_BUILD_DIR:=$(BUILD_DIR)test/
-
-LIBPNG_FILE:=$(TEST_BUILD_DIR)libpng-1.2.56.tar.gz
-LIBPNG_URL:=https://downloads.sourceforge.net/project/libpng/libpng12/older-releases/1.2.56/libpng-1.2.56.tar.gz
-LIBPNG_DIR:=$(TEST_BUILD_DIR)libpng-1.2.56/
-LIBPNG_MAKEFILE:=$(LIBPNG_DIR)Makefile
-LIBPNG_LIB:=$(LIBPNG_DIR).libs/libpng12.a
-
-HARNESS_FILE:=$(TEST_BUILD_DIR)StandaloneFuzzTargetMain.c
-HARNESS_OBJ:=$(TEST_BUILD_DIR)StandaloneFuzzTargetMain.o
-HARNESS_URL:="https://raw.githubusercontent.com/llvm/llvm-project/main/compiler-rt/lib/fuzzer/standalone/StandaloneFuzzTargetMain.c"
-
-PNGTEST_FILE:=$(TEST_BUILD_DIR)target.cc
-PNGTEST_OBJ:=$(TEST_BUILD_DIR)target.o
-PNGTEST_URL:="https://raw.githubusercontent.com/google/fuzzbench/master/benchmarks/libpng-1.2.56/target.cc"
-
-TEST_BIN:=$(TEST_BUILD_DIR)pngtest
-
-TESTINSTBIN:=$(BUILD_DIR)testinstr
-TESTINSTSRC:=$(PWD)test/testinstr.c
-
-TEST_DATA_DIR:=$(PWD)build/test/libpng-1.2.56/contrib/pngsuite/
-
-TESTINSTR_DATA_DIR:=$(BUILD_DIR)testinstr_in/
-TESTINSTR_DATA_FILE:=$(TESTINSTR_DATA_DIR)test.dat
-FRIDA_OUT:=$(PWD)frida_out
-QEMU_OUT:=$(PWD)qemu_out
-
-.PHONY: all frida test clean format test_frida test_qemu compare testinstr test_testinstr standalone
-
-all: $(FRIDA_TRACE)
-
-frida: $(FRIDA_TRACE)
-
-$(BUILD_DIR):
-	mkdir -p $(BUILD_DIR)
-
-############################# FRIDA ############################################
-$(FRIDA_BUILD_DIR): | $(BUILD_DIR)
-	mkdir -p $@
-
-$(GUM_DEVKIT_TARBALL): | $(FRIDA_BUILD_DIR)
-	wget -O $@ $(GUM_DEVKIT_URL)
-
-$(GUM_DEVIT_LIBRARY): | $(GUM_DEVKIT_TARBALL)
-	tar Jxvf $(GUM_DEVKIT_TARBALL) -C $(FRIDA_BUILD_DIR)
-
-$(GUM_DEVIT_HEADER): | $(GUM_DEVKIT_TARBALL)
-	tar Jxvf $(GUM_DEVKIT_TARBALL) -C $(FRIDA_BUILD_DIR)
-
-$(FRIDA_TRACE): $(GUM_DEVIT_LIBRARY) $(GUM_DEVIT_HEADER) $(SOURCES) Makefile | $(FRIDA_BUILD_DIR)
-	$(CC) -shared \
-		$(CFLAGS) \
-		-o $@ $(SOURCES) \
-		$(GUM_DEVIT_LIBRARY) \
-		-I $(FRIDA_BUILD_DIR) \
-		-I .. \
-		-I ../include \
-		-I $(INC_DIR) \
-		../instrumentation/afl-compiler-rt.o.c \
-		-lpthread -ldl -lresolv
-
-	cp -v $(FRIDA_TRACE) ../
-
-############################# TEST #############################################
-
-test: $(TEST_BIN)
-
-$(TEST_BUILD_DIR): $(BUILD_DIR)
-	mkdir -p $@
-
-$(HARNESS_FILE): | $(TEST_BUILD_DIR)
-	wget -O $@ $(HARNESS_URL)
-
-$(HARNESS_OBJ): $(HARNESS_FILE)
-	$(CC) -o $@ -c $<
-
-$(PNGTEST_FILE): | $(TEST_BUILD_DIR)
-	wget -O $@ $(PNGTEST_URL)
-
-$(PNGTEST_OBJ): $(PNGTEST_FILE) | $(LIBPNG_DIR)
-	$(CXX) -std=c++11 -I $(LIBPNG_DIR) -o $@ -c $<
-
-$(LIBPNG_FILE): | $(TEST_BUILD_DIR)
-	wget -O $@ $(LIBPNG_URL)
-
-$(LIBPNG_DIR): $(LIBPNG_FILE)
-	tar zxvf $(LIBPNG_FILE) -C $(TEST_BUILD_DIR)
-
-$(LIBPNG_MAKEFILE): | $(LIBPNG_DIR)
-	cd $(LIBPNG_DIR) && ./configure
-
-$(LIBPNG_LIB): $(LIBPNG_MAKEFILE)
-	make -C $(LIBPNG_DIR)
-
-$(TEST_BIN): $(HARNESS_OBJ) $(PNGTEST_OBJ) $(LIBPNG_LIB)
-	$(CXX) \
-		-o $@ \
-		$(HARNESS_OBJ) $(PNGTEST_OBJ) $(LIBPNG_LIB) \
-		-lz \
-		$(TEST_LDFLAGS)
-
-############################# TESTINSR #########################################
-$(TESTINSTR_DATA_DIR): | $(BUILD_DIR)
-	mkdir -p $@
-
-$(TESTINSTR_DATA_FILE): | $(TESTINSTR_DATA_DIR)
-	echo -n "000" > $@
-
-$(TESTINSTBIN): $(TESTINSTSRC) | $(BUILD_DIR)
-	$(CC) -o $@ $<
-
-testinstr: $(TESTINSTBIN)
-
-############################# CLEAN ############################################
 clean:
-	rm -rf $(BUILD_DIR)
+	@gmake clean
 
-############################# FORMAT ###########################################
 format:
-	cd .. && echo $(SOURCES) | xargs -L1 ./.custom-format.py -i
-	cd .. && echo $(INCLUDES) | xargs -L1 ./.custom-format.py -i
-	cd .. && ./.custom-format.py -i $(TESTINSTSRC)
-
-############################# RUN #############################################
-
-# Add the environment variable AFL_DEBUG_CHILD=1 to show printf's from the target
-
-png_frida: $(FRIDA_TRACE) $(TEST_BIN)
-	make -C ..
-	cd .. && \
-		./afl-fuzz \
-			-O \
-			-i $(TEST_DATA_DIR) \
-			-o $(FRIDA_OUT) \
-			-- \
-				$(TEST_BIN) @@
-
-png_qemu: $(TEST_BIN)
-	make -C ..
-	cd .. && \
-		./afl-fuzz \
-			-Q \
-			-i $(TEST_DATA_DIR) \
-			-o $(QEMU_OUT) \
-			-- \
-				$(TEST_BIN) @@
-
-compare: $(FRIDA_TRACE) $(TEST_BIN)
-	cd .. && \
-		./afl-fuzz \
-			-V30 \
-			-O \
-			-i $(TEST_DATA_DIR) \
-			-o $(FRIDA_OUT) \
-			-- \
-				$(TEST_BIN) @@
-	cd .. && \
-		./afl-fuzz \
-			-V30 \
-			-Q \
-			-i $(TEST_DATA_DIR) \
-			-o $(QEMU_OUT) \
-				-- \
-					$(TEST_BIN) @@
-	cat frida_out/default/fuzzer_stats
-	cat qemu_out/default/fuzzer_stats
-
-testinstr_qemu: $(TESTINSTBIN) $(TESTINSTR_DATA_FILE)
-	make -C ..
-	cd .. && \
-			AFL_QEMU_INST_RANGES=$(AFL_FRIDA_INST_RANGES) \
-			./afl-fuzz \
-				-Q \
-				-i $(TESTINSTR_DATA_DIR) \
-				-o $(QEMU_OUT) \
-				-- \
-					$(TESTINSTBIN) @@
-
-testinstr_frida: $(FRIDA_TRACE) $(TESTINSTBIN) $(TESTINSTR_DATA_FILE)
-	make -C ..
-	cd .. && \
-			AFL_FRIDA_INST_RANGES=$(AFL_FRIDA_INST_RANGES) \
-			AFL_FRIDA_INST_NO_OPTIMIZE=1 \
-			AFL_FRIDA_INST_NO_PREFETCH=1 \
-			AFL_FRIDA_INST_STRICT=1 \
-			./afl-fuzz \
-				-O \
-				-i $(TESTINSTR_DATA_DIR) \
-				-o $(FRIDA_OUT) \
-				-- \
-					$(TESTINSTBIN) @@
-
-standalone: $(FRIDA_TRACE) $(TESTINSTBIN) $(TESTINSTR_DATA_FILE)
-	cd .. && \
-			AFL_FRIDA_INST_RANGES=$(AFL_FRIDA_INST_RANGES) \
-			AFL_DEBUG_CHILD=1 \
-			AFL_FRIDA_DEBUG_MAPS=1 \
-			AFL_FRIDA_INST_NO_OPTIMIZE=1 \
-			AFL_FRIDA_INST_NO_PREFETCH=1 \
-			AFL_FRIDA_INST_TRACE=1 \
-			AFL_FRIDA_INST_STRICT=1 \
-			LD_PRELOAD=$(FRIDA_TRACE) \
-			DYLD_INSERT_LIBRARIES=$(FRIDA_TRACE) \
-			$(TESTINSTBIN) $(TESTINSTR_DATA_FILE)
-
-tmin_qemu: $(TEST_BIN)
-	make -C ..
-	cd .. && \
-		./afl-tmin \
-			-Q \
-			-i $(TEST_DATA_DIR)basn0g01.png \
-			-o $(QEMU_OUT)/qemu-min-basn0g01.png \
-			-- \
-				$(TEST_BIN) @@
-
-tmin_frida: $(TEST_BIN)
-	make -C ..
-	cd .. && \
-		./afl-tmin \
-			-O \
-			-i $(TEST_DATA_DIR)basn0g01.png \
-			-o $(FRIDA_OUT)/qemu-min-basn0g01.png \
-			-- \
-				$(TEST_BIN)
-
-showmap_qemu: $(TEST_BIN)
-	make -C ..
-	cd .. && \
-		./afl-showmap \
-			-Q \
-			-i $(TEST_DATA_DIR) \
-			-o $(QEMU_OUT) \
-			-- \
-				$(TEST_BIN) @@
-
-showmap_frida: $(TEST_BIN)
-	make -C ..
-	cd .. && \
-		./afl-showmap \
-			-O \
-			-i $(TEST_DATA_DIR) \
-			-o $(FRIDA_OUT) \
-			-- \
-				$(TEST_BIN) @@
-
-analyze_qemu: $(TEST_BIN)
-	make -C ..
-	cd .. && \
-		./afl-analyze \
-			-Q \
-			-i $(TEST_DATA_DIR)basn0g01.png \
-			-- \
-				$(TEST_BIN) @@
-
-analyze_frida: $(TEST_BIN)
-	make -C ..
-	cd .. && \
-		./afl-analyze \
-			-O \
-			-i $(TEST_DATA_DIR)basn0g01.png \
-			-- \
-				$(TEST_BIN) @@
-
-cmin_qemu: $(TEST_BIN)
-	make -C ..
-	cd .. && \
-		./afl-cmin \
-			-Q \
-			-i $(TEST_DATA_DIR) \
-			-o $(QEMU_OUT) \
-			-- \
-				$(TEST_BIN) @@
-
-cmin_frida: $(TEST_BIN)
-	make -C ..
-	cd .. && \
-		./afl-cmin \
-			-O \
-			-i $(TEST_DATA_DIR) \
-			-o $(FRIDA_OUT) \
-			-- \
-				$(TEST_BIN) @@
-
-cmin_bash_qemu: $(TEST_BIN)
-	make -C ..
-	cd .. && \
-		./afl-cmin.bash \
-			-Q \
-			-i $(TEST_DATA_DIR) \
-			-o $(QEMU_OUT) \
-			-- \
-				$(TEST_BIN) @@
-
-cmin_bash_frida: $(TEST_BIN)
-	make -C ..
-	cd .. && \
-		./afl-cmin.bash \
-			-O \
-			-i $(TEST_DATA_DIR) \
-			-o $(FRIDA_OUT) \
-			-- \
-				$(TEST_BIN) @@
+	@gmake format