forked from spinpx/afl_pin_mode
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
98 lines (75 loc) · 2.53 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
TARGET := $(shell uname -p)
ifeq ($(TARGET),x86_64)
PIN_OBJ_DIR=obj-intel64
else
PIN_OBJ_DIR=obj-ia32
endif
CUR_DIR = $(shell pwd)
#PIN_NAME=pin-3.4-97438-gf90d1f746-gcc-linux
PIN_NAME=pin-2.14-71313-gcc.4.4.7-linux
PIN_URL="http://software.intel.com/sites/landingpage/pintool/downloads/${PIN_NAME}.tar.gz"
PIN_TAR=${CUR_DIR}/${PIN_NAME}.tar.gz
PIN_ROOT=${CUR_DIR}/${PIN_NAME}
PIN_BIN=${PIN_ROOT}/pin
TOOL_NAME=tool.so
PIN_TOOL=${CUR_DIR}/${PIN_OBJ_DIR}/${TOOL_NAME}
define newline
endef
define CONFIG_BODY
#ifndef AFL_PIN_CONFIG_H
#define AFL_PIN_CONFIG_H
#define PIN_APP_LD_PRELOAD \"${CUR_DIR}/forkserver.so\"
#define PIN_BIN \"${PIN_BIN}\"
#define PIN_TOOL \"${PIN_TOOL}\"
#endif
endef
PIN_CONFIG_STR="$(subst $(newline),\n,${CONFIG_BODY})"
PIN_CONFIG_FILE="${CUR_DIR}/pin_config.h"
all: check test_app crash_app forkserver simulate pin_tool mini pin_run
check: | ${PIN_ROOT}
${PIN_ROOT}:
@echo "install pin ...."
@wget ${PIN_URL}
@tar -xf ${PIN_TAR}
@echo ${PIN_CONFIG_STR} > ${PIN_CONFIG_FILE}
# write pin config file.
install_afl:
@wget http://lcamtuf.coredump.cx/afl/releases/afl-latest.tgz
@tar -xf afl-latest.tgz
# TODO: Name of afl-2.51b?
forkserver: forkserver.cpp
${CXX} -O3 -std=c++11 -Wall -shared -fPIC -o forkserver.so forkserver.cpp
simulate: simulate.cpp
$(CXX) -O3 -std=c++11 -o simulate simulate.cpp
test_app: test.cpp
$(CXX) -O3 -o test test.cpp
crash_app: crash.cpp
$(CXX) -O3 -o crash crash.cpp
mini_app: mini.c
$(CXX) -O3 -o mini mini.cpp
pin_run: pin_run.cpp
$(CXX) -O3 -std=c++11 -o pin_run pin_run.cpp
pin_tool:
PIN_ROOT=${PIN_ROOT} make -f makefile.pin
pin_test: test_app crash_app forkserver simulate
USING_PIN=1 ./simulate ./pin_run ./test
no_pin_test: test_app crash_app forkserver simulate
./simulate ./test
afl_test:
./afl-2.51b/afl-fuzz -m 1000 -i inputs -o outputs -- ./pin_run ./mini @@
test: test_app crash_app forkserver simulate
@echo "-----------------------------------------------------------------------"
@echo "test without simulating..."
LD_PRELOAD=./forkserver.so ./test
([ $$? -eq 0 ] && echo "success!") || echo "failure!"
@echo "-----------------------------------------------------------------------"
@echo "test normal with simulating..."
./simulate ./test
([ $$? -eq 0 ] && echo "success!") || echo "failure!"
@echo "-----------------------------------------------------------------------"
@echo "test normal with simulating..."
./simulate ./crash
([ $$? -eq 0 ] && echo "success!") || echo "failure!"
clean:
make -f makefile.pin clean mini pin_run
rm -f *.so test crash simulate