mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-24 14:43:22 +00:00
Compare commits
111 Commits
Author | SHA1 | Date | |
---|---|---|---|
775861ea94 | |||
602eceed8b | |||
68dc4829b3 | |||
a25f27de28 | |||
ed1a6f8a57 | |||
a9292626a6 | |||
1e7485dcee | |||
58871777ae | |||
f98dc8abe8 | |||
028d4c8c64 | |||
ba28f5fbfa | |||
5ba66a8860 | |||
06f0982f0f | |||
eda770fd32 | |||
37d2039211 | |||
d8e8d34c4e | |||
96ada75bd9 | |||
87596105ef | |||
ac639012fb | |||
a84b7c7820 | |||
5549212d9e | |||
eb52f1cc08 | |||
236fb9b145 | |||
e5d305ad42 | |||
76a033431d | |||
7793692590 | |||
97ba817aa7 | |||
6e6d91b6b0 | |||
123ec5d136 | |||
5da5d6e0df | |||
c33de47120 | |||
643df2b538 | |||
970e0b14ce | |||
3768933c92 | |||
da5d3d63e2 | |||
ccad11f7eb | |||
0d164e4c18 | |||
644e069450 | |||
75af391408 | |||
9604fe922e | |||
d5b6c0f773 | |||
12ab9ebd32 | |||
4859b583ad | |||
1ffb1b6b2a | |||
58b80b68bc | |||
2f9eeef60c | |||
d88c97ad28 | |||
ba28c4982b | |||
8746b3e310 | |||
a5db79e4d6 | |||
d5812786f3 | |||
227c1a7002 | |||
243c6640a8 | |||
33a129e00c | |||
9cefc4d3d4 | |||
3046c80cd5 | |||
ab0823cd3b | |||
de561b730a | |||
a518c4d75c | |||
660b697ed9 | |||
cefc9a00bf | |||
0c054f520e | |||
e731a1c1ab | |||
523ce154c3 | |||
04219f9857 | |||
136febaf68 | |||
046473acd5 | |||
8412b17d79 | |||
e9621db61c | |||
68d883d428 | |||
46ef6a54e1 | |||
355dcf6320 | |||
a4017406dc | |||
b99bbf671b | |||
9d3c25ac81 | |||
4e9c6050d0 | |||
f75778adfb | |||
db65dc5a0b | |||
bb6d9cddd7 | |||
ee7d69b817 | |||
aad9ac2b33 | |||
358cd1b062 | |||
0aeee03e47 | |||
9d305acbf3 | |||
5f492da717 | |||
c5b4e26052 | |||
1a60e35a2a | |||
2260a065f4 | |||
1eb54c4c3e | |||
c39596c8bf | |||
88cbaeb3e1 | |||
25f9c1f4fb | |||
934a02f7f6 | |||
98a2a334de | |||
1fc1b32db2 | |||
b01ef97569 | |||
c3197dfeb7 | |||
a9e6998b82 | |||
dcb5bc3fa5 | |||
daaefcddc0 | |||
3c0cfd82bc | |||
df0638ab87 | |||
27d05f3c21 | |||
86d76b52ac | |||
c38dedbecd | |||
2f74feaf99 | |||
806a76afae | |||
f822cdeb74 | |||
7fabe5052b | |||
353ae3682a | |||
ca0c9f6d17 |
10
.github/workflows/ci.yml
vendored
10
.github/workflows/ci.yml
vendored
@ -20,20 +20,18 @@ jobs:
|
||||
AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES: 1
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: update
|
||||
run: sudo apt-get update && sudo apt-get upgrade -y
|
||||
- name: debug
|
||||
run: apt-cache search plugin-dev | grep gcc-; echo; apt-cache search clang-format- | grep clang-format-
|
||||
- name: update
|
||||
run: sudo apt-get update
|
||||
# && sudo apt-get upgrade -y
|
||||
- name: install packages
|
||||
#run: sudo apt-get install -y -m -f --install-suggests build-essential git libtool libtool-bin automake bison libglib2.0-0 clang llvm-dev libc++-dev findutils libcmocka-dev python3-dev python3-setuptools ninja-build python3-pip
|
||||
run: sudo apt-get install -y -m -f build-essential git libtool libtool-bin automake flex bison libglib2.0-0 clang llvm-dev libc++-dev findutils libcmocka-dev python3-dev python3-setuptools ninja-build python3-pip
|
||||
run: sudo apt-get install -y -m -f build-essential gcc-10 g++-10 git libtool libtool-bin automake flex bison libglib2.0-0 clang-12 llvm-12-dev libc++-dev findutils libcmocka-dev python3-dev python3-setuptools ninja-build python3-pip gcc-10-plugin-dev
|
||||
- name: compiler installed
|
||||
run: gcc -v; echo; clang -v
|
||||
- name: install gcc plugin
|
||||
run: sudo apt-get install -y -m -f --install-suggests $(readlink /usr/bin/gcc)-plugin-dev
|
||||
- name: build afl++
|
||||
run: make distrib ASAN_BUILD=1 NO_NYX=1
|
||||
run: export NO_NYX=1; export ASAN_BUILD=1; export LLVM_CONFIG=llvm-config-12; make ASAN_BUILD=1 NO_NYX=1 LLVM_CONFIG=llvm-config-12 distrib
|
||||
- name: run tests
|
||||
run: sudo -E ./afl-system-config; make tests
|
||||
# macos:
|
||||
|
6
.gitmodules
vendored
6
.gitmodules
vendored
@ -19,9 +19,9 @@
|
||||
[submodule "nyx_mode/libnyx"]
|
||||
path = nyx_mode/libnyx
|
||||
url = https://github.com/nyx-fuzz/libnyx.git
|
||||
[submodule "nyx_mode/QEMU-Nyx"]
|
||||
path = nyx_mode/QEMU-Nyx
|
||||
url = https://github.com/nyx-fuzz/qemu-nyx.git
|
||||
[submodule "nyx_mode/packer"]
|
||||
path = nyx_mode/packer
|
||||
url = https://github.com/nyx-fuzz/packer.git
|
||||
[submodule "nyx_mode/QEMU-Nyx"]
|
||||
path = nyx_mode/QEMU-Nyx
|
||||
url = https://github.com/nyx-fuzz/QEMU-Nyx
|
||||
|
@ -16,8 +16,8 @@ ENV NO_CORESIGHT=1
|
||||
ENV NO_NYX=1
|
||||
|
||||
### Only change these if you know what you are doing:
|
||||
# LLVM 15 does not look good so we stay at 14 to still have LTO
|
||||
ENV LLVM_VERSION=14
|
||||
# Current recommended LLVM version is 16
|
||||
ENV LLVM_VERSION=16
|
||||
# GCC 12 is producing compile errors for some targets so we stay at GCC 11
|
||||
ENV GCC_VERSION=11
|
||||
|
||||
@ -88,7 +88,7 @@ ARG TEST_BUILD
|
||||
|
||||
RUN sed -i.bak 's/^ -/ /g' GNUmakefile && \
|
||||
make clean && make distrib && \
|
||||
([ "${TEST_BUILD}" ] || (make install && make clean)) && \
|
||||
([ "${TEST_BUILD}" ] || (make install)) && \
|
||||
mv GNUmakefile.bak GNUmakefile
|
||||
|
||||
RUN echo "set encoding=utf-8" > /root/.vimrc && \
|
||||
|
27
GNUmakefile
27
GNUmakefile
@ -66,6 +66,10 @@ ifdef MSAN_BUILD
|
||||
override LDFLAGS += -fsanitize=memory
|
||||
endif
|
||||
|
||||
ifdef CODE_COVERAGE
|
||||
override CFLAGS += -D__AFL_CODE_COVERAGE=1
|
||||
endif
|
||||
|
||||
ifeq "$(findstring android, $(shell $(CC) --version 2>/dev/null))" ""
|
||||
ifeq "$(shell echo 'int main() {return 0; }' | $(CC) $(CFLAGS) -Werror -x c - -flto=full -o .test 2>/dev/null && echo 1 || echo 0 ; rm -f .test )" "1"
|
||||
CFLAGS_FLTO ?= -flto=full
|
||||
@ -395,7 +399,7 @@ help:
|
||||
@echo INTROSPECTION - compile afl-fuzz with mutation introspection
|
||||
@echo NO_PYTHON - disable python support
|
||||
@echo NO_SPLICING - disables splicing mutation in afl-fuzz, not recommended for normal fuzzing
|
||||
@echo NO_UTF - do not use UTF-8 for line rendering in status screen (fallback to G1 box drawing, of vanilla AFL)
|
||||
@echo "NO_UTF - do not use UTF-8 for line rendering in status screen (fallback to G1 box drawing, of vanilla AFL)"
|
||||
@echo NO_NYX - disable building nyx mode dependencies
|
||||
@echo "NO_CORESIGHT - disable building coresight (arm64 only)"
|
||||
@echo NO_UNICORN_ARM64 - disable building unicorn on arm64
|
||||
@ -649,16 +653,16 @@ endif
|
||||
# -$(MAKE) -C utils/plot_ui
|
||||
-$(MAKE) -C frida_mode
|
||||
ifneq "$(SYS)" "Darwin"
|
||||
ifeq "$(ARCH)" "aarch64"
|
||||
ifndef NO_CORESIGHT
|
||||
ifeq "$(ARCH)" "aarch64"
|
||||
ifndef NO_CORESIGHT
|
||||
-$(MAKE) -C coresight_mode
|
||||
endif
|
||||
endif
|
||||
ifeq "$(SYS)" "Linux"
|
||||
ifndef NO_NYX
|
||||
endif
|
||||
ifeq "$(SYS)" "Linux"
|
||||
ifndef NO_NYX
|
||||
-cd nyx_mode && ./build_nyx_support.sh
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
-cd qemu_mode && sh ./build_qemu_support.sh
|
||||
ifeq "$(ARCH)" "aarch64"
|
||||
ifndef NO_UNICORN_ARM64
|
||||
@ -782,7 +786,7 @@ install: all $(MANPAGES)
|
||||
@rm -f $${DESTDIR}$(BIN_PATH)/afl-plot.sh
|
||||
@rm -f $${DESTDIR}$(BIN_PATH)/afl-as
|
||||
@rm -f $${DESTDIR}$(HELPER_PATH)/afl-llvm-rt.o $${DESTDIR}$(HELPER_PATH)/afl-llvm-rt-32.o $${DESTDIR}$(HELPER_PATH)/afl-llvm-rt-64.o $${DESTDIR}$(HELPER_PATH)/afl-gcc-rt.o
|
||||
@for i in afl-llvm-dict2file.so afl-llvm-lto-instrumentlist.so afl-llvm-pass.so cmplog-instructions-pass.so cmplog-routines-pass.so cmplog-switches-pass.so compare-transform-pass.so libcompcov.so libdislocator.so libnyx.so libqasan.so libtokencap.so SanitizerCoverageLTO.so SanitizerCoveragePCGUARD.so split-compares-pass.so split-switches-pass.so; do echo rm -fv $${DESTDIR}$(HELPER_PATH)/$${i}; done
|
||||
@for i in afl-llvm-dict2file.so afl-llvm-lto-instrumentlist.so afl-llvm-pass.so cmplog-instructions-pass.so cmplog-routines-pass.so cmplog-switches-pass.so compare-transform-pass.so libcompcov.so libdislocator.so libnyx.so libqasan.so libtokencap.so SanitizerCoverageLTO.so SanitizerCoveragePCGUARD.so split-compares-pass.so split-switches-pass.so injection-pass.so; do echo rm -fv $${DESTDIR}$(HELPER_PATH)/$${i}; done
|
||||
install -m 755 $(PROGS) $(SH_PROGS) $${DESTDIR}$(BIN_PATH)
|
||||
@if [ -f afl-qemu-trace ]; then install -m 755 afl-qemu-trace $${DESTDIR}$(BIN_PATH); fi
|
||||
@if [ -f utils/plot_ui/afl-plot-ui ]; then install -m 755 utils/plot_ui/afl-plot-ui $${DESTDIR}$(BIN_PATH); fi
|
||||
@ -813,11 +817,12 @@ endif
|
||||
install -m 644 docs/*.md $${DESTDIR}$(DOC_PATH)
|
||||
cp -r testcases/ $${DESTDIR}$(MISC_PATH)
|
||||
cp -r dictionaries/ $${DESTDIR}$(MISC_PATH)
|
||||
cp injections.dic $${DESTDIR}$(MISC_PATH)
|
||||
|
||||
.PHONY: uninstall
|
||||
uninstall:
|
||||
-cd $${DESTDIR}$(BIN_PATH) && rm -f $(PROGS) $(SH_PROGS) afl-cs-proxy afl-qemu-trace afl-plot-ui afl-fuzz-document afl-network-server afl-g* afl-plot.sh afl-as afl-ld-lto afl-c* afl-lto*
|
||||
-cd $${DESTDIR}$(HELPER_PATH) && rm -f afl-g*.*o afl-llvm-*.*o afl-compiler-*.*o libdislocator.so libtokencap.so libcompcov.so libqasan.so afl-frida-trace.so libnyx.so socketfuzz*.so argvfuzz*.so libAFLDriver.a libAFLQemuDriver.a as afl-as SanitizerCoverage*.so compare-transform-pass.so cmplog-*-pass.so split-*-pass.so dynamic_list.txt
|
||||
-cd $${DESTDIR}$(BIN_PATH) && rm -f $(PROGS) $(SH_PROGS) afl-cs-proxy afl-qemu-trace afl-plot-ui afl-fuzz-document afl-network-client afl-network-server afl-g* afl-plot.sh afl-as afl-ld-lto afl-c* afl-lto*
|
||||
-cd $${DESTDIR}$(HELPER_PATH) && rm -f afl-g*.*o afl-llvm-*.*o afl-compiler-*.*o libdislocator.so libtokencap.so libcompcov.so libqasan.so afl-frida-trace.so libnyx.so socketfuzz*.so argvfuzz*.so libAFLDriver.a libAFLQemuDriver.a as afl-as SanitizerCoverage*.so compare-transform-pass.so cmplog-*-pass.so split-*-pass.so dynamic_list.txt injections.dic
|
||||
-rm -rf $${DESTDIR}$(MISC_PATH)/testcases $${DESTDIR}$(MISC_PATH)/dictionaries
|
||||
-sh -c "ls docs/*.md | sed 's|^docs/|$${DESTDIR}$(DOC_PATH)/|' | xargs rm -f"
|
||||
-cd $${DESTDIR}$(MAN_PATH) && rm -f $(MANPAGES)
|
||||
|
@ -11,7 +11,7 @@
|
||||
# from Laszlo Szekeres.
|
||||
#
|
||||
# Copyright 2015 Google Inc. All rights reserved.
|
||||
# Copyright 2019-2023 AFLplusplus Project. All rights reserved.
|
||||
# Copyright 2019-2024 AFLplusplus Project. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -45,13 +45,13 @@ endif
|
||||
LLVMVER = $(shell $(LLVM_CONFIG) --version 2>/dev/null | sed 's/git//' | sed 's/svn//' )
|
||||
LLVM_MAJOR = $(shell $(LLVM_CONFIG) --version 2>/dev/null | sed 's/\..*//' )
|
||||
LLVM_MINOR = $(shell $(LLVM_CONFIG) --version 2>/dev/null | sed 's/.*\.//' | sed 's/git//' | sed 's/svn//' | sed 's/ .*//' )
|
||||
LLVM_UNSUPPORTED = $(shell $(LLVM_CONFIG) --version 2>/dev/null | grep -E -q '^[0-2]\.|^3.[0-7]\.' && echo 1 || echo 0 )
|
||||
LLVM_UNSUPPORTED = $(shell $(LLVM_CONFIG) --version 2>/dev/null | grep -E -q '^[0-2]\.|^3.[0-8]\.' && echo 1 || echo 0 )
|
||||
LLVM_TOO_NEW = $(shell $(LLVM_CONFIG) --version 2>/dev/null | grep -E -q '^1[8-9]|^2[0-9]' && echo 1 || echo 0 )
|
||||
LLVM_TOO_OLD = $(shell $(LLVM_CONFIG) --version 2>/dev/null | grep -E -q '^[1-9]\.|^1[012]\.' && echo 1 || echo 0 )
|
||||
LLVM_NEW_API = $(shell $(LLVM_CONFIG) --version 2>/dev/null | grep -E -q '^1[0-9]' && echo 1 || echo 0 )
|
||||
LLVM_NEWER_API = $(shell $(LLVM_CONFIG) --version 2>/dev/null | grep -E -q '^1[6-9]' && echo 1 || echo 0 )
|
||||
LLVM_13_OK = $(shell $(LLVM_CONFIG) --version 2>/dev/null | grep -E -q '^1[3-9]' && echo 1 || echo 0 )
|
||||
LLVM_HAVE_LTO = $(shell $(LLVM_CONFIG) --version 2>/dev/null | grep -E -q '^1[1-9]' && echo 1 || echo 0 )
|
||||
LLVM_HAVE_LTO = $(shell $(LLVM_CONFIG) --version 2>/dev/null | grep -E -q '^1[2-9]' && echo 1 || echo 0 )
|
||||
LLVM_BINDIR = $(shell $(LLVM_CONFIG) --bindir 2>/dev/null)
|
||||
LLVM_LIBDIR = $(shell $(LLVM_CONFIG) --libdir 2>/dev/null)
|
||||
LLVM_STDCXX = gnu++11
|
||||
@ -95,12 +95,12 @@ ifeq "$(LLVM_NEWER_API)" "1"
|
||||
endif
|
||||
|
||||
ifeq "$(LLVM_HAVE_LTO)" "1"
|
||||
$(info [+] llvm_mode detected llvm 11+, enabling afl-lto LTO implementation)
|
||||
$(info [+] llvm_mode detected llvm 12+, enabling afl-lto LTO implementation)
|
||||
LLVM_LTO = 1
|
||||
endif
|
||||
|
||||
ifeq "$(LLVM_LTO)" "0"
|
||||
$(info [+] llvm_mode detected llvm < 11, afl-lto LTO will not be build.)
|
||||
$(info [+] llvm_mode detected llvm < 12, afl-lto LTO will not be build.)
|
||||
endif
|
||||
|
||||
ifeq "$(LLVM_APPLE_XCODE)" "1"
|
||||
@ -341,7 +341,7 @@ ifeq "$(TEST_MMAP)" "1"
|
||||
endif
|
||||
|
||||
PROGS_ALWAYS = ./afl-cc ./afl-compiler-rt.o ./afl-compiler-rt-32.o ./afl-compiler-rt-64.o
|
||||
PROGS = $(PROGS_ALWAYS) ./afl-llvm-pass.so ./SanitizerCoveragePCGUARD.so ./split-compares-pass.so ./split-switches-pass.so ./cmplog-routines-pass.so ./cmplog-instructions-pass.so ./cmplog-switches-pass.so ./afl-llvm-dict2file.so ./compare-transform-pass.so ./afl-ld-lto ./afl-llvm-lto-instrumentlist.so ./SanitizerCoverageLTO.so
|
||||
PROGS = $(PROGS_ALWAYS) ./afl-llvm-pass.so ./SanitizerCoveragePCGUARD.so ./split-compares-pass.so ./split-switches-pass.so ./cmplog-routines-pass.so ./cmplog-instructions-pass.so ./cmplog-switches-pass.so ./afl-llvm-dict2file.so ./compare-transform-pass.so ./afl-ld-lto ./afl-llvm-lto-instrumentlist.so ./SanitizerCoverageLTO.so ./injection-pass.so
|
||||
|
||||
# If prerequisites are not given, warn, do not build anything, and exit with code 0
|
||||
ifeq "$(LLVMVER)" ""
|
||||
@ -469,6 +469,9 @@ endif
|
||||
afl-llvm-dict2file.so: instrumentation/afl-llvm-dict2file.so.cc instrumentation/afl-llvm-common.o | test_deps
|
||||
$(CXX) $(CLANG_CPPFL) -shared $< -o $@ $(CLANG_LFL) instrumentation/afl-llvm-common.o
|
||||
|
||||
./injection-pass.so: instrumentation/injection-pass.cc instrumentation/afl-llvm-common.o | test_deps
|
||||
$(CXX) $(CLANG_CPPFL) -shared $< -o $@ $(CLANG_LFL) instrumentation/afl-llvm-common.o
|
||||
|
||||
.PHONY: document
|
||||
document:
|
||||
$(CLANG_BIN) -D_AFL_DOCUMENT_MUTATIONS $(CFLAGS_SAFE) $(CPPFLAGS) $(CLANG_CFL) -O3 -Wno-unused-result -fPIC -c instrumentation/afl-compiler-rt.o.c -o ./afl-compiler-rt.o
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
<img align="right" src="https://raw.githubusercontent.com/AFLplusplus/Website/main/static/aflpp_bg.svg" alt="AFL++ logo" width="250" heigh="250">
|
||||
|
||||
Release version: [4.09c](https://github.com/AFLplusplus/AFLplusplus/releases)
|
||||
Release version: [4.10c](https://github.com/AFLplusplus/AFLplusplus/releases)
|
||||
|
||||
GitHub version: 4.09c
|
||||
GitHub version: 4.10c
|
||||
|
||||
Repository:
|
||||
[https://github.com/AFLplusplus/AFLplusplus](https://github.com/AFLplusplus/AFLplusplus)
|
||||
|
28
TODO.md
28
TODO.md
@ -2,25 +2,21 @@
|
||||
|
||||
## Must
|
||||
|
||||
- adapt MOpt to new mutation engine
|
||||
- Update afl->pending_not_fuzzed for MOpt
|
||||
- cmplog rtn sanity check on fixed length? + no length 1
|
||||
- afl-showmap -f support
|
||||
- afl-fuzz multicore wrapper script
|
||||
- when trimming then perform crash detection
|
||||
- either -L0 and/or -p mmopt results in zero new coverage
|
||||
|
||||
## Should
|
||||
|
||||
<<<<<<< Updated upstream
|
||||
- add value_profile but only enable after 15 minutes without finds?
|
||||
=======
|
||||
- afl-showmap -f support
|
||||
- afl-fuzz multicore wrapper script
|
||||
- UI revamp
|
||||
- hardened_usercopy=0 page_alloc.shuffle=0
|
||||
- add value_profile but only enable after 15 minutes without finds
|
||||
>>>>>>> Stashed changes
|
||||
- cmplog max len, cmplog max items envs?
|
||||
- adapt MOpt to new mutation engine
|
||||
- Update afl->pending_not_fuzzed for MOpt
|
||||
- cmplog rtn sanity check on fixed length? currently we ignore the length
|
||||
- afl-showmap -f support
|
||||
- afl-fuzz multicore wrapper script
|
||||
- when trimming then perform crash detection
|
||||
- problem: either -L0 and/or -p mmopt results in zero new coverage
|
||||
|
||||
|
||||
## Should
|
||||
|
||||
- afl-crash-analysis
|
||||
- support persistent and deferred fork server in afl-showmap?
|
||||
- better autodetection of shifting runtime timeout values
|
||||
|
6
afl-cmin
6
afl-cmin
@ -1,11 +1,15 @@
|
||||
#!/usr/bin/env sh
|
||||
SYS=$(uname -s)
|
||||
test "$SYS" = "Darwin" && {
|
||||
echo Error: afl-cmin does not work on Apple currently. please use afl-cmin.bash instead.
|
||||
exit 1
|
||||
}
|
||||
export AFL_QUIET=1
|
||||
export ASAN_OPTIONS=detect_leaks=0
|
||||
THISPATH=`dirname ${0}`
|
||||
export PATH="${THISPATH}:$PATH"
|
||||
awk -f - -- ${@+"$@"} <<'EOF'
|
||||
#!/usr/bin/awk -f
|
||||
|
||||
# awk script to minimize a test corpus of input files
|
||||
#
|
||||
# based on afl-cmin bash script written by Michal Zalewski
|
||||
|
@ -7,7 +7,7 @@
|
||||
#
|
||||
# Copyright 2014, 2015 Google Inc. All rights reserved.
|
||||
#
|
||||
# Copyright 2019-2023 AFLplusplus
|
||||
# Copyright 2019-2024 AFLplusplus
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -38,6 +38,7 @@ fi
|
||||
|
||||
echo
|
||||
PLATFORM=`uname -s`
|
||||
ARCH=`uname -m`
|
||||
|
||||
# check that we're on Mac
|
||||
if [[ "$PLATFORM" = "Darwin" ]] ; then
|
||||
@ -87,6 +88,13 @@ if [[ "$PLATFORM" = "Darwin" ]] ; then
|
||||
</plist>
|
||||
EOF
|
||||
|
||||
if [[ "$ARCH" = "x86_64" ]]; then
|
||||
echo "Disabling ASLR system wide"
|
||||
nvram boot-args="no_aslr=1"
|
||||
else
|
||||
echo NOTICE: on ARM64 we do not know currently how to disable system wide ASLR, please report if you know how.
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "Reboot and enjoy your fuzzing"
|
||||
exit 0
|
||||
|
@ -25,6 +25,7 @@ echo "WARNING: this reduces the security of the system!"
|
||||
echo
|
||||
if [ '!' "$EUID" = 0 ] && [ '!' `id -u` = 0 ] ; then
|
||||
echo "Warning: you need to be root to run this!"
|
||||
sleep 1
|
||||
# we do not exit as other mechanisms exist that allows to do this than
|
||||
# being root. let the errors speak for themselves.
|
||||
fi
|
||||
|
@ -6,7 +6,7 @@
|
||||
# Originally written by Michal Zalewski
|
||||
#
|
||||
# Copyright 2015 Google Inc. All rights reserved.
|
||||
# Copyright 2019-2023 AFLplusplus Project. All rights reserved.
|
||||
# Copyright 2019-2024 AFLplusplus Project. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -1 +1 @@
|
||||
ff4e5a2
|
||||
5ed4f8d
|
||||
|
Submodule custom_mutators/grammar_mutator/grammar_mutator updated: ff4e5a265d...5ed4f8d6e6
@ -3,6 +3,37 @@
|
||||
This is the list of all noteworthy changes made in every public
|
||||
release of the tool. See README.md for the general instruction manual.
|
||||
|
||||
### Version ++4.10c (release)
|
||||
- afl-fuzz:
|
||||
- default power schedule is now EXPLORE, due a fix in fast schedules
|
||||
explore is slightly better now.
|
||||
- fixed minor issues in the mutation engine, thanks to @futhewo for
|
||||
reporting!
|
||||
- better deterministic fuzzing is now available, benchmarks have shown
|
||||
to improve fuzzing. Enable with -D. Thanks to @kdsjZh for the PR!
|
||||
- afl-cc:
|
||||
- large rewrite by @SonicStark which fixes a few corner cases, thanks!
|
||||
- LTO mode now requires llvm 12+
|
||||
- workaround for ASAN with gcc_plugin mode
|
||||
- instrumentation:
|
||||
- LLVM 18 support, thanks to @devnexen!
|
||||
- Injection (SQL, LDAP, XSS) fuzzing feature now available, see
|
||||
`instrumentation/README.injections.md` how to activate/use/expand.
|
||||
- compcov/LAF-intel:
|
||||
- floating point splitting bug fix by @hexcoder
|
||||
- due a bug in LLVM 17 integer splitting is disabled there!
|
||||
- when splitting floats was selected, integers were always split as well,
|
||||
fixed to require AFL_LLVM_LAF_SPLIT_COMPARES or _ALL as it should
|
||||
- dynamic instrumentation filtering for LLVM NATIVE, thanks @Mozilla!
|
||||
see utils/dynamic_covfilter/README.md
|
||||
- qemu_mode:
|
||||
- plugins are now activated by default and a new module is included that
|
||||
produces drcov compatible traces for lighthouse/lightkeeper/...
|
||||
thanks to @JRomainG to submitting!
|
||||
- updated Nyx checkout (fixes a bug) and some QOL
|
||||
- updated the custom grammar mutator
|
||||
- document afl-cmin does not work on macOS (but afl-cmin.bash does)
|
||||
|
||||
### Version ++4.09c (release)
|
||||
- afl-fuzz:
|
||||
- fixed the new mutation implementation for two bugs
|
||||
@ -34,7 +65,6 @@
|
||||
- added benchmark/benchmark.py if you want to see how good your fuzzing
|
||||
speed is in comparison to other setups.
|
||||
|
||||
|
||||
### Version ++4.08c (release)
|
||||
- afl-fuzz:
|
||||
- new mutation engine: mutations that favor discovery more paths are
|
||||
|
@ -114,10 +114,10 @@ freshly installed clang, clang++, llvm-config, gmake and coreutils, e.g.:
|
||||
# Depending on your MacOS system + brew version it is either
|
||||
export PATH="/opt/homebrew/opt/llvm/bin:$PATH"
|
||||
# or
|
||||
export PATH="/usr/local/opt/llvm/bin:$PATH"
|
||||
export PATH="/usr/local/opt/llvm/bin:/usr/local/opt/coreutils/libexec/gnubin:$PATH"
|
||||
# you can check with "brew info llvm"
|
||||
|
||||
export PATH="/usr/local/opt/coreutils/libexec/gnubin:/usr/local/bin:$PATH"
|
||||
export PATH="/usr/local/bin:$PATH"
|
||||
export CC=clang
|
||||
export CXX=clang++
|
||||
gmake
|
||||
|
@ -73,7 +73,7 @@ def init(seed):
|
||||
def fuzz_count(buf):
|
||||
return cnt
|
||||
|
||||
def splice_optout()
|
||||
def splice_optout():
|
||||
pass
|
||||
|
||||
def fuzz(buf, add_buf, max_size):
|
||||
@ -198,7 +198,7 @@ def deinit(): # optional for Python
|
||||
This method can be used if you want to send data to the target yourself,
|
||||
e.g. via IPC. This replaces some usage of utils/afl_proxy but requires
|
||||
that you start the target with afl-fuzz.
|
||||
Example: [custom_mutators/examples/custom_send.c](custom_mutators/examples/custom_send.c)
|
||||
Example: [custom_mutators/examples/custom_send.c](../custom_mutators/examples/custom_send.c)
|
||||
|
||||
- `queue_new_entry` (optional):
|
||||
|
||||
|
@ -196,6 +196,19 @@ in the specified file.
|
||||
For more information, see
|
||||
[instrumentation/README.instrument_list.md](../instrumentation/README.instrument_list.md).
|
||||
|
||||
#### INJECTIONS
|
||||
|
||||
This feature is able to find simple injection vulnerabilities in insecure
|
||||
calls to mysql/mariadb/nosql/postgresql/ldap and XSS in libxml2.
|
||||
|
||||
- Setting `AFL_LLVM_INJECTIONS_ALL` will enable all injection hooking
|
||||
|
||||
- Setting `AFL_LLVM_INJECTIONS_SQL` will enable SQL injection hooking
|
||||
|
||||
- Setting `AFL_LLVM_INJECTIONS_LDAP` will enable LDAP injection hooking
|
||||
|
||||
- Setting `AFL_LLVM_INJECTIONS_XSS` will enable XSS injection hooking
|
||||
|
||||
#### LAF-INTEL
|
||||
|
||||
This great feature will split compares into series of single byte comparisons to
|
||||
|
@ -94,8 +94,7 @@ For more information, see
|
||||
|
||||
In FRIDA mode, you can fuzz binary-only targets as easily as with QEMU mode.
|
||||
FRIDA mode is most of the times slightly faster than QEMU mode. It is also
|
||||
newer, lacks COMPCOV, and has the advantage that it works on MacOS (both intel
|
||||
and M1).
|
||||
newer, and has the advantage that it works on MacOS (both intel and M1).
|
||||
|
||||
To build FRIDA mode:
|
||||
|
||||
@ -113,10 +112,6 @@ The mode is approximately 2-5x slower than compile-time instrumentation, and is
|
||||
less conducive to parallelization. But for binary-only fuzzing, it gives a huge
|
||||
speed improvement if it is possible to use.
|
||||
|
||||
If you want to fuzz a binary-only library, then you can fuzz it with frida-gum
|
||||
via frida_mode/. You will have to write a harness to call the target function in
|
||||
the library, use afl-frida.c as a template.
|
||||
|
||||
You can also perform remote fuzzing with frida, e.g., if you want to fuzz on
|
||||
iPhone or Android devices, for this you can use
|
||||
[https://github.com/ttdennis/fpicker/](https://github.com/ttdennis/fpicker/) as
|
||||
@ -302,7 +297,6 @@ some are very hard to set up...
|
||||
* S2E: [https://github.com/S2E](https://github.com/S2E)
|
||||
* TinyInst:
|
||||
[https://github.com/googleprojectzero/TinyInst](https://github.com/googleprojectzero/TinyInst)
|
||||
(Mac/Windows only)
|
||||
* ... please send me any missing that are good
|
||||
|
||||
## Closing words
|
||||
|
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
@ -390,7 +390,7 @@ Consider the [following](test/js/test2.c) test code...
|
||||
--------------------------------------------------------
|
||||
Originally written by Michal Zalewski
|
||||
Copyright 2014 Google Inc. All rights reserved.
|
||||
Copyright 2019-2023 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2024 AFLplusplus Project. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
@ -166,7 +166,7 @@ static void afl_print_env(void) {
|
||||
|
||||
if (fd < 0) {
|
||||
|
||||
FWARNF("Failed to open /proc/self/cmdline, errno: (%d)", errno);
|
||||
FWARNF("Failed to open /proc/self/environ, errno: (%d)", errno);
|
||||
return;
|
||||
|
||||
}
|
||||
@ -174,7 +174,7 @@ static void afl_print_env(void) {
|
||||
ssize_t bytes_read = read(fd, buffer, PROC_MAX - 1);
|
||||
if (bytes_read < 0) {
|
||||
|
||||
FFATAL("Failed to read /proc/self/cmdline, errno: (%d)", errno);
|
||||
FFATAL("Failed to read /proc/self/environ, errno: (%d)", errno);
|
||||
|
||||
}
|
||||
|
||||
|
@ -653,7 +653,7 @@ void ranges_init(void) {
|
||||
/*
|
||||
* After step 4 we have the total ranges to be instrumented, we now subtract
|
||||
* that either from the original ranges of the modules or from the whole
|
||||
* memory if AFL_INST_NO_DYNAMIC_LOAD to configure the stalker.
|
||||
* memory if AFL_FRIDA_INST_NO_DYNAMIC_LOAD to configure the stalker.
|
||||
*/
|
||||
if (ranges_inst_dynamic_load) {
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// Author: Mateusz Jurczyk (mjurczyk@google.com)
|
||||
//
|
||||
// Copyright 2019-2023 Google LLC
|
||||
// Copyright 2019-2024 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
@ -3,7 +3,7 @@
|
||||
--------------------------------------------------------
|
||||
Originally written by Michal Zalewski
|
||||
Copyright 2014 Google Inc. All rights reserved.
|
||||
Copyright 2019-2023 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2024 AFLplusplus Project. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
@ -3,7 +3,7 @@
|
||||
--------------------------------------------------------
|
||||
Originally written by Michal Zalewski
|
||||
Copyright 2014 Google Inc. All rights reserved.
|
||||
Copyright 2019-2023 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2024 AFLplusplus Project. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
@ -3,7 +3,7 @@
|
||||
--------------------------------------------------------
|
||||
Originally written by Michal Zalewski
|
||||
Copyright 2014 Google Inc. All rights reserved.
|
||||
Copyright 2019-2023 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2024 AFLplusplus Project. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
@ -3,7 +3,7 @@
|
||||
--------------------------------------------------------
|
||||
Originally written by Michal Zalewski
|
||||
Copyright 2014 Google Inc. All rights reserved.
|
||||
Copyright 2019-2023 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2024 AFLplusplus Project. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
@ -3,7 +3,7 @@
|
||||
--------------------------------------------------------
|
||||
Originally written by Michal Zalewski
|
||||
Copyright 2014 Google Inc. All rights reserved.
|
||||
Copyright 2019-2023 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2024 AFLplusplus Project. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
@ -3,7 +3,7 @@
|
||||
--------------------------------------------------------
|
||||
Originally written by Michal Zalewski
|
||||
Copyright 2014 Google Inc. All rights reserved.
|
||||
Copyright 2019-2023 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2024 AFLplusplus Project. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
@ -3,7 +3,7 @@
|
||||
--------------------------------------------------------
|
||||
Originally written by Michal Zalewski
|
||||
Copyright 2014 Google Inc. All rights reserved.
|
||||
Copyright 2019-2023 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2024 AFLplusplus Project. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
@ -3,7 +3,7 @@
|
||||
--------------------------------------------------------
|
||||
Originally written by Michal Zalewski
|
||||
Copyright 2014 Google Inc. All rights reserved.
|
||||
Copyright 2019-2023 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2024 AFLplusplus Project. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
@ -3,7 +3,7 @@
|
||||
--------------------------------------------------------
|
||||
Originally written by Michal Zalewski
|
||||
Copyright 2014 Google Inc. All rights reserved.
|
||||
Copyright 2019-2023 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2024 AFLplusplus Project. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
@ -3,7 +3,7 @@
|
||||
--------------------------------------------------------
|
||||
Originally written by Michal Zalewski
|
||||
Copyright 2014 Google Inc. All rights reserved.
|
||||
Copyright 2019-2023 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2024 AFLplusplus Project. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
@ -3,7 +3,7 @@
|
||||
--------------------------------------------------------
|
||||
Originally written by Michal Zalewski
|
||||
Copyright 2014 Google Inc. All rights reserved.
|
||||
Copyright 2019-2023 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2024 AFLplusplus Project. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
# Copyright 2023 AFLplusplus
|
||||
# Copyright 2024 AFLplusplus
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -10,7 +10,7 @@
|
||||
Dominik Maier <mail@dmnk.co>
|
||||
|
||||
Copyright 2016, 2017 Google Inc. All rights reserved.
|
||||
Copyright 2019-2023 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2024 AFLplusplus Project. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
@ -10,7 +10,7 @@
|
||||
Dominik Maier <mail@dmnk.co>
|
||||
|
||||
Copyright 2016, 2017 Google Inc. All rights reserved.
|
||||
Copyright 2019-2023 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2024 AFLplusplus Project. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -149,6 +149,48 @@ struct tainted {
|
||||
|
||||
};
|
||||
|
||||
struct inf_profile {
|
||||
|
||||
u32 inf_skipped_bytes; /* Inference Stage Profiling */
|
||||
u64 inf_execs_cost, inf_time_cost;
|
||||
|
||||
};
|
||||
|
||||
/* ToDo: add cmplog profile as well */
|
||||
struct havoc_profile {
|
||||
|
||||
u32 queued_det_stage, /* Det/Havoc Stage Profiling */
|
||||
queued_havoc_stage, total_queued_det, edge_det_stage, edge_havoc_stage,
|
||||
total_det_edge;
|
||||
|
||||
u64 det_stage_time, havoc_stage_time, total_det_time;
|
||||
|
||||
};
|
||||
|
||||
struct skipdet_entry {
|
||||
|
||||
u8 continue_inf, done_eff;
|
||||
u32 undet_bits, quick_eff_bytes;
|
||||
|
||||
u8 *skip_eff_map, /* we'v finish the eff_map */
|
||||
*done_inf_map; /* some bytes are not done yet */
|
||||
|
||||
};
|
||||
|
||||
struct skipdet_global {
|
||||
|
||||
u8 use_skip_havoc;
|
||||
|
||||
u32 undet_bits_threshold;
|
||||
|
||||
u64 last_cov_undet;
|
||||
|
||||
u8 *virgin_det_bits; /* global fuzzed bits */
|
||||
|
||||
struct inf_profile *inf_prof;
|
||||
|
||||
};
|
||||
|
||||
struct queue_entry {
|
||||
|
||||
u8 *fname; /* File name for the test case */
|
||||
@ -203,6 +245,8 @@ struct queue_entry {
|
||||
|
||||
struct queue_entry *mother; /* queue entry this based on */
|
||||
|
||||
struct skipdet_entry *skipdet_e;
|
||||
|
||||
};
|
||||
|
||||
struct extra_data {
|
||||
@ -247,6 +291,8 @@ enum {
|
||||
/* 19 */ STAGE_CUSTOM_MUTATOR,
|
||||
/* 20 */ STAGE_COLORIZATION,
|
||||
/* 21 */ STAGE_ITS,
|
||||
/* 22 */ STAGE_INF,
|
||||
/* 23 */ STAGE_QUICK,
|
||||
|
||||
STAGE_NUM_MAX
|
||||
|
||||
@ -782,6 +828,11 @@ typedef struct afl_state {
|
||||
* is too large) */
|
||||
struct queue_entry **q_testcase_cache;
|
||||
|
||||
/* Global Profile Data for deterministic/havoc-splice stage */
|
||||
struct havoc_profile *havoc_prof;
|
||||
|
||||
struct skipdet_global *skipdet_g;
|
||||
|
||||
#ifdef INTROSPECTION
|
||||
char mutation[8072];
|
||||
char m_tmp[4096];
|
||||
@ -1232,6 +1283,13 @@ AFL_RAND_RETURN rand_next(afl_state_t *afl);
|
||||
/* probability between 0.0 and 1.0 */
|
||||
double rand_next_percent(afl_state_t *afl);
|
||||
|
||||
/* SkipDet Functions */
|
||||
|
||||
u8 skip_deterministic_stage(afl_state_t *, u8 *, u8 *, u32, u64);
|
||||
u8 is_det_timeout(u64, u8);
|
||||
|
||||
void plot_profile_data(afl_state_t *, struct queue_entry *);
|
||||
|
||||
/**** Inline routines ****/
|
||||
|
||||
/* Generate a random number (from 0 to limit - 1). This may
|
||||
|
@ -1082,6 +1082,7 @@ u32 mutation_strategy_exploration_binary[MUT_STRATEGY_ARRAY_SIZE] = {
|
||||
MUT_CLONE_COPY,
|
||||
MUT_CLONE_COPY,
|
||||
MUT_CLONE_COPY,
|
||||
MUT_CLONE_COPY,
|
||||
MUT_CLONE_FIXED,
|
||||
MUT_CLONE_FIXED,
|
||||
MUT_CLONE_FIXED,
|
||||
@ -2490,12 +2491,13 @@ inline u32 afl_mutate(afl_state_t *afl, u8 *buf, u32 len, u32 steps,
|
||||
|
||||
case MUT_INSERTASCIINUM: {
|
||||
|
||||
u32 len = 1 + rand_below(afl, 8);
|
||||
u32 ins_len = 1 + rand_below(afl, 8);
|
||||
u32 pos = rand_below(afl, len);
|
||||
|
||||
/* Insert ascii number. */
|
||||
if (unlikely(len < pos + len)) {
|
||||
if (unlikely(len < pos + ins_len)) {
|
||||
|
||||
// no retry if we have a small input
|
||||
if (unlikely(len < 8)) {
|
||||
|
||||
break;
|
||||
@ -2511,7 +2513,20 @@ inline u32 afl_mutate(afl_state_t *afl, u8 *buf, u32 len, u32 steps,
|
||||
u64 val = rand_next(afl);
|
||||
char numbuf[32];
|
||||
snprintf(numbuf, sizeof(numbuf), "%llu", val);
|
||||
memcpy(buf + pos, numbuf, len);
|
||||
size_t val_len = strlen(numbuf), off;
|
||||
|
||||
if (ins_len > val_len) {
|
||||
|
||||
ins_len = val_len;
|
||||
off = 0;
|
||||
|
||||
} else {
|
||||
|
||||
off = val_len - ins_len;
|
||||
|
||||
}
|
||||
|
||||
memcpy(buf + pos, numbuf + off, ins_len);
|
||||
|
||||
break;
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
Dominik Maier <mail@dmnk.co>
|
||||
|
||||
Copyright 2016, 2017 Google Inc. All rights reserved.
|
||||
Copyright 2019-2023 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2024 AFLplusplus Project. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
@ -10,7 +10,7 @@
|
||||
Dominik Maier <mail@dmnk.co>
|
||||
|
||||
Copyright 2016, 2017 Google Inc. All rights reserved.
|
||||
Copyright 2019-2023 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2024 AFLplusplus Project. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
@ -12,7 +12,7 @@
|
||||
Dominik Maier <mail@dmnk.co>
|
||||
|
||||
Copyright 2016, 2017 Google Inc. All rights reserved.
|
||||
Copyright 2019-2023 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2024 AFLplusplus Project. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
@ -10,7 +10,7 @@
|
||||
Dominik Maier <mail@dmnk.co>
|
||||
|
||||
Copyright 2016, 2017 Google Inc. All rights reserved.
|
||||
Copyright 2019-2023 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2024 AFLplusplus Project. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
@ -10,7 +10,7 @@
|
||||
Heiko Eissfeldt <heiko.eissfeldt@hexco.de>,
|
||||
|
||||
Copyright 2016, 2017 Google Inc. All rights reserved.
|
||||
Copyright 2019-2023 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2024 AFLplusplus Project. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -26,7 +26,7 @@
|
||||
/* Version string: */
|
||||
|
||||
// c = release, a = volatile github dev, e = experimental branch
|
||||
#define VERSION "++4.09c"
|
||||
#define VERSION "++4.10c"
|
||||
|
||||
/******************************************************
|
||||
* *
|
||||
@ -52,6 +52,18 @@
|
||||
/* Default file permission umode when creating files (default: 0600) */
|
||||
#define DEFAULT_PERMISSION 0600
|
||||
|
||||
/* SkipDet's global configuration */
|
||||
|
||||
#define MINIMAL_BLOCK_SIZE 64
|
||||
#define SMALL_DET_TIME (60 * 1000 * 1000U)
|
||||
#define MAXIMUM_INF_EXECS (16 * 1024U)
|
||||
#define MAXIMUM_QUICK_EFF_EXECS (64 * 1024U)
|
||||
#define THRESHOLD_DEC_TIME (20 * 60 * 1000U)
|
||||
|
||||
/* Set the Prob of selecting eff_bytes 3 times more than original,
|
||||
Now disabled */
|
||||
#define EFF_HAVOC_RATE 3
|
||||
|
||||
/* CMPLOG/REDQUEEN TUNING
|
||||
*
|
||||
* Here you can modify tuning and solving options for CMPLOG.
|
||||
|
@ -10,7 +10,7 @@
|
||||
Dominik Maier <mail@dmnk.co>
|
||||
|
||||
Copyright 2016, 2017 Google Inc. All rights reserved.
|
||||
Copyright 2019-2023 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2024 AFLplusplus Project. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
316
include/envs.h
316
include/envs.h
@ -16,250 +16,104 @@ static char *afl_environment_deprecated[] = {
|
||||
|
||||
static char *afl_environment_variables[] = {
|
||||
|
||||
"AFL_ALIGNED_ALLOC",
|
||||
"AFL_ALLOW_TMP",
|
||||
"AFL_ANALYZE_HEX",
|
||||
"AFL_AS",
|
||||
"AFL_AUTORESUME",
|
||||
"AFL_AS_FORCE_INSTRUMENT",
|
||||
"AFL_BENCH_JUST_ONE",
|
||||
"AFL_BENCH_UNTIL_CRASH",
|
||||
"AFL_CAL_FAST",
|
||||
"AFL_CC",
|
||||
"AFL_CC_COMPILER",
|
||||
"AFL_CMIN_ALLOW_ANY",
|
||||
"AFL_CMIN_CRASHES_ONLY",
|
||||
"AFL_CMPLOG_ONLY_NEW",
|
||||
"AFL_CODE_END",
|
||||
"AFL_CODE_START",
|
||||
"AFL_COMPCOV_BINNAME",
|
||||
"AFL_COMPCOV_LEVEL",
|
||||
"AFL_CRASH_EXITCODE",
|
||||
"AFL_CRASHING_SEEDS_AS_NEW_CRASH",
|
||||
"AFL_CUSTOM_MUTATOR_LIBRARY",
|
||||
"AFL_CUSTOM_MUTATOR_ONLY",
|
||||
"AFL_CUSTOM_INFO_PROGRAM",
|
||||
"AFL_CUSTOM_INFO_PROGRAM_ARGV",
|
||||
"AFL_CUSTOM_INFO_PROGRAM_INPUT",
|
||||
"AFL_CUSTOM_INFO_OUT",
|
||||
"AFL_CXX",
|
||||
"AFL_CYCLE_SCHEDULES",
|
||||
"AFL_DEBUG",
|
||||
"AFL_DEBUG_CHILD",
|
||||
"AFL_DEBUG_GDB",
|
||||
"AFL_DEBUG_UNICORN",
|
||||
"AFL_DISABLE_TRIM",
|
||||
"AFL_DISABLE_LLVM_INSTRUMENTATION",
|
||||
"AFL_DONT_OPTIMIZE",
|
||||
"AFL_DRIVER_STDERR_DUPLICATE_FILENAME",
|
||||
"AFL_DUMB_FORKSRV",
|
||||
"AFL_EARLY_FORKSERVER",
|
||||
"AFL_ENTRYPOINT",
|
||||
"AFL_EXIT_WHEN_DONE",
|
||||
"AFL_EXIT_ON_TIME",
|
||||
"AFL_EXIT_ON_SEED_ISSUES",
|
||||
"AFL_FAST_CAL",
|
||||
"AFL_FINAL_SYNC",
|
||||
"AFL_FORCE_UI",
|
||||
"AFL_FRIDA_DEBUG_MAPS",
|
||||
"AFL_FRIDA_DRIVER_NO_HOOK",
|
||||
"AFL_FRIDA_EXCLUDE_RANGES",
|
||||
"AFL_FRIDA_INST_CACHE_SIZE",
|
||||
"AFL_FRIDA_INST_COVERAGE_ABSOLUTE",
|
||||
"AFL_FRIDA_INST_COVERAGE_FILE",
|
||||
"AFL_FRIDA_INST_DEBUG_FILE",
|
||||
"AFL_FRIDA_INST_INSN",
|
||||
"AFL_FRIDA_INST_JIT",
|
||||
"AFL_FRIDA_INST_NO_CACHE",
|
||||
"AFL_FRIDA_INST_NO_DYNAMIC_LOAD",
|
||||
"AFL_FRIDA_INST_NO_OPTIMIZE",
|
||||
"AFL_FRIDA_INST_NO_PREFETCH",
|
||||
"AFL_FRIDA_INST_NO_PREFETCH_BACKPATCH",
|
||||
"AFL_ALIGNED_ALLOC", "AFL_ALLOW_TMP", "AFL_ANALYZE_HEX", "AFL_AS",
|
||||
"AFL_AUTORESUME", "AFL_AS_FORCE_INSTRUMENT", "AFL_BENCH_JUST_ONE",
|
||||
"AFL_BENCH_UNTIL_CRASH", "AFL_CAL_FAST", "AFL_CC", "AFL_CC_COMPILER",
|
||||
"AFL_CMIN_ALLOW_ANY", "AFL_CMIN_CRASHES_ONLY", "AFL_CMPLOG_ONLY_NEW",
|
||||
"AFL_CODE_END", "AFL_CODE_START", "AFL_COMPCOV_BINNAME",
|
||||
"AFL_COMPCOV_LEVEL", "AFL_CRASH_EXITCODE",
|
||||
"AFL_CRASHING_SEEDS_AS_NEW_CRASH", "AFL_CUSTOM_MUTATOR_LIBRARY",
|
||||
"AFL_CUSTOM_MUTATOR_ONLY", "AFL_CUSTOM_INFO_PROGRAM",
|
||||
"AFL_CUSTOM_INFO_PROGRAM_ARGV", "AFL_CUSTOM_INFO_PROGRAM_INPUT",
|
||||
"AFL_CUSTOM_INFO_OUT", "AFL_CXX", "AFL_CYCLE_SCHEDULES", "AFL_DEBUG",
|
||||
"AFL_DEBUG_CHILD", "AFL_DEBUG_GDB", "AFL_DEBUG_UNICORN", "AFL_DISABLE_TRIM",
|
||||
"AFL_DISABLE_LLVM_INSTRUMENTATION", "AFL_DONT_OPTIMIZE",
|
||||
"AFL_DRIVER_STDERR_DUPLICATE_FILENAME", "AFL_DUMB_FORKSRV",
|
||||
"AFL_EARLY_FORKSERVER", "AFL_ENTRYPOINT", "AFL_EXIT_WHEN_DONE",
|
||||
"AFL_EXIT_ON_TIME", "AFL_EXIT_ON_SEED_ISSUES", "AFL_FAST_CAL",
|
||||
"AFL_FINAL_SYNC", "AFL_FORCE_UI", "AFL_FRIDA_DEBUG_MAPS",
|
||||
"AFL_FRIDA_DRIVER_NO_HOOK", "AFL_FRIDA_EXCLUDE_RANGES",
|
||||
"AFL_FRIDA_INST_CACHE_SIZE", "AFL_FRIDA_INST_COVERAGE_ABSOLUTE",
|
||||
"AFL_FRIDA_INST_COVERAGE_FILE", "AFL_FRIDA_INST_DEBUG_FILE",
|
||||
"AFL_FRIDA_INST_INSN", "AFL_FRIDA_INST_JIT", "AFL_FRIDA_INST_NO_CACHE",
|
||||
"AFL_FRIDA_INST_NO_DYNAMIC_LOAD", "AFL_FRIDA_INST_NO_OPTIMIZE",
|
||||
"AFL_FRIDA_INST_NO_PREFETCH", "AFL_FRIDA_INST_NO_PREFETCH_BACKPATCH",
|
||||
"AFL_FRIDA_INST_NO_SUPPRESS"
|
||||
"AFL_FRIDA_INST_RANGES",
|
||||
"AFL_FRIDA_INST_REGS_FILE",
|
||||
"AFL_FRIDA_INST_SEED",
|
||||
"AFL_FRIDA_INST_TRACE",
|
||||
"AFL_FRIDA_INST_TRACE_UNIQUE",
|
||||
"AFL_FRIDA_INST_UNSTABLE_COVERAGE_FILE",
|
||||
"AFL_FRIDA_JS_SCRIPT",
|
||||
"AFL_FRIDA_OUTPUT_STDOUT",
|
||||
"AFL_FRIDA_OUTPUT_STDERR",
|
||||
"AFL_FRIDA_PERSISTENT_ADDR",
|
||||
"AFL_FRIDA_PERSISTENT_CNT",
|
||||
"AFL_FRIDA_PERSISTENT_DEBUG",
|
||||
"AFL_FRIDA_PERSISTENT_HOOK",
|
||||
"AFL_FRIDA_PERSISTENT_RET",
|
||||
"AFL_FRIDA_STALKER_ADJACENT_BLOCKS",
|
||||
"AFL_FRIDA_STALKER_IC_ENTRIES",
|
||||
"AFL_FRIDA_STALKER_NO_BACKPATCH",
|
||||
"AFL_FRIDA_STATS_FILE",
|
||||
"AFL_FRIDA_STATS_INTERVAL",
|
||||
"AFL_FRIDA_TRACEABLE",
|
||||
"AFL_FRIDA_INST_REGS_FILE", "AFL_FRIDA_INST_SEED", "AFL_FRIDA_INST_TRACE",
|
||||
"AFL_FRIDA_INST_TRACE_UNIQUE", "AFL_FRIDA_INST_UNSTABLE_COVERAGE_FILE",
|
||||
"AFL_FRIDA_JS_SCRIPT", "AFL_FRIDA_OUTPUT_STDOUT", "AFL_FRIDA_OUTPUT_STDERR",
|
||||
"AFL_FRIDA_PERSISTENT_ADDR", "AFL_FRIDA_PERSISTENT_CNT",
|
||||
"AFL_FRIDA_PERSISTENT_DEBUG", "AFL_FRIDA_PERSISTENT_HOOK",
|
||||
"AFL_FRIDA_PERSISTENT_RET", "AFL_FRIDA_STALKER_ADJACENT_BLOCKS",
|
||||
"AFL_FRIDA_STALKER_IC_ENTRIES", "AFL_FRIDA_STALKER_NO_BACKPATCH",
|
||||
"AFL_FRIDA_STATS_FILE", "AFL_FRIDA_STATS_INTERVAL", "AFL_FRIDA_TRACEABLE",
|
||||
"AFL_FRIDA_VERBOSE",
|
||||
"AFL_FUZZER_ARGS", // oss-fuzz
|
||||
"AFL_FUZZER_STATS_UPDATE_INTERVAL",
|
||||
"AFL_GDB",
|
||||
"AFL_GCC_ALLOWLIST",
|
||||
"AFL_GCC_DENYLIST",
|
||||
"AFL_GCC_BLOCKLIST",
|
||||
"AFL_GCC_INSTRUMENT_FILE",
|
||||
"AFL_GCC_OUT_OF_LINE",
|
||||
"AFL_GCC_SKIP_NEVERZERO",
|
||||
"AFL_GCJ",
|
||||
"AFL_HANG_TMOUT",
|
||||
"AFL_FORKSRV_INIT_TMOUT",
|
||||
"AFL_HARDEN",
|
||||
"AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES",
|
||||
"AFL_IGNORE_PROBLEMS",
|
||||
"AFL_IGNORE_PROBLEMS_COVERAGE",
|
||||
"AFL_IGNORE_SEED_PROBLEMS",
|
||||
"AFL_IGNORE_TIMEOUTS",
|
||||
"AFL_IGNORE_UNKNOWN_ENVS",
|
||||
"AFL_IMPORT_FIRST",
|
||||
"AFL_INPUT_LEN_MIN",
|
||||
"AFL_INPUT_LEN_MAX",
|
||||
"AFL_INST_LIBS",
|
||||
"AFL_INST_RATIO",
|
||||
"AFL_KEEP_TIMEOUTS",
|
||||
"AFL_KILL_SIGNAL",
|
||||
"AFL_FORK_SERVER_KILL_SIGNAL",
|
||||
"AFL_KEEP_TRACES",
|
||||
"AFL_KEEP_ASSEMBLY",
|
||||
"AFL_LD_HARD_FAIL",
|
||||
"AFL_LD_LIMIT_MB",
|
||||
"AFL_LD_NO_CALLOC_OVER",
|
||||
"AFL_LD_PASSTHROUGH",
|
||||
"AFL_REAL_LD",
|
||||
"AFL_LD_PRELOAD",
|
||||
"AFL_LD_VERBOSE",
|
||||
"AFL_LLVM_ALLOWLIST",
|
||||
"AFL_LLVM_DENYLIST",
|
||||
"AFL_LLVM_BLOCKLIST",
|
||||
"AFL_CMPLOG",
|
||||
"AFL_LLVM_CMPLOG",
|
||||
"AFL_GCC_CMPLOG",
|
||||
"AFL_LLVM_INSTRIM",
|
||||
"AFL_LLVM_CALLER",
|
||||
"AFL_LLVM_CTX",
|
||||
"AFL_LLVM_CTX_K",
|
||||
"AFL_LLVM_DICT2FILE",
|
||||
"AFL_LLVM_DICT2FILE_NO_MAIN",
|
||||
"AFL_LLVM_DOCUMENT_IDS",
|
||||
"AFL_LLVM_INSTRIM_LOOPHEAD",
|
||||
"AFL_LLVM_INSTRUMENT",
|
||||
"AFL_LLVM_LTO_AUTODICTIONARY",
|
||||
"AFL_LLVM_AUTODICTIONARY",
|
||||
"AFL_FUZZER_STATS_UPDATE_INTERVAL", "AFL_GDB", "AFL_GCC_ALLOWLIST",
|
||||
"AFL_GCC_DENYLIST", "AFL_GCC_BLOCKLIST", "AFL_GCC_INSTRUMENT_FILE",
|
||||
"AFL_GCC_OUT_OF_LINE", "AFL_GCC_SKIP_NEVERZERO", "AFL_GCJ",
|
||||
"AFL_HANG_TMOUT", "AFL_FORKSRV_INIT_TMOUT", "AFL_HARDEN",
|
||||
"AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES", "AFL_IGNORE_PROBLEMS",
|
||||
"AFL_IGNORE_PROBLEMS_COVERAGE", "AFL_IGNORE_SEED_PROBLEMS",
|
||||
"AFL_IGNORE_TIMEOUTS", "AFL_IGNORE_UNKNOWN_ENVS", "AFL_IMPORT_FIRST",
|
||||
"AFL_INPUT_LEN_MIN", "AFL_INPUT_LEN_MAX", "AFL_INST_LIBS", "AFL_INST_RATIO",
|
||||
"AFL_KEEP_TIMEOUTS", "AFL_KILL_SIGNAL", "AFL_FORK_SERVER_KILL_SIGNAL",
|
||||
"AFL_KEEP_TRACES", "AFL_KEEP_ASSEMBLY", "AFL_LD_HARD_FAIL",
|
||||
"AFL_LD_LIMIT_MB", "AFL_LD_NO_CALLOC_OVER", "AFL_LD_PASSTHROUGH",
|
||||
"AFL_REAL_LD", "AFL_LD_PRELOAD", "AFL_LD_VERBOSE", "AFL_LLVM_ALLOWLIST",
|
||||
"AFL_LLVM_DENYLIST", "AFL_LLVM_BLOCKLIST", "AFL_CMPLOG", "AFL_LLVM_CMPLOG",
|
||||
"AFL_GCC_CMPLOG", "AFL_LLVM_INSTRIM", "AFL_LLVM_CALLER", "AFL_LLVM_CTX",
|
||||
"AFL_LLVM_CTX_K", "AFL_LLVM_DICT2FILE", "AFL_LLVM_DICT2FILE_NO_MAIN",
|
||||
"AFL_LLVM_DOCUMENT_IDS", "AFL_LLVM_INSTRIM_LOOPHEAD", "AFL_LLVM_INSTRUMENT",
|
||||
"AFL_LLVM_LTO_AUTODICTIONARY", "AFL_LLVM_AUTODICTIONARY",
|
||||
"AFL_LLVM_SKIPSINGLEBLOCK",
|
||||
"AFL_LLVM_INSTRIM_SKIPSINGLEBLOCK",
|
||||
"AFL_LLVM_LAF_SPLIT_COMPARES",
|
||||
"AFL_LLVM_LAF_SPLIT_COMPARES_BITW",
|
||||
"AFL_LLVM_LAF_SPLIT_FLOATS",
|
||||
"AFL_LLVM_LAF_SPLIT_SWITCHES",
|
||||
"AFL_LLVM_LAF_ALL",
|
||||
"AFL_LLVM_LAF_TRANSFORM_COMPARES",
|
||||
"AFL_LLVM_MAP_ADDR",
|
||||
"AFL_LLVM_MAP_DYNAMIC",
|
||||
"AFL_LLVM_NGRAM_SIZE",
|
||||
"AFL_NGRAM_SIZE",
|
||||
"AFL_LLVM_NO_RPATH",
|
||||
"AFL_LLVM_NOT_ZERO",
|
||||
"AFL_LLVM_INSTRUMENT_FILE",
|
||||
"AFL_LLVM_THREADSAFE_INST",
|
||||
"AFL_LLVM_SKIP_NEVERZERO",
|
||||
"AFL_NO_AFFINITY",
|
||||
"AFL_TRY_AFFINITY",
|
||||
"AFL_LLVM_LTO_DONTWRITEID",
|
||||
// Marker: ADD_TO_INJECTIONS
|
||||
"AFL_LLVM_INJECTIONS_ALL", "AFL_LLVM_INJECTIONS_SQL",
|
||||
"AFL_LLVM_INJECTIONS_LDAP", "AFL_LLVM_INJECTIONS_XSS",
|
||||
"AFL_LLVM_INSTRIM_SKIPSINGLEBLOCK", "AFL_LLVM_LAF_SPLIT_COMPARES",
|
||||
"AFL_LLVM_LAF_SPLIT_COMPARES_BITW", "AFL_LLVM_LAF_SPLIT_FLOATS",
|
||||
"AFL_LLVM_LAF_SPLIT_SWITCHES", "AFL_LLVM_LAF_ALL",
|
||||
"AFL_LLVM_LAF_TRANSFORM_COMPARES", "AFL_LLVM_MAP_ADDR",
|
||||
"AFL_LLVM_MAP_DYNAMIC", "AFL_LLVM_NGRAM_SIZE", "AFL_NGRAM_SIZE",
|
||||
"AFL_LLVM_NO_RPATH", "AFL_LLVM_NOT_ZERO", "AFL_LLVM_INSTRUMENT_FILE",
|
||||
"AFL_LLVM_THREADSAFE_INST", "AFL_LLVM_SKIP_NEVERZERO", "AFL_NO_AFFINITY",
|
||||
"AFL_TRY_AFFINITY", "AFL_LLVM_LTO_DONTWRITEID",
|
||||
"AFL_LLVM_LTO_SKIPINIT"
|
||||
"AFL_LLVM_LTO_STARTID",
|
||||
"AFL_FUZZER_LOOPCOUNT",
|
||||
"AFL_NO_ARITH",
|
||||
"AFL_NO_AUTODICT",
|
||||
"AFL_NO_BUILTIN",
|
||||
"AFL_FUZZER_LOOPCOUNT", "AFL_NO_ARITH", "AFL_NO_AUTODICT", "AFL_NO_BUILTIN",
|
||||
#if defined USE_COLOR && !defined ALWAYS_COLORED
|
||||
"AFL_NO_COLOR",
|
||||
"AFL_NO_COLOUR",
|
||||
"AFL_NO_COLOR", "AFL_NO_COLOUR",
|
||||
#endif
|
||||
"AFL_NO_CPU_RED",
|
||||
"AFL_NO_CFG_FUZZING", // afl.rs rust crate option
|
||||
"AFL_NO_CRASH_README",
|
||||
"AFL_NO_FORKSRV",
|
||||
"AFL_NO_UI",
|
||||
"AFL_NO_PYTHON",
|
||||
"AFL_NO_STARTUP_CALIBRATION",
|
||||
"AFL_NO_WARN_INSTABILITY",
|
||||
"AFL_UNTRACER_FILE",
|
||||
"AFL_LLVM_USE_TRACE_PC",
|
||||
"AFL_MAP_SIZE",
|
||||
"AFL_MAPSIZE",
|
||||
"AFL_NO_CRASH_README", "AFL_NO_FORKSRV", "AFL_NO_UI", "AFL_NO_PYTHON",
|
||||
"AFL_NO_STARTUP_CALIBRATION", "AFL_NO_WARN_INSTABILITY",
|
||||
"AFL_UNTRACER_FILE", "AFL_LLVM_USE_TRACE_PC", "AFL_MAP_SIZE", "AFL_MAPSIZE",
|
||||
"AFL_MAX_DET_EXTRAS",
|
||||
"AFL_NO_X86", // not really an env but we dont want to warn on it
|
||||
"AFL_NOOPT",
|
||||
"AFL_NYX_AUX_SIZE",
|
||||
"AFL_NYX_DISABLE_SNAPSHOT_MODE",
|
||||
"AFL_NYX_LOG",
|
||||
"AFL_NYX_REUSE_SNAPSHOT",
|
||||
"AFL_PASSTHROUGH",
|
||||
"AFL_PATH",
|
||||
"AFL_PERFORMANCE_FILE",
|
||||
"AFL_PERSISTENT_RECORD",
|
||||
"AFL_POST_PROCESS_KEEP_ORIGINAL",
|
||||
"AFL_PRELOAD",
|
||||
"AFL_TARGET_ENV",
|
||||
"AFL_PYTHON_MODULE",
|
||||
"AFL_QEMU_CUSTOM_BIN",
|
||||
"AFL_QEMU_COMPCOV",
|
||||
"AFL_QEMU_COMPCOV_DEBUG",
|
||||
"AFL_QEMU_DEBUG_MAPS",
|
||||
"AFL_QEMU_DISABLE_CACHE",
|
||||
"AFL_QEMU_DRIVER_NO_HOOK",
|
||||
"AFL_QEMU_FORCE_DFL",
|
||||
"AFL_QEMU_PERSISTENT_ADDR",
|
||||
"AFL_QEMU_PERSISTENT_CNT",
|
||||
"AFL_QEMU_PERSISTENT_GPR",
|
||||
"AFL_QEMU_PERSISTENT_HOOK",
|
||||
"AFL_QEMU_PERSISTENT_MEM",
|
||||
"AFL_QEMU_PERSISTENT_RET",
|
||||
"AFL_QEMU_PERSISTENT_RETADDR_OFFSET",
|
||||
"AFL_QEMU_PERSISTENT_EXITS",
|
||||
"AFL_QEMU_INST_RANGES",
|
||||
"AFL_QEMU_EXCLUDE_RANGES",
|
||||
"AFL_QEMU_SNAPSHOT",
|
||||
"AFL_QEMU_TRACK_UNSTABLE",
|
||||
"AFL_QUIET",
|
||||
"AFL_RANDOM_ALLOC_CANARY",
|
||||
"AFL_REAL_PATH",
|
||||
"AFL_SHUFFLE_QUEUE",
|
||||
"AFL_SKIP_BIN_CHECK",
|
||||
"AFL_SKIP_CPUFREQ",
|
||||
"AFL_SKIP_CRASHES",
|
||||
"AFL_SKIP_OSSFUZZ",
|
||||
"AFL_STATSD",
|
||||
"AFL_STATSD_HOST",
|
||||
"AFL_STATSD_PORT",
|
||||
"AFL_STATSD_TAGS_FLAVOR",
|
||||
"AFL_SYNC_TIME",
|
||||
"AFL_TESTCACHE_SIZE",
|
||||
"AFL_TESTCACHE_ENTRIES",
|
||||
"AFL_TMIN_EXACT",
|
||||
"AFL_TMPDIR",
|
||||
"AFL_TOKEN_FILE",
|
||||
"AFL_TRACE_PC",
|
||||
"AFL_USE_ASAN",
|
||||
"AFL_USE_MSAN",
|
||||
"AFL_USE_TRACE_PC",
|
||||
"AFL_USE_UBSAN",
|
||||
"AFL_USE_TSAN",
|
||||
"AFL_USE_CFISAN",
|
||||
"AFL_USE_LSAN",
|
||||
"AFL_WINE_PATH",
|
||||
"AFL_NO_SNAPSHOT",
|
||||
"AFL_EXPAND_HAVOC_NOW",
|
||||
"AFL_USE_FASAN",
|
||||
"AFL_USE_QASAN",
|
||||
"AFL_PRINT_FILENAMES",
|
||||
"AFL_PIZZA_MODE",
|
||||
NULL
|
||||
"AFL_NOOPT", "AFL_NYX_AUX_SIZE", "AFL_NYX_DISABLE_SNAPSHOT_MODE",
|
||||
"AFL_NYX_LOG", "AFL_NYX_REUSE_SNAPSHOT", "AFL_PASSTHROUGH", "AFL_PATH",
|
||||
"AFL_PERFORMANCE_FILE", "AFL_PERSISTENT_RECORD",
|
||||
"AFL_POST_PROCESS_KEEP_ORIGINAL", "AFL_PRELOAD", "AFL_TARGET_ENV",
|
||||
"AFL_PYTHON_MODULE", "AFL_QEMU_CUSTOM_BIN", "AFL_QEMU_COMPCOV",
|
||||
"AFL_QEMU_COMPCOV_DEBUG", "AFL_QEMU_DEBUG_MAPS", "AFL_QEMU_DISABLE_CACHE",
|
||||
"AFL_QEMU_DRIVER_NO_HOOK", "AFL_QEMU_FORCE_DFL", "AFL_QEMU_PERSISTENT_ADDR",
|
||||
"AFL_QEMU_PERSISTENT_CNT", "AFL_QEMU_PERSISTENT_GPR",
|
||||
"AFL_QEMU_PERSISTENT_HOOK", "AFL_QEMU_PERSISTENT_MEM",
|
||||
"AFL_QEMU_PERSISTENT_RET", "AFL_QEMU_PERSISTENT_RETADDR_OFFSET",
|
||||
"AFL_QEMU_PERSISTENT_EXITS", "AFL_QEMU_INST_RANGES",
|
||||
"AFL_QEMU_EXCLUDE_RANGES", "AFL_QEMU_SNAPSHOT", "AFL_QEMU_TRACK_UNSTABLE",
|
||||
"AFL_QUIET", "AFL_RANDOM_ALLOC_CANARY", "AFL_REAL_PATH",
|
||||
"AFL_SHUFFLE_QUEUE", "AFL_SKIP_BIN_CHECK", "AFL_SKIP_CPUFREQ",
|
||||
"AFL_SKIP_CRASHES", "AFL_SKIP_OSSFUZZ", "AFL_STATSD", "AFL_STATSD_HOST",
|
||||
"AFL_STATSD_PORT", "AFL_STATSD_TAGS_FLAVOR", "AFL_SYNC_TIME",
|
||||
"AFL_TESTCACHE_SIZE", "AFL_TESTCACHE_ENTRIES", "AFL_TMIN_EXACT",
|
||||
"AFL_TMPDIR", "AFL_TOKEN_FILE", "AFL_TRACE_PC", "AFL_USE_ASAN",
|
||||
"AFL_USE_MSAN", "AFL_USE_TRACE_PC", "AFL_USE_UBSAN", "AFL_USE_TSAN",
|
||||
"AFL_USE_CFISAN", "AFL_USE_LSAN", "AFL_WINE_PATH", "AFL_NO_SNAPSHOT",
|
||||
"AFL_EXPAND_HAVOC_NOW", "AFL_USE_FASAN", "AFL_USE_QASAN",
|
||||
"AFL_PRINT_FILENAMES", "AFL_PIZZA_MODE", NULL
|
||||
|
||||
};
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
Dominik Maier <mail@dmnk.co>>
|
||||
|
||||
Copyright 2016, 2017 Google Inc. All rights reserved.
|
||||
Copyright 2019-2023 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2024 AFLplusplus Project. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -126,7 +126,8 @@ typedef struct afl_forkserver {
|
||||
u8 *out_file, /* File to fuzz, if any */
|
||||
*target_path; /* Path of the target */
|
||||
|
||||
FILE *plot_file; /* Gnuplot output file */
|
||||
FILE *plot_file, /* Gnuplot output file */
|
||||
*det_plot_file;
|
||||
|
||||
/* Note: last_run_timed_out is u32 to send it to the child as 4 byte array */
|
||||
u32 last_run_timed_out; /* Traced process timed out? */
|
||||
|
@ -15,7 +15,7 @@
|
||||
Other code written by Michal Zalewski
|
||||
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
Copyright 2019-2023 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2024 AFLplusplus Project. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
@ -10,7 +10,7 @@
|
||||
Dominik Maier <mail@dmnk.co>
|
||||
|
||||
Copyright 2016, 2017 Google Inc. All rights reserved.
|
||||
Copyright 2019-2023 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2024 AFLplusplus Project. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
@ -12,7 +12,7 @@
|
||||
Dominik Maier <mail@dmnk.co>
|
||||
|
||||
Copyright 2016, 2017 Google Inc. All rights reserved.
|
||||
Copyright 2019-2023 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2024 AFLplusplus Project. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
@ -12,7 +12,7 @@
|
||||
Dominik Maier <mail@dmnk.co>
|
||||
|
||||
Copyright 2016, 2017 Google Inc. All rights reserved.
|
||||
Copyright 2019-2023 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2024 AFLplusplus Project. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
@ -10,7 +10,7 @@
|
||||
Dominik Maier <mail@dmnk.co>
|
||||
|
||||
Copyright 2016, 2017 Google Inc. All rights reserved.
|
||||
Copyright 2019-2023 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2024 AFLplusplus Project. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* xxHash - Extremely Fast Hash algorithm
|
||||
* Header File
|
||||
* Copyright (C) 2012-2023 Yann Collet
|
||||
* Copyright (C) 2012-2024 Yann Collet
|
||||
*
|
||||
* BSD 2-Clause License (https://www.opensource.org/licenses/bsd-license.php)
|
||||
*
|
||||
|
7
injections.dic
Normal file
7
injections.dic
Normal file
@ -0,0 +1,7 @@
|
||||
"1'\" OR \"1\"=\"1"
|
||||
"1\"' OR '1'='1"
|
||||
"'\"><FUZZ"
|
||||
"*)(FUZZ=*))(|"
|
||||
"\";FUZZ;\""
|
||||
"';FUZZ;'"
|
||||
"$(FUZZ)"
|
48
instrumentation/README.injections.md
Normal file
48
instrumentation/README.injections.md
Normal file
@ -0,0 +1,48 @@
|
||||
# Injection fuzzing
|
||||
|
||||
Coverage guided fuzzing so far is only able to detect crashes, so usually
|
||||
memory corruption issues, or - if implemented by hand in the harness -
|
||||
invariants.
|
||||
|
||||
This is a proof-of-concept implementation to additionally hunt for injection
|
||||
vulnerabilities.
|
||||
It works by instrumenting calls to specific functions and parsing the
|
||||
query parameter for a specific unescaped dictionary string, and if detected,
|
||||
crashes the target.
|
||||
|
||||
This has a very low false positive rate.
|
||||
But obviously this can only find injection vulnerailities that are suspectible
|
||||
to this specific (but most common) issue. Hence in a rare kind of injection
|
||||
vulnerability this won't find the bug - and be a false negative.
|
||||
But this can be tweaked by the user - see the HOW TO MODIFY section below.
|
||||
|
||||
## How to use
|
||||
|
||||
Set one or more of the following environment variables for **compiling**
|
||||
the target and - *this is important* - when **fuzzing** the target:
|
||||
|
||||
- `AFL_LLVM_INJECTIONS_SQL`
|
||||
- `AFL_LLVM_INJECTIONS_LDAP`
|
||||
- `AFL_LLVM_INJECTIONS_XSS`
|
||||
|
||||
Alternatively you can set `AFL_LLVM_INJECTIONS_ALL` to enable all.
|
||||
|
||||
## How to modify
|
||||
|
||||
If you want to add more fuctions to check for e.g. SQL injections:
|
||||
Add these to `instrumentation/injection-pass.cc` and recompile.
|
||||
|
||||
If you want to test for more injection inputs:
|
||||
Add the dictionary tokens to `src/afl-fuzz.c` and the check for them to
|
||||
`instrumentation/afl-compiler-rt.o.c`.
|
||||
|
||||
If you want to add new injection targets:
|
||||
You will have to edit all three files.
|
||||
|
||||
Just search for:
|
||||
```
|
||||
// Marker: ADD_TO_INJECTIONS
|
||||
```
|
||||
in the files to see where this needs to be added.
|
||||
|
||||
**NOTE:** pull requests to improve this feature are highly welcome :-)
|
@ -2,7 +2,7 @@
|
||||
|
||||
## TL;DR:
|
||||
|
||||
This version requires a LLVM 11 or newer.
|
||||
This version requires a LLVM 12 or newer.
|
||||
|
||||
1. Use afl-clang-lto/afl-clang-lto++ because the resulting binaries run
|
||||
slightly faster and give better coverage.
|
||||
@ -10,7 +10,7 @@ This version requires a LLVM 11 or newer.
|
||||
2. You can use it together with COMPCOV, COMPLOG and the instrument file
|
||||
listing features.
|
||||
|
||||
3. It only works with LLVM 11 or newer.
|
||||
3. It only works with LLVM 12 or newer.
|
||||
|
||||
4. AUTODICTIONARY feature (see below)
|
||||
|
||||
@ -60,7 +60,7 @@ AUTODICTIONARY: 11 strings found
|
||||
[+] Instrumented 12071 locations with no collisions (on average 1046 collisions would be in afl-gcc/afl-clang-fast) (non-hardened mode).
|
||||
```
|
||||
|
||||
## Getting LLVM 11+
|
||||
## Getting LLVM 12+
|
||||
|
||||
### Installing llvm
|
||||
|
||||
@ -73,7 +73,7 @@ chmod +x llvm.sh
|
||||
sudo ./llvm.sh 15 all
|
||||
```
|
||||
|
||||
LLVM 11 to 16 should be available in all current Linux repositories.
|
||||
LLVM 12 to 18 should be available in all current Linux repositories.
|
||||
|
||||
## How to build afl-clang-lto
|
||||
|
||||
@ -277,7 +277,7 @@ AS=llvm-as ...
|
||||
afl-clang-lto is still work in progress.
|
||||
|
||||
Known issues:
|
||||
* Anything that LLVM 11+ cannot compile, afl-clang-lto cannot compile either -
|
||||
* Anything that LLVM 12+ cannot compile, afl-clang-lto cannot compile either -
|
||||
obviously.
|
||||
* Anything that does not compile with LTO, afl-clang-lto cannot compile either -
|
||||
obviously.
|
||||
@ -319,7 +319,7 @@ Still more problems came up though as this only works without bugs from LLVM 9
|
||||
onwards, and with high optimization the link optimization ruins the instrumented
|
||||
control flow graph.
|
||||
|
||||
This is all now fixed with LLVM 11+. The llvm's own linker is now able to load
|
||||
This is all now fixed with LLVM 12+. The llvm's own linker is now able to load
|
||||
passes and this bypasses all problems we had.
|
||||
|
||||
Happy end :)
|
||||
|
@ -692,33 +692,37 @@ bool ModuleSanitizerCoverageLTO::instrumentModule(
|
||||
* prototype */
|
||||
FunctionType *FT = Callee->getFunctionType();
|
||||
|
||||
isStrcmp &= FT->getNumParams() == 2 &&
|
||||
FT->getReturnType()->isIntegerTy(32) &&
|
||||
FT->getParamType(0) == FT->getParamType(1) &&
|
||||
FT->getParamType(0) ==
|
||||
IntegerType::getInt8PtrTy(M.getContext());
|
||||
isStrcasecmp &= FT->getNumParams() == 2 &&
|
||||
FT->getReturnType()->isIntegerTy(32) &&
|
||||
FT->getParamType(0) == FT->getParamType(1) &&
|
||||
FT->getParamType(0) ==
|
||||
IntegerType::getInt8PtrTy(M.getContext());
|
||||
isStrcmp &=
|
||||
FT->getNumParams() == 2 &&
|
||||
FT->getReturnType()->isIntegerTy(32) &&
|
||||
FT->getParamType(0) == FT->getParamType(1) &&
|
||||
FT->getParamType(0) ==
|
||||
IntegerType::getInt8Ty(M.getContext())->getPointerTo(0);
|
||||
isStrcasecmp &=
|
||||
FT->getNumParams() == 2 &&
|
||||
FT->getReturnType()->isIntegerTy(32) &&
|
||||
FT->getParamType(0) == FT->getParamType(1) &&
|
||||
FT->getParamType(0) ==
|
||||
IntegerType::getInt8Ty(M.getContext())->getPointerTo(0);
|
||||
isMemcmp &= FT->getNumParams() == 3 &&
|
||||
FT->getReturnType()->isIntegerTy(32) &&
|
||||
FT->getParamType(0)->isPointerTy() &&
|
||||
FT->getParamType(1)->isPointerTy() &&
|
||||
FT->getParamType(2)->isIntegerTy();
|
||||
isStrncmp &= FT->getNumParams() == 3 &&
|
||||
FT->getReturnType()->isIntegerTy(32) &&
|
||||
FT->getParamType(0) == FT->getParamType(1) &&
|
||||
FT->getParamType(0) ==
|
||||
IntegerType::getInt8PtrTy(M.getContext()) &&
|
||||
FT->getParamType(2)->isIntegerTy();
|
||||
isStrncasecmp &= FT->getNumParams() == 3 &&
|
||||
FT->getReturnType()->isIntegerTy(32) &&
|
||||
FT->getParamType(0) == FT->getParamType(1) &&
|
||||
FT->getParamType(0) ==
|
||||
IntegerType::getInt8PtrTy(M.getContext()) &&
|
||||
FT->getParamType(2)->isIntegerTy();
|
||||
isStrncmp &=
|
||||
FT->getNumParams() == 3 &&
|
||||
FT->getReturnType()->isIntegerTy(32) &&
|
||||
FT->getParamType(0) == FT->getParamType(1) &&
|
||||
FT->getParamType(0) ==
|
||||
IntegerType::getInt8Ty(M.getContext())->getPointerTo(0) &&
|
||||
FT->getParamType(2)->isIntegerTy();
|
||||
isStrncasecmp &=
|
||||
FT->getNumParams() == 3 &&
|
||||
FT->getReturnType()->isIntegerTy(32) &&
|
||||
FT->getParamType(0) == FT->getParamType(1) &&
|
||||
FT->getParamType(0) ==
|
||||
IntegerType::getInt8Ty(M.getContext())->getPointerTo(0) &&
|
||||
FT->getParamType(2)->isIntegerTy();
|
||||
isStdString &= FT->getNumParams() >= 2 &&
|
||||
FT->getParamType(0)->isPointerTy() &&
|
||||
FT->getParamType(1)->isPointerTy();
|
||||
@ -1241,7 +1245,11 @@ void ModuleSanitizerCoverageLTO::instrumentFunction(
|
||||
if (F.empty()) return;
|
||||
if (F.getName().find(".module_ctor") != std::string::npos)
|
||||
return; // Should not instrument sanitizer init functions.
|
||||
#if LLVM_VERSION_MAJOR >= 18
|
||||
if (F.getName().starts_with("__sanitizer_"))
|
||||
#else
|
||||
if (F.getName().startswith("__sanitizer_"))
|
||||
#endif
|
||||
return; // Don't instrument __sanitizer_* callbacks.
|
||||
// Don't touch available_externally functions, their actual body is elsewhere.
|
||||
if (F.getLinkage() == GlobalValue::AvailableExternallyLinkage) return;
|
||||
@ -1493,7 +1501,7 @@ GlobalVariable *ModuleSanitizerCoverageLTO::CreateFunctionLocalArrayInSection(
|
||||
Array->setComdat(Comdat);
|
||||
#endif
|
||||
Array->setSection(getSectionName(Section));
|
||||
Array->setAlignment(Align(DL->getTypeStoreSize(Ty).getFixedSize()));
|
||||
Array->setAlignment(Align(DL->getTypeStoreSize(Ty).getFixedValue()));
|
||||
GlobalsToAppendToUsed.push_back(Array);
|
||||
GlobalsToAppendToCompilerUsed.push_back(Array);
|
||||
MDNode *MD = MDNode::get(F.getContext(), ValueAsMetadata::get(&F));
|
||||
|
@ -572,7 +572,11 @@ void ModuleSanitizerCoverageAFL::instrumentFunction(
|
||||
if (!isInInstrumentList(&F, FMNAME)) return;
|
||||
if (F.getName().find(".module_ctor") != std::string::npos)
|
||||
return; // Should not instrument sanitizer init functions.
|
||||
#if LLVM_VERSION_MAJOR >= 18
|
||||
if (F.getName().starts_with("__sanitizer_"))
|
||||
#else
|
||||
if (F.getName().startswith("__sanitizer_"))
|
||||
#endif
|
||||
return; // Don't instrument __sanitizer_* callbacks.
|
||||
// Don't touch available_externally functions, their actual body is elewhere.
|
||||
if (F.getLinkage() == GlobalValue::AvailableExternallyLinkage) return;
|
||||
@ -623,6 +627,13 @@ void ModuleSanitizerCoverageAFL::instrumentFunction(
|
||||
|
||||
}
|
||||
|
||||
if (debug) {
|
||||
|
||||
fprintf(stderr, "SanitizerCoveragePCGUARD: instrumenting %s in %s\n",
|
||||
F.getName().str().c_str(), F.getParent()->getName().str().c_str());
|
||||
|
||||
}
|
||||
|
||||
InjectCoverage(F, BlocksToInstrument, IsLeafFunc);
|
||||
// InjectTraceForCmp(F, CmpTraceTargets);
|
||||
// InjectTraceForSwitch(F, SwitchTraceTargets);
|
||||
@ -948,6 +959,7 @@ bool ModuleSanitizerCoverageAFL::InjectCoverage(
|
||||
#endif
|
||||
{
|
||||
|
||||
// fprintf(stderr, "UNHANDLED: %u\n", t->getTypeID());
|
||||
unhandled++;
|
||||
continue;
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
------------------------------------------------
|
||||
|
||||
Copyright 2015, 2016 Google Inc. All rights reserved.
|
||||
Copyright 2019-2023 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2024 AFLplusplus Project. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -22,6 +22,10 @@
|
||||
#define __USE_GNU
|
||||
#endif
|
||||
#include <dlfcn.h>
|
||||
|
||||
__attribute__((weak)) void __sanitizer_symbolize_pc(void *, const char *fmt,
|
||||
char *out_buf,
|
||||
size_t out_buf_size);
|
||||
#endif
|
||||
|
||||
#ifdef __ANDROID__
|
||||
@ -92,6 +96,8 @@ extern ssize_t _kern_write(int fd, off_t pos, const void *buffer,
|
||||
size_t bufferSize);
|
||||
#endif // HAIKU
|
||||
|
||||
char *strcasestr(const char *haystack, const char *needle);
|
||||
|
||||
static u8 __afl_area_initial[MAP_INITIAL_SIZE];
|
||||
static u8 *__afl_area_ptr_dummy = __afl_area_initial;
|
||||
static u8 *__afl_area_ptr_backup = __afl_area_initial;
|
||||
@ -122,8 +128,8 @@ struct afl_module_info_t {
|
||||
uintptr_t base_address;
|
||||
|
||||
// PC Guard start/stop
|
||||
u32 start;
|
||||
u32 stop;
|
||||
u32 *start;
|
||||
u32 *stop;
|
||||
|
||||
// PC Table begin/end
|
||||
const uintptr_t *pcs_beg;
|
||||
@ -145,6 +151,18 @@ afl_module_info_t *__afl_module_info = NULL;
|
||||
|
||||
u32 __afl_pcmap_size = 0;
|
||||
uintptr_t *__afl_pcmap_ptr = NULL;
|
||||
|
||||
typedef struct {
|
||||
|
||||
uintptr_t start;
|
||||
u32 len;
|
||||
|
||||
} FilterPCEntry;
|
||||
|
||||
u32 __afl_filter_pcs_size = 0;
|
||||
FilterPCEntry *__afl_filter_pcs = NULL;
|
||||
u8 *__afl_filter_pcs_module = NULL;
|
||||
|
||||
#endif // __AFL_CODE_COVERAGE
|
||||
|
||||
/* 1 if we are running in afl, and the forkserver was started, else 0 */
|
||||
@ -1585,15 +1603,116 @@ void __sanitizer_cov_trace_pc_guard(uint32_t *guard) {
|
||||
}
|
||||
|
||||
#ifdef __AFL_CODE_COVERAGE
|
||||
void __sanitizer_cov_pcs_init(const uintptr_t *pcs_beg,
|
||||
const uintptr_t *pcs_end) {
|
||||
void afl_read_pc_filter_file(const char *filter_file) {
|
||||
|
||||
if (__afl_debug) {
|
||||
FILE *file;
|
||||
char ch;
|
||||
|
||||
fprintf(stderr, "DEBUG: __sanitizer_cov_pcs_init called\n");
|
||||
file = fopen(filter_file, "r");
|
||||
if (file == NULL) {
|
||||
|
||||
perror("Error opening file");
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
// Check how many PCs we expect to read
|
||||
while ((ch = fgetc(file)) != EOF) {
|
||||
|
||||
if (ch == '\n') { __afl_filter_pcs_size++; }
|
||||
|
||||
}
|
||||
|
||||
// Rewind to actually read the PCs
|
||||
fseek(file, 0, SEEK_SET);
|
||||
|
||||
__afl_filter_pcs = malloc(__afl_filter_pcs_size * sizeof(FilterPCEntry));
|
||||
if (!__afl_filter_pcs) {
|
||||
|
||||
perror("Error allocating PC array");
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < __afl_filter_pcs_size; i++) {
|
||||
|
||||
fscanf(file, "%lx", &(__afl_filter_pcs[i].start));
|
||||
ch = fgetc(file); // Read tab
|
||||
fscanf(file, "%u", &(__afl_filter_pcs[i].len));
|
||||
ch = fgetc(file); // Read tab
|
||||
|
||||
if (!__afl_filter_pcs_module) {
|
||||
|
||||
// Read the module name and store it.
|
||||
// TODO: We only support one module here right now although
|
||||
// there is technically no reason to support multiple modules
|
||||
// in one go.
|
||||
size_t max_module_len = 255;
|
||||
size_t i = 0;
|
||||
__afl_filter_pcs_module = malloc(max_module_len);
|
||||
while (i < max_module_len - 1 &&
|
||||
(__afl_filter_pcs_module[i] = fgetc(file)) != '\t') {
|
||||
|
||||
++i;
|
||||
|
||||
}
|
||||
|
||||
__afl_filter_pcs_module[i] = '\0';
|
||||
fprintf(stderr, "DEBUGXXX: Read module name %s\n",
|
||||
__afl_filter_pcs_module);
|
||||
|
||||
}
|
||||
|
||||
while ((ch = fgetc(file)) != '\n' && ch != EOF)
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
|
||||
}
|
||||
|
||||
u32 locate_in_pcs(uintptr_t needle, u32 *index) {
|
||||
|
||||
size_t lower_bound = 0;
|
||||
size_t upper_bound = __afl_filter_pcs_size - 1;
|
||||
|
||||
while (lower_bound < __afl_filter_pcs_size && lower_bound <= upper_bound) {
|
||||
|
||||
size_t current_index = lower_bound + (upper_bound - lower_bound) / 2;
|
||||
|
||||
if (__afl_filter_pcs[current_index].start <= needle) {
|
||||
|
||||
if (__afl_filter_pcs[current_index].start +
|
||||
__afl_filter_pcs[current_index].len >
|
||||
needle) {
|
||||
|
||||
// Hit
|
||||
*index = current_index;
|
||||
return 1;
|
||||
|
||||
} else {
|
||||
|
||||
lower_bound = current_index + 1;
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (!current_index) { break; }
|
||||
upper_bound = current_index - 1;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
void __sanitizer_cov_pcs_init(const uintptr_t *pcs_beg,
|
||||
const uintptr_t *pcs_end) {
|
||||
|
||||
// If for whatever reason, we cannot get dlinfo here, then pc_guard_init also
|
||||
// couldn't get it and we'd end up attributing to the wrong module.
|
||||
Dl_info dlinfo;
|
||||
@ -1606,6 +1725,16 @@ void __sanitizer_cov_pcs_init(const uintptr_t *pcs_beg,
|
||||
|
||||
}
|
||||
|
||||
if (__afl_debug) {
|
||||
|
||||
fprintf(
|
||||
stderr,
|
||||
"DEBUG: (%u) __sanitizer_cov_pcs_init called for module %s with %ld "
|
||||
"PCs\n",
|
||||
getpid(), dlinfo.dli_fname, pcs_end - pcs_beg);
|
||||
|
||||
}
|
||||
|
||||
afl_module_info_t *last_module_info = __afl_module_info;
|
||||
while (last_module_info && last_module_info->next) {
|
||||
|
||||
@ -1621,34 +1750,78 @@ void __sanitizer_cov_pcs_init(const uintptr_t *pcs_beg,
|
||||
|
||||
}
|
||||
|
||||
if (strcmp(dlinfo.dli_fname, last_module_info->name)) {
|
||||
|
||||
// This can happen with modules being loaded after the forkserver
|
||||
// where we decide to not track the module. In that case we must
|
||||
// not track it here either.
|
||||
fprintf(
|
||||
stderr,
|
||||
"WARNING: __sanitizer_cov_pcs_init module info mismatch: %s vs %s\n",
|
||||
dlinfo.dli_fname, last_module_info->name);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
last_module_info->pcs_beg = pcs_beg;
|
||||
last_module_info->pcs_end = pcs_end;
|
||||
|
||||
// This is a direct filter based on symbolizing inside the runtime.
|
||||
// It should only be used with smaller binaries to avoid long startup
|
||||
// times. Currently, this only supports a single token to scan for.
|
||||
const char *pc_filter = getenv("AFL_PC_FILTER");
|
||||
|
||||
// This is a much faster PC filter based on pre-symbolized input data
|
||||
// that is sorted for fast lookup through binary search. This method
|
||||
// of filtering is suitable even for very large binaries.
|
||||
const char *pc_filter_file = getenv("AFL_PC_FILTER_FILE");
|
||||
if (pc_filter_file && !__afl_filter_pcs) {
|
||||
|
||||
afl_read_pc_filter_file(pc_filter_file);
|
||||
|
||||
}
|
||||
|
||||
// Now update the pcmap. If this is the last module coming in, after all
|
||||
// pre-loaded code, then this will also map all of our delayed previous
|
||||
// modules.
|
||||
|
||||
if (!__afl_pcmap_ptr) { return; }
|
||||
|
||||
//
|
||||
for (afl_module_info_t *mod_info = __afl_module_info; mod_info;
|
||||
mod_info = mod_info->next) {
|
||||
|
||||
if (mod_info->mapped) { continue; }
|
||||
|
||||
if (!mod_info->start) {
|
||||
|
||||
fprintf(stderr,
|
||||
"ERROR: __sanitizer_cov_pcs_init called with mod_info->start == "
|
||||
"NULL (%s)\n",
|
||||
mod_info->name);
|
||||
abort();
|
||||
|
||||
}
|
||||
|
||||
PCTableEntry *start = (PCTableEntry *)(mod_info->pcs_beg);
|
||||
PCTableEntry *end = (PCTableEntry *)(mod_info->pcs_end);
|
||||
|
||||
if (!*mod_info->stop) { continue; }
|
||||
|
||||
u32 in_module_index = 0;
|
||||
|
||||
while (start < end) {
|
||||
|
||||
if (mod_info->start + in_module_index >= __afl_map_size) {
|
||||
if (*mod_info->start + in_module_index >= __afl_map_size) {
|
||||
|
||||
fprintf(stderr, "ERROR: __sanitizer_cov_pcs_init out of bounds?!\n");
|
||||
fprintf(stderr,
|
||||
"ERROR: __sanitizer_cov_pcs_init out of bounds?! Start: %u "
|
||||
"Stop: %u Map Size: %u (%s)\n",
|
||||
*mod_info->start, *mod_info->stop, __afl_map_size,
|
||||
mod_info->name);
|
||||
abort();
|
||||
|
||||
}
|
||||
|
||||
u32 orig_start_index = *mod_info->start;
|
||||
|
||||
uintptr_t PC = start->PC;
|
||||
|
||||
// This is what `GetPreviousInstructionPc` in sanitizer runtime does
|
||||
@ -1658,7 +1831,58 @@ void __sanitizer_cov_pcs_init(const uintptr_t *pcs_beg,
|
||||
// Calculate relative offset in module
|
||||
PC = PC - mod_info->base_address;
|
||||
|
||||
__afl_pcmap_ptr[mod_info->start + in_module_index] = PC;
|
||||
if (__afl_pcmap_ptr) {
|
||||
|
||||
__afl_pcmap_ptr[orig_start_index + in_module_index] = PC;
|
||||
|
||||
}
|
||||
|
||||
if (pc_filter) {
|
||||
|
||||
char PcDescr[1024];
|
||||
// This function is a part of the sanitizer run-time.
|
||||
// To use it, link with AddressSanitizer or other sanitizer.
|
||||
__sanitizer_symbolize_pc((void *)start->PC, "%p %F %L", PcDescr,
|
||||
sizeof(PcDescr));
|
||||
|
||||
if (strstr(PcDescr, pc_filter)) {
|
||||
|
||||
if (__afl_debug)
|
||||
fprintf(
|
||||
stderr,
|
||||
"DEBUG: Selective instrumentation match: %s (PC %p Index %u)\n",
|
||||
PcDescr, (void *)start->PC,
|
||||
*(mod_info->start + in_module_index));
|
||||
// No change to guard needed
|
||||
|
||||
} else {
|
||||
|
||||
// Null out the guard to disable this edge
|
||||
*(mod_info->start + in_module_index) = 0;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (__afl_filter_pcs && strstr(mod_info->name, __afl_filter_pcs_module)) {
|
||||
|
||||
u32 result_index;
|
||||
if (locate_in_pcs(PC, &result_index)) {
|
||||
|
||||
if (__afl_debug)
|
||||
fprintf(stderr,
|
||||
"DEBUG: Selective instrumentation match: (PC %lx File "
|
||||
"Index %u PC Index %u)\n",
|
||||
PC, result_index, in_module_index);
|
||||
|
||||
} else {
|
||||
|
||||
// Null out the guard to disable this edge
|
||||
*(mod_info->start + in_module_index) = 0;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
start++;
|
||||
in_module_index++;
|
||||
@ -1669,8 +1893,10 @@ void __sanitizer_cov_pcs_init(const uintptr_t *pcs_beg,
|
||||
|
||||
if (__afl_debug) {
|
||||
|
||||
fprintf(stderr, "DEBUG: __sanitizer_cov_pcs_init initialized %u PCs\n",
|
||||
in_module_index);
|
||||
fprintf(stderr,
|
||||
"DEBUG: __sanitizer_cov_pcs_init successfully mapped %s with %u "
|
||||
"PCs\n",
|
||||
mod_info->name, in_module_index);
|
||||
|
||||
}
|
||||
|
||||
@ -1704,9 +1930,9 @@ void __sanitizer_cov_trace_pc_guard_init(uint32_t *start, uint32_t *stop) {
|
||||
fprintf(
|
||||
stderr,
|
||||
"DEBUG: Running __sanitizer_cov_trace_pc_guard_init: %p-%p (%lu edges) "
|
||||
"after_fs=%u\n",
|
||||
"after_fs=%u *start=%u\n",
|
||||
start, stop, (unsigned long)(stop - start),
|
||||
__afl_already_initialized_forkserver);
|
||||
__afl_already_initialized_forkserver, *start);
|
||||
|
||||
}
|
||||
|
||||
@ -1738,8 +1964,8 @@ void __sanitizer_cov_trace_pc_guard_init(uint32_t *start, uint32_t *stop) {
|
||||
mod_info->id = last_module_info ? last_module_info->id + 1 : 0;
|
||||
mod_info->name = strdup(dlinfo.dli_fname);
|
||||
mod_info->base_address = (uintptr_t)dlinfo.dli_fbase;
|
||||
mod_info->start = 0;
|
||||
mod_info->stop = 0;
|
||||
mod_info->start = NULL;
|
||||
mod_info->stop = NULL;
|
||||
mod_info->pcs_beg = NULL;
|
||||
mod_info->pcs_end = NULL;
|
||||
mod_info->mapped = 0;
|
||||
@ -1755,8 +1981,12 @@ void __sanitizer_cov_trace_pc_guard_init(uint32_t *start, uint32_t *stop) {
|
||||
|
||||
}
|
||||
|
||||
fprintf(stderr, "[pcmap] Module: %s Base Address: %p\n", dlinfo.dli_fname,
|
||||
dlinfo.dli_fbase);
|
||||
if (__afl_debug) {
|
||||
|
||||
fprintf(stderr, "[pcmap] Module: %s Base Address: %p\n",
|
||||
dlinfo.dli_fname, dlinfo.dli_fbase);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1859,12 +2089,17 @@ void __sanitizer_cov_trace_pc_guard_init(uint32_t *start, uint32_t *stop) {
|
||||
#ifdef __AFL_CODE_COVERAGE
|
||||
if (mod_info) {
|
||||
|
||||
mod_info->start = *orig_start;
|
||||
mod_info->stop = *(stop - 1);
|
||||
if (!mod_info->start) {
|
||||
|
||||
mod_info->start = orig_start;
|
||||
mod_info->stop = stop - 1;
|
||||
|
||||
}
|
||||
|
||||
if (__afl_debug) {
|
||||
|
||||
fprintf(stderr, "DEBUG: [pcmap] Start Index: %u Stop Index: %u\n",
|
||||
mod_info->start, mod_info->stop);
|
||||
*(mod_info->start), *(mod_info->stop));
|
||||
|
||||
}
|
||||
|
||||
@ -2670,5 +2905,52 @@ void __afl_set_persistent_mode(u8 mode) {
|
||||
|
||||
}
|
||||
|
||||
// Marker: ADD_TO_INJECTIONS
|
||||
|
||||
void __afl_injection_sql(u8 *buf) {
|
||||
|
||||
if (likely(buf)) {
|
||||
|
||||
if (unlikely(strstr((char *)buf, "'\"\"'"))) {
|
||||
|
||||
fprintf(stderr, "ALERT: Detected SQL injection in query: %s\n", buf);
|
||||
abort();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void __afl_injection_ldap(u8 *buf) {
|
||||
|
||||
if (likely(buf)) {
|
||||
|
||||
if (unlikely(strstr((char *)buf, "*)(1=*))(|"))) {
|
||||
|
||||
fprintf(stderr, "ALERT: Detected LDAP injection in query: %s\n", buf);
|
||||
abort();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void __afl_injection_xss(u8 *buf) {
|
||||
|
||||
if (likely(buf)) {
|
||||
|
||||
if (unlikely(strstr((char *)buf, "1\"><\""))) {
|
||||
|
||||
fprintf(stderr, "ALERT: Detected XSS injection in content: %s\n", buf);
|
||||
abort();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#undef write_error
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
Copyright 2014-2019 Free Software Foundation, Inc
|
||||
Copyright 2015, 2016 Google Inc. All rights reserved.
|
||||
Copyright 2019-2020 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2023 AdaCore
|
||||
Copyright 2019-2024 AdaCore
|
||||
|
||||
Written by Alexandre Oliva <oliva@adacore.com>, based on the AFL++
|
||||
LLVM CmpLog pass by Andrea Fioraldi <andreafioraldi@gmail.com>, and
|
||||
|
@ -3,7 +3,7 @@
|
||||
Copyright 2014-2019 Free Software Foundation, Inc
|
||||
Copyright 2015, 2016 Google Inc. All rights reserved.
|
||||
Copyright 2019-2020 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2023 AdaCore
|
||||
Copyright 2019-2024 AdaCore
|
||||
|
||||
Written by Alexandre Oliva <oliva@adacore.com>, based on the AFL++
|
||||
LLVM CmpLog Routines pass by Andrea Fioraldi
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
Copyright 2014-2019 Free Software Foundation, Inc
|
||||
Copyright 2015, 2016 Google Inc. All rights reserved.
|
||||
Copyright 2019-2023 AdaCore
|
||||
Copyright 2019-2024 AdaCore
|
||||
|
||||
Written by Alexandre Oliva <oliva@adacore.com>, based on the AFL++
|
||||
GCC plugin.
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
Copyright 2014-2019 Free Software Foundation, Inc
|
||||
Copyright 2015, 2016 Google Inc. All rights reserved.
|
||||
Copyright 2019-2023 AdaCore
|
||||
Copyright 2019-2024 AdaCore
|
||||
|
||||
Written by Alexandre Oliva <oliva@adacore.com>, based on the AFL
|
||||
LLVM pass by Laszlo Szekeres <lszekeres@google.com> and Michal
|
||||
|
@ -201,7 +201,7 @@ void initInstrumentList() {
|
||||
|
||||
if (debug)
|
||||
DEBUGF("loaded allowlist with %zu file and %zu function entries\n",
|
||||
allowListFiles.size(), allowListFunctions.size());
|
||||
allowListFiles.size() / 4, allowListFunctions.size() / 4);
|
||||
|
||||
}
|
||||
|
||||
@ -276,7 +276,7 @@ void initInstrumentList() {
|
||||
|
||||
if (debug)
|
||||
DEBUGF("loaded denylist with %zu file and %zu function entries\n",
|
||||
denyListFiles.size(), denyListFunctions.size());
|
||||
denyListFiles.size() / 4, denyListFunctions.size() / 4);
|
||||
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
Written by Marc Heuse <mh@mh-sec.de>
|
||||
|
||||
Copyright 2019-2023 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2024 AFLplusplus Project. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -433,32 +433,35 @@ bool AFLdict2filePass::runOnModule(Module &M) {
|
||||
isStrstr &=
|
||||
FT->getNumParams() == 2 &&
|
||||
FT->getParamType(0) == FT->getParamType(1) &&
|
||||
FT->getParamType(0) == IntegerType::getInt8PtrTy(M.getContext());
|
||||
FT->getParamType(0) ==
|
||||
IntegerType::getInt8Ty(M.getContext())->getPointerTo(0);
|
||||
isStrcmp &=
|
||||
FT->getNumParams() == 2 && FT->getReturnType()->isIntegerTy(32) &&
|
||||
FT->getParamType(0) == FT->getParamType(1) &&
|
||||
FT->getParamType(0) == IntegerType::getInt8PtrTy(M.getContext());
|
||||
FT->getParamType(0) ==
|
||||
IntegerType::getInt8Ty(M.getContext())->getPointerTo(0);
|
||||
isStrcasecmp &=
|
||||
FT->getNumParams() == 2 && FT->getReturnType()->isIntegerTy(32) &&
|
||||
FT->getParamType(0) == FT->getParamType(1) &&
|
||||
FT->getParamType(0) == IntegerType::getInt8PtrTy(M.getContext());
|
||||
FT->getParamType(0) ==
|
||||
IntegerType::getInt8Ty(M.getContext())->getPointerTo(0);
|
||||
isMemcmp &= FT->getNumParams() == 3 &&
|
||||
FT->getReturnType()->isIntegerTy(32) &&
|
||||
FT->getParamType(0)->isPointerTy() &&
|
||||
FT->getParamType(1)->isPointerTy() &&
|
||||
FT->getParamType(2)->isIntegerTy();
|
||||
isStrncmp &= FT->getNumParams() == 3 &&
|
||||
FT->getReturnType()->isIntegerTy(32) &&
|
||||
FT->getParamType(0) == FT->getParamType(1) &&
|
||||
FT->getParamType(0) ==
|
||||
IntegerType::getInt8PtrTy(M.getContext()) &&
|
||||
FT->getParamType(2)->isIntegerTy();
|
||||
isStrncasecmp &= FT->getNumParams() == 3 &&
|
||||
FT->getReturnType()->isIntegerTy(32) &&
|
||||
FT->getParamType(0) == FT->getParamType(1) &&
|
||||
FT->getParamType(0) ==
|
||||
IntegerType::getInt8PtrTy(M.getContext()) &&
|
||||
FT->getParamType(2)->isIntegerTy();
|
||||
isStrncmp &=
|
||||
FT->getNumParams() == 3 && FT->getReturnType()->isIntegerTy(32) &&
|
||||
FT->getParamType(0) == FT->getParamType(1) &&
|
||||
FT->getParamType(0) ==
|
||||
IntegerType::getInt8Ty(M.getContext())->getPointerTo(0) &&
|
||||
FT->getParamType(2)->isIntegerTy();
|
||||
isStrncasecmp &=
|
||||
FT->getNumParams() == 3 && FT->getReturnType()->isIntegerTy(32) &&
|
||||
FT->getParamType(0) == FT->getParamType(1) &&
|
||||
FT->getParamType(0) ==
|
||||
IntegerType::getInt8Ty(M.getContext())->getPointerTo(0) &&
|
||||
FT->getParamType(2)->isIntegerTy();
|
||||
isStdString &= FT->getNumParams() >= 2 &&
|
||||
FT->getParamType(0)->isPointerTy() &&
|
||||
FT->getParamType(1)->isPointerTy();
|
||||
|
@ -9,7 +9,7 @@
|
||||
from afl-as.c are Michal's fault.
|
||||
|
||||
Copyright 2015, 2016 Google Inc. All rights reserved.
|
||||
Copyright 2019-2023 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2024 AFLplusplus Project. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
@ -12,7 +12,7 @@
|
||||
NGRAM previous location coverage comes from Adrian Herrera.
|
||||
|
||||
Copyright 2015, 2016 Google Inc. All rights reserved.
|
||||
Copyright 2019-2023 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2024 AFLplusplus Project. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
@ -5,7 +5,7 @@
|
||||
Written by Andrea Fioraldi <andreafioraldi@gmail.com>
|
||||
|
||||
Copyright 2015, 2016 Google Inc. All rights reserved.
|
||||
Copyright 2019-2023 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2024 AFLplusplus Project. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
@ -5,7 +5,7 @@
|
||||
Written by Andrea Fioraldi <andreafioraldi@gmail.com>
|
||||
|
||||
Copyright 2015, 2016 Google Inc. All rights reserved.
|
||||
Copyright 2019-2023 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2024 AFLplusplus Project. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -385,7 +385,8 @@ bool CmpLogRoutines::hookRtns(Module &M) {
|
||||
isStrcmp &=
|
||||
FT->getNumParams() == 2 && FT->getReturnType()->isIntegerTy(32) &&
|
||||
FT->getParamType(0) == FT->getParamType(1) &&
|
||||
FT->getParamType(0) == IntegerType::getInt8PtrTy(M.getContext());
|
||||
FT->getParamType(0) ==
|
||||
IntegerType::getInt8Ty(M.getContext())->getPointerTo(0);
|
||||
|
||||
bool isStrncmp = (!FuncName.compare("strncmp") ||
|
||||
!FuncName.compare("xmlStrncmp") ||
|
||||
@ -398,12 +399,12 @@ bool CmpLogRoutines::hookRtns(Module &M) {
|
||||
!FuncName.compare("g_ascii_strncasecmp") ||
|
||||
!FuncName.compare("Curl_strncasecompare") ||
|
||||
!FuncName.compare("g_strncasecmp"));
|
||||
isStrncmp &= FT->getNumParams() == 3 &&
|
||||
FT->getReturnType()->isIntegerTy(32) &&
|
||||
FT->getParamType(0) == FT->getParamType(1) &&
|
||||
FT->getParamType(0) ==
|
||||
IntegerType::getInt8PtrTy(M.getContext()) &&
|
||||
FT->getParamType(2)->isIntegerTy();
|
||||
isStrncmp &=
|
||||
FT->getNumParams() == 3 && FT->getReturnType()->isIntegerTy(32) &&
|
||||
FT->getParamType(0) == FT->getParamType(1) &&
|
||||
FT->getParamType(0) ==
|
||||
IntegerType::getInt8Ty(M.getContext())->getPointerTo(0) &&
|
||||
FT->getParamType(2)->isIntegerTy();
|
||||
|
||||
bool isGccStdStringStdString =
|
||||
Callee->getName().find("__is_charIT_EE7__value") !=
|
||||
|
@ -5,7 +5,7 @@
|
||||
Written by Andrea Fioraldi <andreafioraldi@gmail.com>
|
||||
|
||||
Copyright 2015, 2016 Google Inc. All rights reserved.
|
||||
Copyright 2019-2023 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2024 AFLplusplus Project. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
@ -271,28 +271,30 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp,
|
||||
isStrcmp &=
|
||||
FT->getNumParams() == 2 && FT->getReturnType()->isIntegerTy(32) &&
|
||||
FT->getParamType(0) == FT->getParamType(1) &&
|
||||
FT->getParamType(0) == IntegerType::getInt8PtrTy(M.getContext());
|
||||
FT->getParamType(0) ==
|
||||
IntegerType::getInt8Ty(M.getContext())->getPointerTo(0);
|
||||
isStrcasecmp &=
|
||||
FT->getNumParams() == 2 && FT->getReturnType()->isIntegerTy(32) &&
|
||||
FT->getParamType(0) == FT->getParamType(1) &&
|
||||
FT->getParamType(0) == IntegerType::getInt8PtrTy(M.getContext());
|
||||
FT->getParamType(0) ==
|
||||
IntegerType::getInt8Ty(M.getContext())->getPointerTo(0);
|
||||
isMemcmp &= FT->getNumParams() == 3 &&
|
||||
FT->getReturnType()->isIntegerTy(32) &&
|
||||
FT->getParamType(0)->isPointerTy() &&
|
||||
FT->getParamType(1)->isPointerTy() &&
|
||||
FT->getParamType(2)->isIntegerTy();
|
||||
isStrncmp &= FT->getNumParams() == 3 &&
|
||||
FT->getReturnType()->isIntegerTy(32) &&
|
||||
FT->getParamType(0) == FT->getParamType(1) &&
|
||||
FT->getParamType(0) ==
|
||||
IntegerType::getInt8PtrTy(M.getContext()) &&
|
||||
FT->getParamType(2)->isIntegerTy();
|
||||
isStrncasecmp &= FT->getNumParams() == 3 &&
|
||||
FT->getReturnType()->isIntegerTy(32) &&
|
||||
FT->getParamType(0) == FT->getParamType(1) &&
|
||||
FT->getParamType(0) ==
|
||||
IntegerType::getInt8PtrTy(M.getContext()) &&
|
||||
FT->getParamType(2)->isIntegerTy();
|
||||
isStrncmp &=
|
||||
FT->getNumParams() == 3 && FT->getReturnType()->isIntegerTy(32) &&
|
||||
FT->getParamType(0) == FT->getParamType(1) &&
|
||||
FT->getParamType(0) ==
|
||||
IntegerType::getInt8Ty(M.getContext())->getPointerTo(0) &&
|
||||
FT->getParamType(2)->isIntegerTy();
|
||||
isStrncasecmp &=
|
||||
FT->getNumParams() == 3 && FT->getReturnType()->isIntegerTy(32) &&
|
||||
FT->getParamType(0) == FT->getParamType(1) &&
|
||||
FT->getParamType(0) ==
|
||||
IntegerType::getInt8Ty(M.getContext())->getPointerTo(0) &&
|
||||
FT->getParamType(2)->isIntegerTy();
|
||||
|
||||
if (!isStrcmp && !isMemcmp && !isStrncmp && !isStrcasecmp &&
|
||||
!isStrncasecmp && !isIntMemcpy)
|
||||
|
366
instrumentation/injection-pass.cc
Normal file
366
instrumentation/injection-pass.cc
Normal file
@ -0,0 +1,366 @@
|
||||
/*
|
||||
american fuzzy lop++ - LLVM Injection instrumentation
|
||||
--------------------------------------------------
|
||||
|
||||
Written by Marc Heuse <mh@mh-sec.de>
|
||||
|
||||
Copyright 2015, 2016 Google Inc. All rights reserved.
|
||||
Copyright 2019-2024 AFLplusplus Project. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <sys/time.h>
|
||||
#include "llvm/Config/llvm-config.h"
|
||||
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
#include "llvm/IR/IRBuilder.h"
|
||||
#if LLVM_VERSION_MAJOR >= 11 /* use new pass manager */
|
||||
#include "llvm/Passes/PassPlugin.h"
|
||||
#include "llvm/Passes/PassBuilder.h"
|
||||
#include "llvm/IR/PassManager.h"
|
||||
#else
|
||||
#include "llvm/IR/LegacyPassManager.h"
|
||||
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
|
||||
#endif
|
||||
#include "llvm/IR/Module.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#if LLVM_VERSION_MAJOR < 17
|
||||
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
|
||||
#endif
|
||||
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
|
||||
#include "llvm/Pass.h"
|
||||
#include "llvm/Analysis/ValueTracking.h"
|
||||
|
||||
#include "llvm/IR/IRBuilder.h"
|
||||
#if LLVM_VERSION_MAJOR >= 4 || \
|
||||
(LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR > 4)
|
||||
#include "llvm/IR/Verifier.h"
|
||||
#include "llvm/IR/DebugInfo.h"
|
||||
#else
|
||||
#include "llvm/Analysis/Verifier.h"
|
||||
#include "llvm/DebugInfo.h"
|
||||
#define nullptr 0
|
||||
#endif
|
||||
|
||||
#include <set>
|
||||
#include "afl-llvm-common.h"
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
namespace {
|
||||
|
||||
#if LLVM_VERSION_MAJOR >= 11 /* use new pass manager */
|
||||
class InjectionRoutines : public PassInfoMixin<InjectionRoutines> {
|
||||
|
||||
public:
|
||||
InjectionRoutines() {
|
||||
|
||||
#else
|
||||
class InjectionRoutines : public ModulePass {
|
||||
|
||||
public:
|
||||
static char ID;
|
||||
InjectionRoutines() : ModulePass(ID) {
|
||||
|
||||
#endif
|
||||
|
||||
initInstrumentList();
|
||||
|
||||
}
|
||||
|
||||
#if LLVM_VERSION_MAJOR >= 11 /* use new pass manager */
|
||||
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
|
||||
#else
|
||||
bool runOnModule(Module &M) override;
|
||||
|
||||
#if LLVM_VERSION_MAJOR >= 4
|
||||
StringRef getPassName() const override {
|
||||
|
||||
#else
|
||||
const char *getPassName() const override {
|
||||
|
||||
#endif
|
||||
return "Injection routines";
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
private:
|
||||
bool hookRtns(Module &M);
|
||||
|
||||
bool doSQL = false;
|
||||
bool doLDAP = false;
|
||||
bool doXSS = false;
|
||||
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
#if LLVM_MAJOR >= 11
|
||||
extern "C" ::llvm::PassPluginLibraryInfo LLVM_ATTRIBUTE_WEAK
|
||||
llvmGetPassPluginInfo() {
|
||||
|
||||
return {LLVM_PLUGIN_API_VERSION, "Injectionroutines", "v0.1",
|
||||
/* lambda to insert our pass into the pass pipeline. */
|
||||
[](PassBuilder &PB) {
|
||||
|
||||
#if LLVM_VERSION_MAJOR <= 13
|
||||
using OptimizationLevel = typename PassBuilder::OptimizationLevel;
|
||||
#endif
|
||||
PB.registerOptimizerLastEPCallback(
|
||||
[](ModulePassManager &MPM, OptimizationLevel OL) {
|
||||
|
||||
MPM.addPass(InjectionRoutines());
|
||||
|
||||
});
|
||||
|
||||
}};
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
char InjectionRoutines::ID = 0;
|
||||
#endif
|
||||
|
||||
bool InjectionRoutines::hookRtns(Module &M) {
|
||||
|
||||
std::vector<CallInst *> calls, llvmStdStd, llvmStdC, gccStdStd, gccStdC,
|
||||
Memcmp, Strcmp, Strncmp;
|
||||
LLVMContext &C = M.getContext();
|
||||
|
||||
Type *VoidTy = Type::getVoidTy(C);
|
||||
IntegerType *Int8Ty = IntegerType::getInt8Ty(C);
|
||||
PointerType *i8PtrTy = PointerType::get(Int8Ty, 0);
|
||||
|
||||
#if LLVM_VERSION_MAJOR >= 9
|
||||
FunctionCallee
|
||||
#else
|
||||
Constant *
|
||||
#endif
|
||||
c1 = M.getOrInsertFunction("__afl_injection_sql", VoidTy, i8PtrTy
|
||||
#if LLVM_VERSION_MAJOR < 5
|
||||
,
|
||||
NULL
|
||||
#endif
|
||||
);
|
||||
#if LLVM_VERSION_MAJOR >= 9
|
||||
FunctionCallee sqlfunc = c1;
|
||||
#else
|
||||
Function *sqlfunc = cast<Function>(c1);
|
||||
#endif
|
||||
|
||||
#if LLVM_VERSION_MAJOR >= 9
|
||||
FunctionCallee
|
||||
#else
|
||||
Constant *
|
||||
#endif
|
||||
c2 = M.getOrInsertFunction("__afl_injection_ldap", VoidTy, i8PtrTy
|
||||
#if LLVM_VERSION_MAJOR < 5
|
||||
,
|
||||
NULL
|
||||
#endif
|
||||
);
|
||||
#if LLVM_VERSION_MAJOR >= 9
|
||||
FunctionCallee ldapfunc = c2;
|
||||
#else
|
||||
Function *ldapfunc = cast<Function>(c2);
|
||||
#endif
|
||||
|
||||
#if LLVM_VERSION_MAJOR >= 9
|
||||
FunctionCallee
|
||||
#else
|
||||
Constant *
|
||||
#endif
|
||||
c3 = M.getOrInsertFunction("__afl_injection_xss", VoidTy, i8PtrTy
|
||||
#if LLVM_VERSION_MAJOR < 5
|
||||
,
|
||||
NULL
|
||||
#endif
|
||||
);
|
||||
#if LLVM_VERSION_MAJOR >= 9
|
||||
FunctionCallee xssfunc = c3;
|
||||
#else
|
||||
Function *xssfunc = cast<Function>(c3);
|
||||
#endif
|
||||
|
||||
#if LLVM_VERSION_MAJOR >= 9
|
||||
FunctionCallee FuncPtr;
|
||||
#else
|
||||
Function *FuncPtr;
|
||||
#endif
|
||||
|
||||
/* iterate over all functions, bbs and instruction and add suitable calls */
|
||||
for (auto &F : M) {
|
||||
|
||||
if (!isInInstrumentList(&F, MNAME)) continue;
|
||||
|
||||
for (auto &BB : F) {
|
||||
|
||||
for (auto &IN : BB) {
|
||||
|
||||
CallInst *callInst = nullptr;
|
||||
|
||||
if ((callInst = dyn_cast<CallInst>(&IN))) {
|
||||
|
||||
Function *Callee = callInst->getCalledFunction();
|
||||
if (!Callee) continue;
|
||||
if (callInst->getCallingConv() != llvm::CallingConv::C) continue;
|
||||
|
||||
std::string FuncName = Callee->getName().str();
|
||||
FuncPtr = nullptr;
|
||||
size_t param = 0;
|
||||
|
||||
// Marker: ADD_TO_INJECTIONS
|
||||
// If you just need to add another function to test for SQL etc.
|
||||
// then add them here.
|
||||
// To add a new class or to work on e.g. std::string/Rust strings/...
|
||||
// you will need to add a function to afl-compiler-rt.c.o and
|
||||
// and upwards in this file add a pointer to that function to use
|
||||
// here.
|
||||
|
||||
if (doSQL &&
|
||||
(FuncName.compare("sqlite3_exec") == 0 ||
|
||||
FuncName.compare("PQexec") == 0 || FuncName.compare("") == 0 ||
|
||||
FuncName.compare("PQexecParams") == 0 ||
|
||||
FuncName.compare("mysql_query") == 0)) {
|
||||
|
||||
if (!be_quiet) {
|
||||
|
||||
errs() << "Injection SQL hook: " << FuncName << "\n";
|
||||
|
||||
}
|
||||
|
||||
FuncPtr = sqlfunc;
|
||||
param = 1;
|
||||
|
||||
}
|
||||
|
||||
if (doLDAP && (FuncName.compare("ldap_search_ext") == 0 ||
|
||||
FuncName.compare("ldap_search_ext_s") == 0)) {
|
||||
|
||||
if (!be_quiet) {
|
||||
|
||||
errs() << "Injection LDAP hook: " << FuncName << "\n";
|
||||
|
||||
}
|
||||
|
||||
FuncPtr = ldapfunc;
|
||||
param = 1;
|
||||
|
||||
}
|
||||
|
||||
if (doXSS && (FuncName.compare("htmlReadMemory") == 0)) {
|
||||
|
||||
if (!be_quiet) {
|
||||
|
||||
errs() << "Injection XSS hook: " << FuncName << "\n";
|
||||
|
||||
}
|
||||
|
||||
FuncPtr = xssfunc;
|
||||
param = 1;
|
||||
|
||||
}
|
||||
|
||||
if (FuncPtr) {
|
||||
|
||||
IRBuilder<> IRB(callInst->getParent());
|
||||
IRB.SetInsertPoint(callInst);
|
||||
|
||||
Value *parameter = callInst->getArgOperand(param);
|
||||
|
||||
std::vector<Value *> args;
|
||||
Value *casted = IRB.CreatePointerCast(parameter, i8PtrTy);
|
||||
args.push_back(casted);
|
||||
IRB.CreateCall(FuncPtr, args);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
#if LLVM_VERSION_MAJOR >= 11 /* use new pass manager */
|
||||
PreservedAnalyses InjectionRoutines::run(Module &M,
|
||||
ModuleAnalysisManager &MAM) {
|
||||
|
||||
#else
|
||||
bool InjectionRoutines::runOnModule(Module &M) {
|
||||
|
||||
#endif
|
||||
|
||||
if (getenv("AFL_QUIET") == NULL)
|
||||
printf("Running injection-pass by Marc Heuse (mh@mh-sec.de)\n");
|
||||
else
|
||||
be_quiet = 1;
|
||||
if (getenv("AFL_LLVM_INJECTIONS_ALL")) {
|
||||
|
||||
doSQL = true;
|
||||
doLDAP = true;
|
||||
doXSS = true;
|
||||
|
||||
}
|
||||
|
||||
if (getenv("AFL_LLVM_INJECTIONS_SQL")) { doSQL = true; }
|
||||
if (getenv("AFL_LLVM_INJECTIONS_LDAP")) { doLDAP = true; }
|
||||
if (getenv("AFL_LLVM_INJECTIONS_XSS")) { doXSS = true; }
|
||||
|
||||
hookRtns(M);
|
||||
#if LLVM_VERSION_MAJOR >= 11 /* use new pass manager */
|
||||
auto PA = PreservedAnalyses::all();
|
||||
#endif
|
||||
verifyModule(M);
|
||||
|
||||
#if LLVM_VERSION_MAJOR >= 11 /* use new pass manager */
|
||||
return PA;
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#if LLVM_VERSION_MAJOR < 11 /* use old pass manager */
|
||||
static void registerInjectionRoutinesPass(const PassManagerBuilder &,
|
||||
legacy::PassManagerBase &PM) {
|
||||
|
||||
auto p = new InjectionRoutines();
|
||||
PM.add(p);
|
||||
|
||||
}
|
||||
|
||||
static RegisterStandardPasses RegisterInjectionRoutinesPass(
|
||||
PassManagerBuilder::EP_OptimizerLast, registerInjectionRoutinesPass);
|
||||
|
||||
static RegisterStandardPasses RegisterInjectionRoutinesPass0(
|
||||
PassManagerBuilder::EP_EnabledOnOptLevel0, registerInjectionRoutinesPass);
|
||||
|
||||
#if LLVM_VERSION_MAJOR >= 11
|
||||
static RegisterStandardPasses RegisterInjectionRoutinesPassLTO(
|
||||
PassManagerBuilder::EP_FullLinkTimeOptimizationLast,
|
||||
registerInjectionRoutinesPass);
|
||||
#endif
|
||||
#endif
|
||||
|
@ -1584,7 +1584,7 @@ size_t SplitComparesTransform::splitFPCompares(Module &M) {
|
||||
CmpInst::Create(Instruction::ICmp, CmpInst::ICMP_UGT, t_f0, t_f1);
|
||||
#if LLVM_MAJOR >= 16
|
||||
icmp_fraction_result->insertInto(negative_bb, negative_bb->end());
|
||||
icmp_fraction_result2->insertInto(positive_bb, negative_bb->end());
|
||||
icmp_fraction_result2->insertInto(positive_bb, positive_bb->end());
|
||||
#else
|
||||
negative_bb->getInstList().push_back(icmp_fraction_result);
|
||||
positive_bb->getInstList().push_back(icmp_fraction_result2);
|
||||
@ -1598,7 +1598,7 @@ size_t SplitComparesTransform::splitFPCompares(Module &M) {
|
||||
CmpInst::Create(Instruction::ICmp, CmpInst::ICMP_ULT, t_f0, t_f1);
|
||||
#if LLVM_MAJOR >= 16
|
||||
icmp_fraction_result->insertInto(negative_bb, negative_bb->end());
|
||||
icmp_fraction_result2->insertInto(positive_bb, negative_bb->end());
|
||||
icmp_fraction_result2->insertInto(positive_bb, positive_bb->end());
|
||||
#else
|
||||
negative_bb->getInstList().push_back(icmp_fraction_result);
|
||||
positive_bb->getInstList().push_back(icmp_fraction_result2);
|
||||
@ -1707,12 +1707,6 @@ bool SplitComparesTransform::runOnModule(Module &M) {
|
||||
|
||||
#endif
|
||||
|
||||
char *bitw_env = getenv("AFL_LLVM_LAF_SPLIT_COMPARES_BITW");
|
||||
if (!bitw_env) bitw_env = getenv("LAF_SPLIT_COMPARES_BITW");
|
||||
if (bitw_env) { target_bitwidth = atoi(bitw_env); }
|
||||
|
||||
enableFPSplit = getenv("AFL_LLVM_LAF_SPLIT_FLOATS") != NULL;
|
||||
|
||||
if ((isatty(2) && getenv("AFL_QUIET") == NULL) ||
|
||||
getenv("AFL_DEBUG") != NULL) {
|
||||
|
||||
@ -1728,6 +1722,27 @@ bool SplitComparesTransform::runOnModule(Module &M) {
|
||||
|
||||
}
|
||||
|
||||
char *bitw_env = getenv("AFL_LLVM_LAF_SPLIT_COMPARES_BITW");
|
||||
if (!bitw_env) bitw_env = getenv("LAF_SPLIT_COMPARES_BITW");
|
||||
if (bitw_env) { target_bitwidth = atoi(bitw_env); }
|
||||
|
||||
if (getenv("AFL_LLVM_LAF_SPLIT_FLOATS")) { enableFPSplit = true; }
|
||||
|
||||
bool split_comp = false;
|
||||
|
||||
if (getenv("AFL_LLVM_LAF_SPLIT_COMPARES")) {
|
||||
|
||||
#if LLVM_MAJOR == 17
|
||||
if (!be_quiet)
|
||||
fprintf(stderr,
|
||||
"WARNING: AFL++ splitting integer comparisons is disabled in "
|
||||
"LLVM 17 due bugs, switch to 16 or 18!\n");
|
||||
#else
|
||||
split_comp = true;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#if LLVM_MAJOR >= 11
|
||||
auto PA = PreservedAnalyses::all();
|
||||
#endif
|
||||
@ -1746,36 +1761,40 @@ bool SplitComparesTransform::runOnModule(Module &M) {
|
||||
|
||||
}
|
||||
|
||||
std::vector<CmpInst *> worklist;
|
||||
/* iterate over all functions, bbs and instruction search for all integer
|
||||
* compare instructions. Save them into the worklist for later. */
|
||||
for (auto &F : M) {
|
||||
if (split_comp) {
|
||||
|
||||
if (!isInInstrumentList(&F, MNAME)) continue;
|
||||
std::vector<CmpInst *> worklist;
|
||||
/* iterate over all functions, bbs and instruction search for all integer
|
||||
* compare instructions. Save them into the worklist for later. */
|
||||
for (auto &F : M) {
|
||||
|
||||
for (auto &BB : F) {
|
||||
if (!isInInstrumentList(&F, MNAME)) continue;
|
||||
|
||||
for (auto &IN : BB) {
|
||||
for (auto &BB : F) {
|
||||
|
||||
if (auto CI = dyn_cast<CmpInst>(&IN)) {
|
||||
for (auto &IN : BB) {
|
||||
|
||||
auto op0 = CI->getOperand(0);
|
||||
auto op1 = CI->getOperand(1);
|
||||
if (!op0 || !op1) {
|
||||
if (auto CI = dyn_cast<CmpInst>(&IN)) {
|
||||
|
||||
auto op0 = CI->getOperand(0);
|
||||
auto op1 = CI->getOperand(1);
|
||||
if (!op0 || !op1) {
|
||||
|
||||
#if LLVM_MAJOR >= 11
|
||||
return PA;
|
||||
return PA;
|
||||
#else
|
||||
return false;
|
||||
return false;
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
auto iTy1 = dyn_cast<IntegerType>(op0->getType());
|
||||
if (iTy1 && isa<IntegerType>(op1->getType())) {
|
||||
auto iTy1 = dyn_cast<IntegerType>(op0->getType());
|
||||
if (iTy1 && isa<IntegerType>(op1->getType())) {
|
||||
|
||||
unsigned bitw = iTy1->getBitWidth();
|
||||
if (isSupportedBitWidth(bitw)) { worklist.push_back(CI); }
|
||||
unsigned bitw = iTy1->getBitWidth();
|
||||
if (isSupportedBitWidth(bitw)) { worklist.push_back(CI); }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1785,13 +1804,13 @@ bool SplitComparesTransform::runOnModule(Module &M) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
// now that we have a list of all integer comparisons we can start replacing
|
||||
// them with the splitted alternatives.
|
||||
for (auto CI : worklist) {
|
||||
|
||||
// now that we have a list of all integer comparisons we can start replacing
|
||||
// them with the splitted alternatives.
|
||||
for (auto CI : worklist) {
|
||||
simplifyAndSplit(CI, M);
|
||||
|
||||
simplifyAndSplit(CI, M);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1 +1 @@
|
||||
512058a
|
||||
6833d23
|
||||
|
Submodule nyx_mode/QEMU-Nyx updated: 60c216bc9e...e5e1c4c21f
@ -1 +1 @@
|
||||
02a6f2aed3
|
||||
e5e1c4c21ff9c4dc80e6409d4eab47146c6024cd
|
||||
|
@ -84,9 +84,17 @@ Then the final step: we generate the Nyx package configuration:
|
||||
python3 nyx_mode/packer/packer/nyx_config_gen.py PACKAGE-DIRECTORY Kernel
|
||||
```
|
||||
|
||||
|
||||
## Fuzzing with Nyx mode
|
||||
|
||||
Note that you need to load the kvm kernel modules for Nyx:
|
||||
```
|
||||
sudo modprobe -r kvm-intel
|
||||
sudo modprobe -r kvm
|
||||
sudo modprobe kvm enable_vmware_backdoor=y
|
||||
sudo modprobe kvm-intel
|
||||
cat /sys/module/kvm/parameters/enable_vmware_backdoor | grep -q Y && echi OK || echo KVM module problem
|
||||
```
|
||||
|
||||
All the hard parts are done, fuzzing with Nyx mode is easy - just supply the
|
||||
`PACKAGE-DIRECTORY` as fuzzing target and specify the `-X` option to afl-fuzz:
|
||||
|
||||
@ -94,16 +102,8 @@ All the hard parts are done, fuzzing with Nyx mode is easy - just supply the
|
||||
afl-fuzz -i in -o out -X -- ./PACKAGE-DIRECTORY
|
||||
```
|
||||
|
||||
Most likely your first run will fail because the Linux modules have to be
|
||||
specially set up, but afl-fuzz will tell you this on startup and how to rectify
|
||||
the situation:
|
||||
|
||||
```
|
||||
sudo modprobe -r kvm-intel # or kvm-amd for AMD processors
|
||||
sudo modprobe -r kvm
|
||||
sudo modprobe kvm enable_vmware_backdoor=y
|
||||
sudo modprobe kvm-intel # or kvm-amd for AMD processors
|
||||
```
|
||||
If you get a forkserver error upon starting then you did not load the Linux
|
||||
kvm kernel modules, see above.
|
||||
|
||||
If you want to fuzz in parallel (and you should!), then this has to be done in a
|
||||
special way:
|
||||
|
@ -9,6 +9,21 @@ echo
|
||||
|
||||
echo "[*] Performing basic sanity checks..."
|
||||
|
||||
if [ "$CI" = "true" ]; then
|
||||
|
||||
echo "[-] Error: nyx_mode cannot be tested in the Github CI, skipping ..."
|
||||
exit 0
|
||||
|
||||
fi
|
||||
|
||||
|
||||
if [ -n "$NO_NYX" ]; then
|
||||
|
||||
echo "[-] Error: the NO_NYX environment variable is set, please unset."
|
||||
exit 0
|
||||
|
||||
fi
|
||||
|
||||
if [ ! "$(uname -s)" = "Linux" ]; then
|
||||
|
||||
echo "[-] Error: Nyx mode is only available on Linux."
|
||||
@ -23,11 +38,17 @@ if [ ! "$(uname -m)" = "x86_64" ]; then
|
||||
|
||||
fi
|
||||
|
||||
cargo help > /dev/null 2>&1 || {
|
||||
echo "[-] Error: Rust is not installed."
|
||||
exit 0
|
||||
}
|
||||
|
||||
echo "[*] Making sure all Nyx is checked out"
|
||||
|
||||
|
||||
if git status 1>/dev/null 2>&1; then
|
||||
|
||||
set +e
|
||||
git submodule init
|
||||
echo "[*] initializing QEMU-Nyx submodule"
|
||||
git submodule update ./QEMU-Nyx 2>/dev/null # ignore errors
|
||||
@ -35,6 +56,7 @@ if git status 1>/dev/null 2>&1; then
|
||||
git submodule update ./packer 2>/dev/null # ignore errors
|
||||
echo "[*] initializing libnyx submodule"
|
||||
git submodule update ./libnyx 2>/dev/null # ignore errors
|
||||
set -e
|
||||
|
||||
else
|
||||
|
||||
@ -48,20 +70,57 @@ test -e packer/.git || { echo "[-] packer not checked out, please install git or
|
||||
test -e libnyx/.git || { echo "[-] libnyx not checked out, please install git or check your internet connection." ; exit 1 ; }
|
||||
test -e QEMU-Nyx/.git || { echo "[-] QEMU-Nyx not checked out, please install git or check your internet connection." ; exit 1 ; }
|
||||
|
||||
echo "[*] checking packer init.cpio.gz ..."
|
||||
if [ ! -f "packer/linux_initramfs/init.cpio.gz" ]; then
|
||||
(cd packer/linux_initramfs/ && sh pack.sh)
|
||||
|
||||
QEMU_NYX_VERSION="$(cat ./QEMU_NYX_VERSION)"
|
||||
cd "./QEMU-Nyx" || exit 1
|
||||
if [ -n "$NO_CHECKOUT" ]; then
|
||||
echo "[*] Skipping checkout to $QEMU_NYX_VERSION"
|
||||
else
|
||||
echo "[*] Checking out $QEMU_NYX_VERSION"
|
||||
set +e
|
||||
sh -c 'git stash' 1>/dev/null 2>/dev/null
|
||||
git pull 1>/dev/null 2>/dev/null
|
||||
git checkout "$QEMU_NYX_VERSION" || echo Warning: could not check out to commit $QEMU_NYX_VERSION
|
||||
set -e
|
||||
fi
|
||||
cd - > /dev/null
|
||||
|
||||
PACKER_VERSION="$(cat ./PACKER_VERSION)"
|
||||
cd "./packer" || exit 1
|
||||
if [ -n "$NO_CHECKOUT" ]; then
|
||||
echo "[*] Skipping checkout to $PACKER_VERSION"
|
||||
else
|
||||
echo "[*] Checking out $PACKER_VERSION"
|
||||
set +e
|
||||
sh -c 'git stash' 1>/dev/null 2>/dev/null
|
||||
git pull 1>/dev/null 2>/dev/null
|
||||
git checkout "$PACKER_VERSION" || echo Warning: could not check out to commit $PACKER_VERSION
|
||||
set -e
|
||||
fi
|
||||
cd - > /dev/null
|
||||
|
||||
LIBNYX_VERSION="$(cat ./LIBNYX_VERSION)"
|
||||
cd "./libnyx/" || exit 1
|
||||
if [ -n "$NO_CHECKOUT" ]; then
|
||||
echo "[*] Skipping checkout to $LIBNYX_VERSION"
|
||||
else
|
||||
echo "[*] Checking out $LIBNYX_VERSION"
|
||||
set +e
|
||||
sh -c 'git stash' 1>/dev/null 2>/dev/null
|
||||
git pull 1>/dev/null 2>/dev/null
|
||||
git checkout "$LIBNYX_VERSION" || echo Warning: could not check out to commit $LIBNYX_VERSION
|
||||
set -e
|
||||
fi
|
||||
cd - > /dev/null
|
||||
|
||||
echo "[*] checking packer init.cpio.gz ..."
|
||||
(cd packer/linux_initramfs/ && sh pack.sh)
|
||||
|
||||
echo "[*] Checking libnyx ..."
|
||||
if [ ! -f "libnyx/libnyx/target/release/liblibnyx.a" ]; then
|
||||
(cd libnyx/libnyx && cargo build --release)
|
||||
fi
|
||||
(cd libnyx/libnyx && cargo build --release)
|
||||
|
||||
echo "[*] Checking QEMU-Nyx ..."
|
||||
if [ ! -f "QEMU-Nyx/x86_64-softmmu/qemu-system-x86_64" ]; then
|
||||
(cd QEMU-Nyx && ./compile_qemu_nyx.sh static)
|
||||
fi
|
||||
(cd QEMU-Nyx && ./compile_qemu_nyx.sh static )
|
||||
|
||||
echo "[*] Checking libnyx.so ..."
|
||||
cp libnyx/libnyx/target/release/liblibnyx.so ../libnyx.so
|
||||
|
Submodule nyx_mode/libnyx updated: 2da7f08b6e...6833d236df
Submodule nyx_mode/packer updated: 202bace888...bcf3e248b6
@ -41,7 +41,7 @@ cd ..
|
||||
rm "$UC_VERSION_FILE"
|
||||
echo "$NEW_VERSION" > "$UC_VERSION_FILE"
|
||||
|
||||
echo "Done. New XXX version is $NEW_VERSION."
|
||||
echo "Done. New libnyx version is $NEW_VERSION."
|
||||
|
||||
|
||||
UC_VERSION_FILE='./PACKER_VERSION'
|
||||
@ -68,7 +68,7 @@ cd ..
|
||||
rm "$UC_VERSION_FILE"
|
||||
echo "$NEW_VERSION" > "$UC_VERSION_FILE"
|
||||
|
||||
echo "Done. New XXX version is $NEW_VERSION."
|
||||
echo "Done. New packer version is $NEW_VERSION."
|
||||
|
||||
|
||||
UC_VERSION_FILE='./QEMU_NYX_VERSION'
|
||||
@ -95,5 +95,5 @@ cd ..
|
||||
rm "$UC_VERSION_FILE"
|
||||
echo "$NEW_VERSION" > "$UC_VERSION_FILE"
|
||||
|
||||
echo "Done. New XXX version is $NEW_VERSION."
|
||||
echo "Done. New QEMU-Nyx version is $NEW_VERSION."
|
||||
|
||||
|
@ -1 +1 @@
|
||||
a1321713c7
|
||||
e63c9af193
|
||||
|
@ -193,12 +193,39 @@ Comparative measurements of execution speed or instrumentation coverage will be
|
||||
fairly meaningless if the optimization levels or instrumentation scopes don't
|
||||
match.
|
||||
|
||||
## 12) Other features
|
||||
## 12) Coverage information
|
||||
|
||||
Coverage information about a run of a target binary can be obtained using a
|
||||
dedicated QEMU user mode plugin enabled at runtime: the `drcov.c` plugin
|
||||
collects coverage information from the target binary and writes it in the Drcov
|
||||
format. This file can then be loaded using tools such as
|
||||
[lighthouse](https://github.com/gaasedelen/lighthouse),
|
||||
[lightkeeper](https://github.com/WorksButNotTested/lightkeeper) or
|
||||
[Cartographer](https://github.com/nccgroup/Cartographer).
|
||||
|
||||
To compile the QEMU TCG plugins, run the following command from the `qemuafl`
|
||||
directory:
|
||||
|
||||
```
|
||||
make plugins
|
||||
```
|
||||
|
||||
Plugins can be loaded using either the `QEMU_PLUGIN` environment variable or
|
||||
using the `-plugin` option. For example:
|
||||
|
||||
```
|
||||
afl-qemu-trace -plugin qemuafl/build/contrib/plugins/libdrcov.so,arg=filename=/tmp/target.drcov.trace <target> <args>
|
||||
```
|
||||
|
||||
This would execute the target binary with the provided arguments and, once done,
|
||||
would write coverage information at `/tmp/target.drcov.trace`.
|
||||
|
||||
## 13) Other features
|
||||
|
||||
With `AFL_QEMU_FORCE_DFL`, you force QEMU to ignore the registered signal
|
||||
handlers of the target.
|
||||
|
||||
## 13) Gotchas, feedback, bugs
|
||||
## 14) Gotchas, feedback, bugs
|
||||
|
||||
If you need to fix up checksums or do other cleanups on mutated test cases, see
|
||||
`afl_custom_post_process` in custom_mutators/examples/example.c for a viable
|
||||
@ -217,7 +244,7 @@ program may be utilizing. In particular, it does not appear to have full support
|
||||
for AVX2/FMA3. Using binaries for older CPUs or recompiling them with
|
||||
`-march=core2`, can help.
|
||||
|
||||
## 14) Alternatives: static rewriting
|
||||
## 15) Alternatives: static rewriting
|
||||
|
||||
Statically rewriting binaries just once, instead of attempting to translate them
|
||||
at run time, can be a faster alternative. That said, static rewriting is fraught
|
||||
|
@ -13,7 +13,7 @@
|
||||
# counters by Andrea Fioraldi <andreafioraldi@gmail.com>
|
||||
#
|
||||
# Copyright 2015, 2016, 2017 Google Inc. All rights reserved.
|
||||
# Copyright 2019-2023 AFLplusplus Project. All rights reserved.
|
||||
# Copyright 2019-2024 AFLplusplus Project. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@ -132,7 +132,10 @@ echo "Building for CPU target $CPU_TARGET"
|
||||
|
||||
# --enable-pie seems to give a couple of exec's a second performance
|
||||
# improvement, much to my surprise. Not sure how universal this is..
|
||||
# --enable-plugins allows loading TCG plugins at runtime, for example to obtain
|
||||
# coverage information, and does not seem to negatively impact performance
|
||||
QEMU_CONF_FLAGS=" \
|
||||
--enable-plugins \
|
||||
--audio-drv-list= \
|
||||
--disable-blobs \
|
||||
--disable-bochs \
|
||||
@ -162,7 +165,6 @@ QEMU_CONF_FLAGS=" \
|
||||
--disable-numa \
|
||||
--disable-opengl \
|
||||
--disable-parallels \
|
||||
--disable-plugins \
|
||||
--disable-qcow1 \
|
||||
--disable-qed \
|
||||
--disable-rbd \
|
||||
|
@ -4,7 +4,7 @@
|
||||
#
|
||||
# Written by Andrea Fioraldi <andreafioraldi@gmail.com>
|
||||
#
|
||||
# Copyright 2019-2023 Andrea Fioraldi. All rights reserved.
|
||||
# Copyright 2019-2024 Andrea Fioraldi. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -4,7 +4,7 @@
|
||||
#
|
||||
# Written by Andrea Fioraldi <andreafioraldi@gmail.com>
|
||||
#
|
||||
# Copyright 2019-2023 Andrea Fioraldi. All rights reserved.
|
||||
# Copyright 2019-2024 Andrea Fioraldi. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// Author: Mateusz Jurczyk (mjurczyk@google.com)
|
||||
//
|
||||
// Copyright 2019-2023 Google LLC
|
||||
// Copyright 2019-2024 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
Written and maintained by Andrea Fioraldi <andreafioraldi@gmail.com>
|
||||
|
||||
Copyright 2019-2023 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2024 AFLplusplus Project. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
@ -4,7 +4,7 @@
|
||||
#
|
||||
# Written by Andrea Fioraldi <andreafioraldi@gmail.com>
|
||||
#
|
||||
# Copyright 2019-2023 Andrea Fioraldi. All rights reserved.
|
||||
# Copyright 2019-2024 Andrea Fioraldi. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
Copyright (c) 2019-2023, Andrea Fioraldi
|
||||
Copyright (c) 2019-2024, Andrea Fioraldi
|
||||
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
Copyright (c) 2019-2023, Andrea Fioraldi
|
||||
Copyright (c) 2019-2024, Andrea Fioraldi
|
||||
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
Copyright (c) 2019-2023, Andrea Fioraldi
|
||||
Copyright (c) 2019-2024, Andrea Fioraldi
|
||||
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
Copyright (c) 2019-2023, Andrea Fioraldi
|
||||
Copyright (c) 2019-2024, Andrea Fioraldi
|
||||
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
Copyright (c) 2019-2023, Andrea Fioraldi
|
||||
Copyright (c) 2019-2024, Andrea Fioraldi
|
||||
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
Copyright (c) 2019-2023, Andrea Fioraldi
|
||||
Copyright (c) 2019-2024, Andrea Fioraldi
|
||||
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
@ -7,7 +7,7 @@ for some strange reason.
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
Copyright (c) 2019-2023, Andrea Fioraldi
|
||||
Copyright (c) 2019-2024, Andrea Fioraldi
|
||||
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
Submodule qemu_mode/qemuafl updated: b0abbe2e74...e63c9af193
@ -4,7 +4,7 @@
|
||||
#
|
||||
# Written by Andrea Fioraldi <andreafioraldi@gmail.com>
|
||||
#
|
||||
# Copyright 2019-2023 Andrea Fioraldi. All rights reserved.
|
||||
# Copyright 2019-2024 Andrea Fioraldi. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
# Copyright 2023 AFLplusplus
|
||||
# Copyright 2024 AFLplusplus
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user