-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
81 lines (75 loc) · 2.9 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
SHELL := /bin/bash
.PHONY: all fuzzilli afl jsc clean
all: fuzzilli afl jsc
fuzzilli:
# Check if submodule is initialized already
@if [[ ! -f fuzzilli/Package.swift ]]; then \
if [[ -d .git ]]; then \
git submodule update fuzzilli; \
else \
echo -e "Please run\n\n git submodule update\n\nbefore building the docker image." >&2; \
exit 1; \
fi; \
fi
# Patch Fuzzilli (don't undo because swift run would compile unpatched state again)
patch -N fuzzilli/Sources/Fuzzilli/Fuzzer.swift patches/fuzzilli/Fuzzer.diff || true
# Compile Fuzzilli
cd fuzzilli && swift build
afl:
# Check if submodule is initialized already
@if [[ ! -f AFLplusplus/Makefile ]]; then \
if [[ -d .git ]]; then \
git submodule update AFLplusplus; \
else \
echo -e "Please run\n\n git submodule update\n\nbefore building the docker image." >&2; \
exit 1; \
fi; \
fi
# Compile AFLplusplus
cd AFLplusplus && make all
# Patch QEMU for AFLplusplus
patch AFLplusplus/qemu_mode/build_qemu_support.sh patches/AFLplusplus/build_qemu_support.diff
# Build qemu support
cd AFLplusplus/qemu_mode && sh ./build_qemu_support.sh
# Undo patch to make sure submodule repository can be pulled without conflicts
patch -R AFLplusplus/qemu_mode/build_qemu_support.sh patches/AFLplusplus/build_qemu_support.diff
jsc:
# Check if submodule is initialized already
@if [[ ! -f WebKit/Makefile ]]; then \
if [[ -d .git ]]; then \
git submodule update WebKit; \
else \
echo -e "Please run\n\n git submodule update\n\nbefore building the docker image." >&2; \
exit 1; \
fi; \
fi
# Patch JavaScriptCore for Fuzzilli
patch WebKit/Source/JavaScriptCore/jsc.cpp fuzzilli/Targets/JavaScriptCore/Patches/webkit.patch
# Patch JavaScriptCore for AFL
patch WebKit/Source/JavaScriptCore/jsc.cpp patches/WebKit/jsc.diff
# Build WebKit
cd WebKit && ../fuzzilli/Targets/JavaScriptCore/fuzzbuild.sh
# Undo AFL patch to make sure submodule repository can be pulled without conflicts
patch -R WebKit/Source/JavaScriptCore/jsc.cpp patches/WebKit/jsc.diff
# Undo fuzzilli patch to make sure submodule repository can be pulled without conflicts
patch -R WebKit/Source/JavaScriptCore/jsc.cpp fuzzilli/Targets/JavaScriptCore/Patches/webkit.patch
# Create symbolic link to JavaScriptCore executable (if not exists already)
@if [[ ! -L jsc ]]; then \
ln -s WebKit/FuzzBuild/Debug/bin/jsc jsc; \
fi
# Store address of forkserver function to .afl_entrypoint
@echo -n "0x" > .afl_entrypoint
@nm jsc | grep functionGetAFLInput | cut -d' ' -f1 >> .afl_entrypoint
clean:
# Reset all local changes of the submodules (e.g. applied patches)
git submodule foreach 'git reset --hard'
# Remove WebKit build files
@if [[ -d WebKit/FuzzBuild ]]; then \
rm -rfv WebKit/FuzzBuild; \
fi
# Remove symbolic link to jsc executable
@if [[ -L jsc ]]; then \
rm -v jsc; \
fi
# Remove AFLplusplus build files
cd AFLplusplus && make deepclean