mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-24 22:53:24 +00:00
Compare commits
309 Commits
Author | SHA1 | Date | |
---|---|---|---|
a326c23210 | |||
7f734c96d1 | |||
4d29e484b7 | |||
56f7e3aa08 | |||
87b9dc4ba0 | |||
d0b86bf055 | |||
0a699d885b | |||
61aeb44863 | |||
d213071e13 | |||
6d4234b305 | |||
059d470e8d | |||
47833bcf9e | |||
2f6242d3f8 | |||
120d009e7d | |||
e12acaa203 | |||
8f6d9d66ef | |||
2b81d2d63f | |||
50678ed369 | |||
9764483693 | |||
0c4f0dd4c4 | |||
b5f7f42cd0 | |||
c34c3e2f5f | |||
4f6ec6cb08 | |||
a96cdc649f | |||
e2fedce6ec | |||
afc47868ee | |||
eefd98f374 | |||
2adf5aac0f | |||
f756734ad2 | |||
6cc8d607fb | |||
824385f52c | |||
d304f4e4f1 | |||
4f2d9eeaaa | |||
743ae50775 | |||
a5a122a533 | |||
1589e17213 | |||
9e3e1a5512 | |||
a0818c4fce | |||
0782ed3841 | |||
0911525194 | |||
0eace0212e | |||
c1af004451 | |||
abd6b06fa4 | |||
35151cefe8 | |||
75d7a09469 | |||
f9851dbfbb | |||
d67ee17778 | |||
dba93705a7 | |||
36127fb197 | |||
5fea071ae9 | |||
a01138e1c8 | |||
319b2e8e6f | |||
e46e0bce44 | |||
4d02d8e43d | |||
be96253f52 | |||
2d0d1e267e | |||
a061e1304d | |||
dbdf2d79f2 | |||
48816417ee | |||
661b626c87 | |||
214e24fff0 | |||
67e8c4f100 | |||
5d9c1bc3a3 | |||
c594a58583 | |||
01236f47bc | |||
b1bfc1ae76 | |||
0faa323f12 | |||
2d3c5cc6d8 | |||
7101192865 | |||
19f9612910 | |||
d955409178 | |||
9bc5abc4ec | |||
64fd01d46c | |||
b2f9802f9f | |||
e24ae96361 | |||
0f62e0b167 | |||
478f0bbc1e | |||
3d7bad99b6 | |||
5c5b73df82 | |||
24503fba5f | |||
d80cedcf02 | |||
bd3855fe5d | |||
84274f2e5d | |||
988028bb3b | |||
ac4dd1605e | |||
7ab689ef0e | |||
e32e825372 | |||
c3cf918bcb | |||
af77dab666 | |||
1d4f779d4d | |||
4c7c78d926 | |||
aabfe781fd | |||
7a650e4866 | |||
30483919eb | |||
5221938945 | |||
dc7ef967d8 | |||
1385c24a7d | |||
cd57641705 | |||
e0866f51c7 | |||
aa125f8246 | |||
b571e88bd3 | |||
2f128e0dbd | |||
e5f8c7a612 | |||
e6a05382b8 | |||
cb8296bdb0 | |||
6b75fe1831 | |||
a30664c563 | |||
7034348c57 | |||
e9e440d7f3 | |||
5e7f8a51e0 | |||
403d95d2d2 | |||
07cf27cddc | |||
bc61c90fb6 | |||
6af195916c | |||
7c07437941 | |||
85fa17451d | |||
12262d3a63 | |||
2ff0ff7a90 | |||
d8ba0caab3 | |||
86bf009792 | |||
ea14f3fd40 | |||
2b5c9954f6 | |||
65d4d10762 | |||
2bea77e28a | |||
add2eb42c0 | |||
ffdb5ec9b1 | |||
eb5c1ee4f3 | |||
eeccb2da69 | |||
0c0a6c3bfa | |||
a293281b9b | |||
8a8e350f34 | |||
c33f8751e3 | |||
6f4b5ae083 | |||
91b7f1c9f2 | |||
b786558dea | |||
ebaac23a51 | |||
9da3a2ed45 | |||
1faf6f6731 | |||
7f2bafbb8b | |||
ae94499503 | |||
04356ecbbe | |||
2090f17a9b | |||
668f5e1fa9 | |||
a7c43484e1 | |||
b352e3d1cc | |||
8bc3fa1df2 | |||
80eabd6e8a | |||
5a0100c6ee | |||
54fa78d32c | |||
61439859ce | |||
240f6421d8 | |||
7eaef449a1 | |||
3881ccd0b7 | |||
6030df2f56 | |||
141c324eb9 | |||
bac8d25bc2 | |||
d3cdeabf92 | |||
673a0a3866 | |||
f2be73186e | |||
025f617d6a | |||
c86d06849b | |||
05b1189a55 | |||
846e910e0c | |||
ab26356bf7 | |||
03e6d33a40 | |||
6596284cc4 | |||
dbfa23b40a | |||
1a9f96858b | |||
24e36212d5 | |||
ca2e8a1bf6 | |||
ca063c92d2 | |||
8a2547073c | |||
e612028255 | |||
f99656e22b | |||
90f61552f7 | |||
ec87abda93 | |||
e1434bcfcd | |||
53c19a807c | |||
3a6dea420f | |||
df9ef84f5e | |||
25b4b32627 | |||
4946e9cc3a | |||
f01bf77604 | |||
91ccbf3f68 | |||
686382c328 | |||
0d55feb11d | |||
31727f36a8 | |||
b5d8d4c866 | |||
b81bc8eb6f | |||
47f35d29ac | |||
4a54555a1a | |||
3e8a691a81 | |||
33eba1fc56 | |||
4ec26fc7cb | |||
5db7be5ee2 | |||
614265897c | |||
f4a13585a1 | |||
e332d37d4e | |||
90a259d523 | |||
322e5e2fb6 | |||
1b4e1d75b3 | |||
c52a0a15c8 | |||
c5a84a124c | |||
16f71bfa24 | |||
b0898de377 | |||
0251b9bfd8 | |||
5837322310 | |||
4063a3eb4c | |||
8bc7b3cf26 | |||
afd2ea90df | |||
bd2cb4cd1c | |||
67cfe4f6d4 | |||
628b4b6002 | |||
86d3c65559 | |||
afff6f642c | |||
eeca3a0b29 | |||
151a8facae | |||
45567791c6 | |||
17752465e6 | |||
14d8eb9e40 | |||
8fe5e29104 | |||
22f757a169 | |||
0db662db7b | |||
70f4b456fa | |||
a41fd5cc5c | |||
efe57c9368 | |||
33f41e3974 | |||
4b915207c4 | |||
8cc1c6c54e | |||
10b82c7277 | |||
35801bed7a | |||
5163a49350 | |||
7abbc8d740 | |||
9548af52b2 | |||
e3dadbfe0f | |||
75fb918a37 | |||
c3d7612c97 | |||
e2acba57bf | |||
e4b7c4e6c9 | |||
e4ff0ebd56 | |||
3b6fcd911a | |||
a3b56e7280 | |||
57e7408774 | |||
462e55da0c | |||
a8b6365a90 | |||
aa39921e49 | |||
885a6fc106 | |||
db9fc49ef8 | |||
94d1740390 | |||
1c91d8ca79 | |||
081c480e36 | |||
8d9620eca2 | |||
35f09e11a4 | |||
026404c452 | |||
ffe89e8f2d | |||
31d4dc8a38 | |||
e847b9948d | |||
1bcc9bfa91 | |||
8817da8ae4 | |||
1149b13185 | |||
fd27b2c9be | |||
5670c847bd | |||
99c67defb4 | |||
209527907f | |||
489f2d4d97 | |||
0710e4f17c | |||
c090abb00d | |||
107ebb7d49 | |||
4ff37da709 | |||
86ec1b9d71 | |||
c0c985a278 | |||
f28f6adbce | |||
51e0707d4d | |||
3188cac1d0 | |||
b189640a92 | |||
3d031f93a6 | |||
3a134edd88 | |||
6e5c08b653 | |||
67ae1d5839 | |||
b4000dda8d | |||
0062a14aa3 | |||
4626435dbf | |||
a0eee2bd92 | |||
6fe38b2138 | |||
342081d5ee | |||
65729a2637 | |||
401811a97d | |||
60dc37a8cf | |||
0165ca8c6c | |||
96f05c7f69 | |||
195bf87f18 | |||
e30c20cd28 | |||
e26c173041 | |||
85b44bb730 | |||
42e6f98005 | |||
e02753fd7d | |||
bf1617d354 | |||
149366507d | |||
9239ab01df | |||
0885dda767 | |||
6dd9764cf6 | |||
b5f2a17235 | |||
32a331ab43 | |||
28af7cb9bd | |||
9734d0b3c0 | |||
8cdc48f73a | |||
2d640558a0 | |||
340647c5f1 | |||
a075cddef6 |
@ -3,10 +3,10 @@
|
||||
# american fuzzy lop++ - custom code formatter
|
||||
# --------------------------------------------
|
||||
#
|
||||
# Written and maintaned by Andrea Fioraldi <andreafioraldi@gmail.com>
|
||||
# Written and maintained by Andrea Fioraldi <andreafioraldi@gmail.com>
|
||||
#
|
||||
# Copyright 2015, 2016, 2017 Google Inc. All rights reserved.
|
||||
# Copyright 2019-2022 AFLplusplus Project. All rights reserved.
|
||||
# Copyright 2019-2023 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.
|
||||
@ -18,24 +18,57 @@
|
||||
import subprocess
|
||||
import sys
|
||||
import os
|
||||
import re
|
||||
# import re # TODO: for future use
|
||||
import shutil
|
||||
import importlib.metadata
|
||||
|
||||
# string_re = re.compile('(\\"(\\\\.|[^"\\\\])*\\")') # future use
|
||||
|
||||
with open(".clang-format") as f:
|
||||
fmt = f.read()
|
||||
# string_re = re.compile('(\\"(\\\\.|[^"\\\\])*\\")') # TODO: for future use
|
||||
|
||||
CURRENT_LLVM = os.getenv('LLVM_VERSION', 14)
|
||||
CLANG_FORMAT_BIN = os.getenv("CLANG_FORMAT_BIN", "")
|
||||
|
||||
|
||||
def check_clang_format_pip_version():
|
||||
"""
|
||||
Check if the correct version of clang-format is installed via pip.
|
||||
|
||||
Returns:
|
||||
bool: True if the correct version of clang-format is installed,
|
||||
False otherwise.
|
||||
"""
|
||||
# Check if clang-format is installed
|
||||
if importlib.util.find_spec('clang_format'):
|
||||
# Check if the installed version is the expected LLVM version
|
||||
if importlib.metadata.version('clang-format')\
|
||||
.startswith(str(CURRENT_LLVM)+'.'):
|
||||
return True
|
||||
else:
|
||||
# Return False, because the clang-format version does not match
|
||||
return False
|
||||
else:
|
||||
# If the 'clang_format' package isn't installed, return False
|
||||
return False
|
||||
|
||||
|
||||
with open(".clang-format") as f:
|
||||
fmt = f.read()
|
||||
|
||||
|
||||
CLANG_FORMAT_PIP = check_clang_format_pip_version()
|
||||
|
||||
if shutil.which(CLANG_FORMAT_BIN) is None:
|
||||
CLANG_FORMAT_BIN = f"clang-format-{CURRENT_LLVM}"
|
||||
|
||||
if shutil.which(CLANG_FORMAT_BIN) is None:
|
||||
if shutil.which(CLANG_FORMAT_BIN) is None \
|
||||
and CLANG_FORMAT_PIP is False:
|
||||
print(f"[!] clang-format-{CURRENT_LLVM} is needed. Aborted.")
|
||||
print(f"Run `pip3 install \"clang-format=={CURRENT_LLVM}.*\"` \
|
||||
to install via pip.")
|
||||
exit(1)
|
||||
|
||||
if CLANG_FORMAT_PIP:
|
||||
CLANG_FORMAT_BIN = shutil.which("clang-format")
|
||||
|
||||
COLUMN_LIMIT = 80
|
||||
for line in fmt.split("\n"):
|
||||
line = line.split(":")
|
||||
@ -54,43 +87,43 @@ def custom_format(filename):
|
||||
|
||||
for line in src.split("\n"):
|
||||
if line.lstrip().startswith("#"):
|
||||
if line[line.find("#") + 1 :].lstrip().startswith("define"):
|
||||
if line[line.find("#") + 1:].lstrip().startswith("define"):
|
||||
in_define = True
|
||||
|
||||
if (
|
||||
"/*" in line
|
||||
and not line.strip().startswith("/*")
|
||||
and line.endswith("*/")
|
||||
and len(line) < (COLUMN_LIMIT - 2)
|
||||
"/*" in line
|
||||
and not line.strip().startswith("/*")
|
||||
and line.endswith("*/")
|
||||
and len(line) < (COLUMN_LIMIT - 2)
|
||||
):
|
||||
cmt_start = line.rfind("/*")
|
||||
line = (
|
||||
line[:cmt_start]
|
||||
+ " " * (COLUMN_LIMIT - 2 - len(line))
|
||||
+ line[cmt_start:]
|
||||
line[:cmt_start]
|
||||
+ " " * (COLUMN_LIMIT - 2 - len(line))
|
||||
+ line[cmt_start:]
|
||||
)
|
||||
|
||||
define_padding = 0
|
||||
if last_line is not None and in_define and last_line.endswith("\\"):
|
||||
last_line = last_line[:-1]
|
||||
define_padding = max(0, len(last_line[last_line.rfind("\n") + 1 :]))
|
||||
define_padding = max(0, len(last_line[last_line.rfind("\n") + 1:]))
|
||||
|
||||
if (
|
||||
last_line is not None
|
||||
and last_line.strip().endswith("{")
|
||||
and line.strip() != ""
|
||||
last_line is not None
|
||||
and last_line.strip().endswith("{")
|
||||
and line.strip() != ""
|
||||
):
|
||||
line = (" " * define_padding + "\\" if in_define else "") + "\n" + line
|
||||
elif (
|
||||
last_line is not None
|
||||
and last_line.strip().startswith("}")
|
||||
and line.strip() != ""
|
||||
last_line is not None
|
||||
and last_line.strip().startswith("}")
|
||||
and line.strip() != ""
|
||||
):
|
||||
line = (" " * define_padding + "\\" if in_define else "") + "\n" + line
|
||||
elif (
|
||||
line.strip().startswith("}")
|
||||
and last_line is not None
|
||||
and last_line.strip() != ""
|
||||
line.strip().startswith("}")
|
||||
and last_line is not None
|
||||
and last_line.strip() != ""
|
||||
):
|
||||
line = (" " * define_padding + "\\" if in_define else "") + "\n" + line
|
||||
|
||||
|
8
.github/workflows/ci.yml
vendored
8
.github/workflows/ci.yml
vendored
@ -23,15 +23,17 @@ jobs:
|
||||
- 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
|
||||
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
|
||||
#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
|
||||
- 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
|
||||
run: make distrib ASAN_BUILD=1 NO_NYX=1
|
||||
- name: run tests
|
||||
run: sudo -E ./afl-system-config; make tests
|
||||
macos:
|
||||
|
133
.gitignore
vendored
133
.gitignore
vendored
@ -1,100 +1,107 @@
|
||||
.test
|
||||
.test2
|
||||
.sync_tmp
|
||||
.vscode
|
||||
!coresight_mode
|
||||
!coresight_mode/coresight-trace
|
||||
*.dSYM
|
||||
*.o
|
||||
*.o.tmp
|
||||
*.pyc
|
||||
*.so
|
||||
*.swp
|
||||
*.pyc
|
||||
*.dSYM
|
||||
as
|
||||
a.out
|
||||
ld
|
||||
in
|
||||
out
|
||||
core*
|
||||
compile_commands.json
|
||||
.sync_tmp
|
||||
.test
|
||||
.test2
|
||||
.vscode
|
||||
afl-analyze
|
||||
afl-analyze.8
|
||||
afl-as
|
||||
afl-as.8
|
||||
afl-c++
|
||||
afl-c++.8
|
||||
afl-cc
|
||||
afl-cc.8
|
||||
afl-clang
|
||||
afl-clang++
|
||||
afl-clang-fast
|
||||
afl-clang-fast++
|
||||
afl-clang-lto
|
||||
afl-clang-lto++
|
||||
afl-fuzz
|
||||
afl-g++
|
||||
afl-gcc
|
||||
afl-gcc-fast
|
||||
afl-g++-fast
|
||||
afl-gotcpu
|
||||
afl-ld
|
||||
afl-ld-lto
|
||||
afl-cs-proxy
|
||||
afl-qemu-trace
|
||||
afl-showmap
|
||||
afl-tmin
|
||||
afl-analyze.8
|
||||
afl-as.8
|
||||
afl-clang-fast++.8
|
||||
afl-clang-fast.8
|
||||
afl-clang-lto.8
|
||||
afl-clang-lto
|
||||
afl-clang-lto++
|
||||
afl-clang-lto++.8
|
||||
afl-clang-lto.8
|
||||
afl-cmin.8
|
||||
afl-cmin.bash.8
|
||||
afl-cs-proxy
|
||||
afl-frida-trace.so
|
||||
afl-fuzz
|
||||
afl-fuzz.8
|
||||
afl-c++.8
|
||||
afl-cc.8
|
||||
afl-gcc.8
|
||||
afl-g++
|
||||
afl-g++.8
|
||||
afl-gcc
|
||||
afl-gcc.8
|
||||
afl-gcc-fast
|
||||
afl-gcc-fast.8
|
||||
afl-g++-fast
|
||||
afl-g++-fast.8
|
||||
afl-gotcpu
|
||||
afl-gotcpu.8
|
||||
afl-plot.8
|
||||
afl-showmap.8
|
||||
afl-system-config.8
|
||||
afl-tmin.8
|
||||
afl-whatsup.8
|
||||
afl-persistent-config.8
|
||||
afl-c++
|
||||
afl-cc
|
||||
afl-ld
|
||||
afl-ld-lto
|
||||
afl-lto
|
||||
afl-lto++
|
||||
afl-lto++.8
|
||||
afl-lto.8
|
||||
afl-persistent-config.8
|
||||
afl-plot.8
|
||||
afl-qemu-trace
|
||||
afl-showmap
|
||||
afl-showmap.8
|
||||
afl-system-config.8
|
||||
afl-tmin
|
||||
afl-tmin.8
|
||||
afl-whatsup.8
|
||||
a.out
|
||||
as
|
||||
compile_commands.json
|
||||
core*
|
||||
examples/afl_frida/afl-frida
|
||||
examples/afl_frida/frida-gum-example.c
|
||||
examples/afl_frida/frida-gum.h
|
||||
examples/afl_frida/libtestinstr.so
|
||||
examples/afl_network_proxy/afl-network-client
|
||||
examples/afl_network_proxy/afl-network-server
|
||||
examples/aflpp_driver/libAFLDriver.a
|
||||
examples/aflpp_driver/libAFLQemuDriver.a
|
||||
gmon.out
|
||||
in
|
||||
ld
|
||||
libAFLDriver.a
|
||||
libAFLQemuDriver.a
|
||||
out
|
||||
qemu_mode/libcompcov/compcovtest
|
||||
qemu_mode/qemu-*
|
||||
qemu_mode/qemuafl
|
||||
unicorn_mode/samples/*/\.test-*
|
||||
unicorn_mode/samples/*/output/
|
||||
test/.afl_performance
|
||||
test-instr
|
||||
test/output
|
||||
test/test-c
|
||||
test/test-cmplog
|
||||
test/test-compcov
|
||||
test/test-instr.ts
|
||||
test/test-persistent
|
||||
test/unittests/unit_hash
|
||||
test/unittests/unit_list
|
||||
test/unittests/unit_maybe_alloc
|
||||
test/unittests/unit_preallocable
|
||||
test/unittests/unit_list
|
||||
test/unittests/unit_rand
|
||||
test/unittests/unit_hash
|
||||
examples/afl_network_proxy/afl-network-server
|
||||
examples/afl_network_proxy/afl-network-client
|
||||
examples/afl_frida/afl-frida
|
||||
examples/afl_frida/libtestinstr.so
|
||||
examples/afl_frida/frida-gum-example.c
|
||||
examples/afl_frida/frida-gum.h
|
||||
examples/aflpp_driver/libAFLDriver.a
|
||||
examples/aflpp_driver/libAFLQemuDriver.a
|
||||
libAFLDriver.a
|
||||
libAFLQemuDriver.a
|
||||
test/.afl_performance
|
||||
gmon.out
|
||||
afl-frida-trace.so
|
||||
unicorn_mode/samples/*/output/
|
||||
unicorn_mode/samples/*/\.test-*
|
||||
utils/afl_network_proxy/afl-network-client
|
||||
utils/afl_network_proxy/afl-network-server
|
||||
utils/plot_ui/afl-plot-ui
|
||||
*.o.tmp
|
||||
utils/afl_proxy/afl-proxy
|
||||
utils/optimin/build
|
||||
utils/optimin/optimin
|
||||
utils/persistent_mode/persistent_demo
|
||||
utils/persistent_mode/persistent_demo_new
|
||||
utils/persistent_mode/test-instr
|
||||
!coresight_mode
|
||||
!coresight_mode/coresight-trace
|
||||
vuln_prog
|
||||
utils/plot_ui/afl-plot-ui
|
||||
vuln_prog
|
||||
|
@ -39,7 +39,7 @@ RUN apt-get update && \
|
||||
apt-get -y install --no-install-recommends \
|
||||
make cmake automake meson ninja-build bison flex \
|
||||
git xz-utils bzip2 wget jupp nano bash-completion less vim joe ssh psmisc \
|
||||
python3 python3-dev python3-setuptools python-is-python3 \
|
||||
python3 python3-dev python3-pip python-is-python3 \
|
||||
libtool libtool-bin libglib2.0-dev \
|
||||
apt-transport-https gnupg dialog \
|
||||
gnuplot-nox libpixman-1-dev \
|
||||
@ -47,7 +47,7 @@ RUN apt-get update && \
|
||||
clang-${LLVM_VERSION} clang-tools-${LLVM_VERSION} libc++1-${LLVM_VERSION} \
|
||||
libc++-${LLVM_VERSION}-dev libc++abi1-${LLVM_VERSION} libc++abi-${LLVM_VERSION}-dev \
|
||||
libclang1-${LLVM_VERSION} libclang-${LLVM_VERSION}-dev \
|
||||
libclang-common-${LLVM_VERSION}-dev libclang-cpp${LLVM_VERSION} \
|
||||
libclang-common-${LLVM_VERSION}-dev libclang-rt-${LLVM_VERSION}-dev libclang-cpp${LLVM_VERSION} \
|
||||
libclang-cpp${LLVM_VERSION}-dev liblld-${LLVM_VERSION} \
|
||||
liblld-${LLVM_VERSION}-dev liblldb-${LLVM_VERSION} liblldb-${LLVM_VERSION}-dev \
|
||||
libllvm${LLVM_VERSION} libomp-${LLVM_VERSION}-dev libomp5-${LLVM_VERSION} \
|
||||
@ -67,6 +67,8 @@ RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${GCC_VERSION} 0
|
||||
RUN wget -qO- https://sh.rustup.rs | CARGO_HOME=/etc/cargo sh -s -- -y -q --no-modify-path
|
||||
ENV PATH=$PATH:/etc/cargo/bin
|
||||
|
||||
RUN apt clean -y
|
||||
|
||||
ENV LLVM_CONFIG=llvm-config-${LLVM_VERSION}
|
||||
ENV AFL_SKIP_CPUFREQ=1
|
||||
ENV AFL_TRY_AFFINITY=1
|
||||
@ -92,4 +94,4 @@ RUN sed -i.bak 's/^ -/ /g' GNUmakefile && \
|
||||
RUN echo "set encoding=utf-8" > /root/.vimrc && \
|
||||
echo ". /etc/bash_completion" >> ~/.bashrc && \
|
||||
echo 'alias joe="joe --wordwrap --joe_state -nobackup"' >> ~/.bashrc && \
|
||||
echo "export PS1='"'[afl++ \h] \w$(__git_ps1) \$ '"'" >> ~/.bashrc
|
||||
echo "export PS1='"'[afl++ \h] \w \$ '"'" >> ~/.bashrc
|
||||
|
39
GNUmakefile
39
GNUmakefile
@ -102,7 +102,7 @@ endif
|
||||
|
||||
ifeq "$(SYS)" "SunOS"
|
||||
CFLAGS_OPT += -Wno-format-truncation
|
||||
LDFLAGS = -lkstat -lrt
|
||||
LDFLAGS = -lkstat -lrt -lsocket -lnsl
|
||||
endif
|
||||
|
||||
ifdef STATIC
|
||||
@ -196,7 +196,7 @@ ifeq "$(PYTHON_INCLUDE)" ""
|
||||
ifneq "$(shell command -v python3-config 2>/dev/null)" ""
|
||||
PYTHON_INCLUDE ?= $(shell python3-config --includes)
|
||||
PYTHON_VERSION ?= $(strip $(shell python3 --version 2>&1))
|
||||
# Starting with python3.8, we need to pass the `embed` flag. Earier versions didn't know this flag.
|
||||
# Starting with python3.8, we need to pass the `embed` flag. Earlier versions didn't know this flag.
|
||||
ifeq "$(shell python3-config --embed --libs 2>/dev/null | grep -q lpython && echo 1 )" "1"
|
||||
PYTHON_LIB ?= $(shell python3-config --libs --embed --ldflags)
|
||||
else
|
||||
@ -312,9 +312,9 @@ all: test_x86 test_shm test_python ready $(PROGS) afl-as llvm gcc_plugin test_bu
|
||||
@echo
|
||||
@echo Build Summary:
|
||||
@test -e afl-fuzz && echo "[+] afl-fuzz and supporting tools successfully built" || echo "[-] afl-fuzz could not be built, please set CC to a working compiler"
|
||||
@test -e afl-llvm-pass.so && echo "[+] LLVM basic mode successfully built" || echo "[-] LLVM mode could not be build, please install at least llvm-11 and clang-11 or newer, see docs/INSTALL.md"
|
||||
@test -e SanitizerCoveragePCGUARD.so && echo "[+] LLVM mode successfully built" || echo "[-] LLVM mode could not be build, please install at least llvm-11 and clang-11 or newer, see docs/INSTALL.md"
|
||||
@test -e SanitizerCoverageLTO.so && echo "[+] LLVM LTO mode successfully built" || echo "[-] LLVM LTO mode could not be build, it is optional, if you want it, please install LLVM 11-14. More information at instrumentation/README.lto.md on how to build it"
|
||||
@test -e afl-llvm-pass.so && echo "[+] LLVM basic mode successfully built" || echo "[-] LLVM mode could not be built, please install at least llvm-11 and clang-11 or newer, see docs/INSTALL.md"
|
||||
@test -e SanitizerCoveragePCGUARD.so && echo "[+] LLVM mode successfully built" || echo "[-] LLVM mode could not be built, please install at least llvm-11 and clang-11 or newer, see docs/INSTALL.md"
|
||||
@test -e SanitizerCoverageLTO.so && echo "[+] LLVM LTO mode successfully built" || echo "[-] LLVM LTO mode could not be built, it is optional, if you want it, please install LLVM 11-14. More information at instrumentation/README.lto.md on how to build it"
|
||||
ifneq "$(SYS)" "Darwin"
|
||||
@test -e afl-gcc-pass.so && echo "[+] gcc_mode successfully built" || echo "[-] gcc_mode could not be built, it is optional, install gcc-VERSION-plugin-dev to enable this"
|
||||
endif
|
||||
@ -388,6 +388,7 @@ help:
|
||||
@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
|
||||
@echo "WAFL_MODE - enable for WASM fuzzing with https://github.com/fgsect/WAFL"
|
||||
@echo AFL_NO_X86 - if compiling on non-intel/amd platforms
|
||||
@echo "LLVM_CONFIG - if your distro doesn't use the standard name for llvm-config (e.g., Debian)"
|
||||
@echo "=========================================="
|
||||
@ -546,8 +547,8 @@ ifndef AFL_NO_X86
|
||||
test_build: afl-cc afl-gcc afl-as afl-showmap
|
||||
@echo "[*] Testing the CC wrapper afl-cc and its instrumentation output..."
|
||||
@unset AFL_MAP_SIZE AFL_USE_UBSAN AFL_USE_CFISAN AFL_USE_LSAN AFL_USE_ASAN AFL_USE_MSAN; ASAN_OPTIONS=detect_leaks=0 AFL_INST_RATIO=100 AFL_PATH=. ./afl-cc test-instr.c $(LDFLAGS) -o test-instr 2>&1 || (echo "Oops, afl-cc failed"; exit 1 )
|
||||
ASAN_OPTIONS=detect_leaks=0 ./afl-showmap -m none -q -o .test-instr0 ./test-instr < /dev/null
|
||||
echo 1 | ASAN_OPTIONS=detect_leaks=0 ./afl-showmap -m none -q -o .test-instr1 ./test-instr
|
||||
-ASAN_OPTIONS=detect_leaks=0 ./afl-showmap -q -m none -o .test-instr0 ./test-instr < /dev/null
|
||||
-echo 1 | ASAN_OPTIONS=detect_leaks=0 ./afl-showmap -m none -q -o .test-instr1 ./test-instr
|
||||
@rm -f test-instr
|
||||
@cmp -s .test-instr0 .test-instr1; DR="$$?"; rm -f .test-instr0 .test-instr1; if [ "$$DR" = "0" ]; then echo; echo "Oops, the instrumentation of afl-cc does not seem to be behaving correctly!"; echo; echo "Please post to https://github.com/AFLplusplus/AFLplusplus/issues to troubleshoot the issue."; echo; exit 1; fi
|
||||
@echo
|
||||
@ -628,25 +629,25 @@ distrib: all
|
||||
-$(MAKE) -j$(nproc) -f GNUmakefile.llvm
|
||||
ifneq "$(SYS)" "Darwin"
|
||||
-$(MAKE) -f GNUmakefile.gcc_plugin
|
||||
endif
|
||||
-$(MAKE) -C utils/libdislocator
|
||||
-$(MAKE) -C utils/libtokencap
|
||||
endif
|
||||
-$(MAKE) -C utils/afl_network_proxy
|
||||
-$(MAKE) -C utils/socket_fuzzing
|
||||
-$(MAKE) -C utils/argv_fuzzing
|
||||
# -$(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
|
||||
endif
|
||||
ifeq "$(SYS)" "Linux"
|
||||
ifndef NO_NYX
|
||||
ifeq "$(SYS)" "Linux"
|
||||
ifndef NO_NYX
|
||||
-cd nyx_mode && ./build_nyx_support.sh
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
-cd qemu_mode && sh ./build_qemu_support.sh
|
||||
ifeq "$(ARCH)" "aarch64"
|
||||
ifndef NO_UNICORN_ARM64
|
||||
@ -659,8 +660,10 @@ endif
|
||||
|
||||
.PHONY: binary-only
|
||||
binary-only: test_shm test_python ready $(PROGS)
|
||||
ifneq "$(SYS)" "Darwin"
|
||||
-$(MAKE) -C utils/libdislocator
|
||||
-$(MAKE) -C utils/libtokencap
|
||||
endif
|
||||
-$(MAKE) -C utils/afl_network_proxy
|
||||
-$(MAKE) -C utils/socket_fuzzing
|
||||
-$(MAKE) -C utils/argv_fuzzing
|
||||
@ -717,9 +720,9 @@ source-only: all
|
||||
-$(MAKE) -j$(nproc) -f GNUmakefile.llvm
|
||||
ifneq "$(SYS)" "Darwin"
|
||||
-$(MAKE) -f GNUmakefile.gcc_plugin
|
||||
endif
|
||||
-$(MAKE) -C utils/libdislocator
|
||||
-$(MAKE) -C utils/libtokencap
|
||||
endif
|
||||
# -$(MAKE) -C utils/plot_ui
|
||||
ifeq "$(SYS)" "Linux"
|
||||
ifndef NO_NYX
|
||||
@ -730,9 +733,9 @@ endif
|
||||
@echo
|
||||
@echo Build Summary:
|
||||
@test -e afl-fuzz && echo "[+] afl-fuzz and supporting tools successfully built" || echo "[-] afl-fuzz could not be built, please set CC to a working compiler"
|
||||
@test -e afl-llvm-pass.so && echo "[+] LLVM basic mode successfully built" || echo "[-] LLVM mode could not be build, please install at least llvm-11 and clang-11 or newer, see docs/INSTALL.md"
|
||||
@test -e SanitizerCoveragePCGUARD.so && echo "[+] LLVM mode successfully built" || echo "[-] LLVM mode could not be build, please install at least llvm-11 and clang-11 or newer, see docs/INSTALL.md"
|
||||
@test -e SanitizerCoverageLTO.so && echo "[+] LLVM LTO mode successfully built" || echo "[-] LLVM LTO mode could not be build, it is optional, if you want it, please install LLVM 11-14. More information at instrumentation/README.lto.md on how to build it"
|
||||
@test -e afl-llvm-pass.so && echo "[+] LLVM basic mode successfully built" || echo "[-] LLVM mode could not be built, please install at least llvm-11 and clang-11 or newer, see docs/INSTALL.md"
|
||||
@test -e SanitizerCoveragePCGUARD.so && echo "[+] LLVM mode successfully built" || echo "[-] LLVM mode could not be built, please install at least llvm-11 and clang-11 or newer, see docs/INSTALL.md"
|
||||
@test -e SanitizerCoverageLTO.so && echo "[+] LLVM LTO mode successfully built" || echo "[-] LLVM LTO mode could not be built, it is optional, if you want it, please install LLVM 11-14. More information at instrumentation/README.lto.md on how to build it"
|
||||
ifneq "$(SYS)" "Darwin"
|
||||
test -e afl-gcc-pass.so && echo "[+] gcc_mode successfully built" || echo "[-] gcc_mode could not be built, it is optional, install gcc-VERSION-plugin-dev to enable this"
|
||||
endif
|
||||
|
@ -11,7 +11,7 @@
|
||||
# from Laszlo Szekeres.
|
||||
#
|
||||
# Copyright 2015 Google Inc. All rights reserved.
|
||||
# Copyright 2019-2022 AFLplusplus Project. All rights reserved.
|
||||
# Copyright 2019-2023 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.
|
||||
|
@ -48,6 +48,7 @@ LLVM_MINOR = $(shell $(LLVM_CONFIG) --version 2>/dev/null | sed 's/.*\.//' | sed
|
||||
LLVM_UNSUPPORTED = $(shell $(LLVM_CONFIG) --version 2>/dev/null | grep -E -q '^[0-2]\.|^3.[0-7]\.' && echo 1 || echo 0 )
|
||||
LLVM_TOO_NEW = $(shell $(LLVM_CONFIG) --version 2>/dev/null | grep -E -q '^1[5-9]' && 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_10_OK = $(shell $(LLVM_CONFIG) --version 2>/dev/null | grep -E -q '^1[1-9]|^10\.[1-9]|^10\.0.[1-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_BINDIR = $(shell $(LLVM_CONFIG) --bindir 2>/dev/null)
|
||||
@ -81,6 +82,11 @@ ifeq "$(LLVM_NEW_API)" "1"
|
||||
LLVM_TOO_OLD=0
|
||||
endif
|
||||
|
||||
ifeq "$(LLVM_NEWER_API)" "1"
|
||||
$(info [+] llvm_mode detected llvm 16+, enabling c++17)
|
||||
LLVM_STDCXX = c++17
|
||||
endif
|
||||
|
||||
ifeq "$(LLVM_TOO_OLD)" "1"
|
||||
$(info [!] llvm_mode detected an old version of llvm, upgrade to at least 9 or preferable 11!)
|
||||
$(shell sleep 1)
|
||||
@ -276,7 +282,7 @@ endif
|
||||
|
||||
CXXFLAGS ?= -O3 -funroll-loops -fPIC -D_FORTIFY_SOURCE=1
|
||||
override CXXFLAGS += -Wall -g -I ./include/ \
|
||||
-DVERSION=\"$(VERSION)\" -Wno-variadic-macros \
|
||||
-DVERSION=\"$(VERSION)\" -Wno-variadic-macros -Wno-deprecated-copy-with-dtor \
|
||||
-DLLVM_MINOR=$(LLVM_MINOR) -DLLVM_MAJOR=$(LLVM_MAJOR)
|
||||
|
||||
ifneq "$(shell $(LLVM_CONFIG) --includedir) 2> /dev/null" ""
|
||||
@ -288,6 +294,11 @@ endif
|
||||
CLANG_CPPFL = `$(LLVM_CONFIG) --cxxflags` -fno-rtti -fPIC $(CXXFLAGS) -Wno-deprecated-declarations
|
||||
CLANG_LFL = `$(LLVM_CONFIG) --ldflags` $(LDFLAGS)
|
||||
|
||||
# wasm fuzzing: disable thread-local storage and unset LLVM debug flag
|
||||
ifdef WAFL_MODE
|
||||
$(info Compiling libraries for use with WAVM)
|
||||
CLANG_CPPFL += -DNDEBUG -DNO_TLS
|
||||
endif
|
||||
|
||||
# User teor2345 reports that this is required to make things work on MacOS X.
|
||||
ifeq "$(SYS)" "Darwin"
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
<img align="right" src="https://raw.githubusercontent.com/AFLplusplus/Website/master/static/aflpp_bg.svg" alt="AFL++ logo" width="250" heigh="250">
|
||||
|
||||
Release version: [4.04c](https://github.com/AFLplusplus/AFLplusplus/releases)
|
||||
Release version: [4.06c](https://github.com/AFLplusplus/AFLplusplus/releases)
|
||||
|
||||
GitHub version: 4.05a
|
||||
GitHub version: 4.07a
|
||||
|
||||
Repository:
|
||||
[https://github.com/AFLplusplus/AFLplusplus](https://github.com/AFLplusplus/AFLplusplus)
|
||||
@ -228,6 +228,7 @@ Thank you! (For people sending pull requests - please add yourself to this list
|
||||
Thomas Rooijakkers David Carlier
|
||||
Ruben ten Hove Joey Jiao
|
||||
fuzzah @intrigus-lgtm
|
||||
Yaakov Saxon
|
||||
```
|
||||
|
||||
</details>
|
||||
|
3
TODO.md
3
TODO.md
@ -2,6 +2,7 @@
|
||||
|
||||
## Should
|
||||
|
||||
- splicing selection weighted?
|
||||
- support afl_custom_{send,post_process}, persistent and deferred fork
|
||||
server in afl-showmap
|
||||
- better autodetection of shifting runtime timeout values
|
||||
@ -9,12 +10,12 @@
|
||||
- afl-plot to support multiple plot_data
|
||||
- parallel builds for source-only targets
|
||||
- get rid of check_binary, replace with more forkserver communication
|
||||
- first fuzzer should be a main automatically? not sure.
|
||||
|
||||
## Maybe
|
||||
|
||||
- forkserver tells afl-fuzz if cmplog is supported and if so enable
|
||||
it by default, with AFL_CMPLOG_NO=1 (?) set to skip?
|
||||
- afl_custom_fuzz_splice_optin()
|
||||
- afl_custom_splice()
|
||||
- cmdline option from-to range for mutations
|
||||
|
||||
|
20
afl-cmin
20
afl-cmin
@ -109,6 +109,7 @@ function usage() {
|
||||
" -O - use binary-only instrumentation (FRIDA mode)\n" \
|
||||
" -Q - use binary-only instrumentation (QEMU mode)\n" \
|
||||
" -U - use unicorn-based instrumentation (unicorn mode)\n" \
|
||||
" -X - use Nyx mode\n" \
|
||||
"\n" \
|
||||
"Minimization settings:\n" \
|
||||
" -A - allow crashes and timeouts (not recommended)\n" \
|
||||
@ -123,9 +124,9 @@ function usage() {
|
||||
"AFL_FORKSRV_INIT_TMOUT: time the fuzzer waits for the forkserver to come up\n" \
|
||||
"AFL_KEEP_TRACES: leave the temporary <out_dir>/.traces directory\n" \
|
||||
"AFL_KILL_SIGNAL: Signal delivered to child processes on timeout (default: SIGKILL)\n" \
|
||||
"AFL_FORK_SERVER_KILL_SIGNAL: Signal delivered to fork server processes on termination\n" \
|
||||
" (default: SIGTERM). If this is not set and AFL_KILL_SIGNAL is set,\n" \
|
||||
" this will be set to the same value as AFL_KILL_SIGNAL.\n" \
|
||||
"AFL_FORK_SERVER_KILL_SIGNAL: Signal delivered to fork server processes on\n" \
|
||||
" termination (default: SIGTERM). If this is not set and AFL_KILL_SIGNAL is\n" \
|
||||
" set, this will be set to the same value as AFL_KILL_SIGNAL.\n" \
|
||||
"AFL_NO_FORKSRV: run target via execve instead of using the forkserver\n" \
|
||||
"AFL_CMIN_ALLOW_ANY: write tuples for crashing inputs also\n" \
|
||||
"AFL_PATH: path for the afl-showmap binary if not found anywhere in PATH\n" \
|
||||
@ -156,7 +157,7 @@ BEGIN {
|
||||
# process options
|
||||
Opterr = 1 # default is to diagnose
|
||||
Optind = 1 # skip ARGV[0]
|
||||
while ((_go_c = getopt(ARGC, ARGV, "hi:o:f:m:t:eACOQU?")) != -1) {
|
||||
while ((_go_c = getopt(ARGC, ARGV, "hi:o:f:m:t:eACOQUXY?")) != -1) {
|
||||
if (_go_c == "i") {
|
||||
if (!Optarg) usage()
|
||||
if (in_dir) { print "Option "_go_c" is only allowed once" > "/dev/stderr"}
|
||||
@ -217,6 +218,12 @@ BEGIN {
|
||||
extra_par = extra_par " -U"
|
||||
unicorn_mode = 1
|
||||
continue
|
||||
} else
|
||||
if (_go_c == "X" || _go_c == "Y") {
|
||||
if (nyx_mode) { print "Option "_go_c" is only allowed once" > "/dev/stderr"}
|
||||
extra_par = extra_par " -X"
|
||||
nyx_mode = 1
|
||||
continue
|
||||
} else
|
||||
if (_go_c == "?") {
|
||||
exit 1
|
||||
@ -291,7 +298,8 @@ BEGIN {
|
||||
exit 1
|
||||
}
|
||||
|
||||
if (target_bin && !exists_and_is_executable(target_bin)) {
|
||||
|
||||
if (!nyx_mode && target_bin && !exists_and_is_executable(target_bin)) {
|
||||
|
||||
"command -v "target_bin" 2>/dev/null" | getline tnew
|
||||
if (!tnew || !exists_and_is_executable(tnew)) {
|
||||
@ -311,7 +319,7 @@ BEGIN {
|
||||
}
|
||||
}
|
||||
|
||||
if (!ENVIRON["AFL_SKIP_BIN_CHECK"] && !qemu_mode && !frida_mode && !unicorn_mode) {
|
||||
if (!ENVIRON["AFL_SKIP_BIN_CHECK"] && !qemu_mode && !frida_mode && !unicorn_mode && !nyx_mode) {
|
||||
if (0 != system( "grep -q __AFL_SHM_ID "target_bin )) {
|
||||
print "[-] Error: binary '"target_bin"' doesn't appear to be instrumented." > "/dev/stderr"
|
||||
exit 1
|
||||
|
@ -53,7 +53,7 @@ unset IN_DIR OUT_DIR STDIN_FILE EXTRA_PAR MEM_LIMIT_GIVEN \
|
||||
|
||||
export AFL_QUIET=1
|
||||
|
||||
while getopts "+i:o:f:m:t:eOQUACh" opt; do
|
||||
while getopts "+i:o:f:m:t:eOQUAChXY" opt; do
|
||||
|
||||
case "$opt" in
|
||||
|
||||
@ -94,6 +94,14 @@ while getopts "+i:o:f:m:t:eOQUACh" opt; do
|
||||
EXTRA_PAR="$EXTRA_PAR -Q"
|
||||
QEMU_MODE=1
|
||||
;;
|
||||
"Y")
|
||||
EXTRA_PAR="$EXTRA_PAR -X"
|
||||
NYX_MODE=1
|
||||
;;
|
||||
"X")
|
||||
EXTRA_PAR="$EXTRA_PAR -X"
|
||||
NYX_MODE=1
|
||||
;;
|
||||
"U")
|
||||
EXTRA_PAR="$EXTRA_PAR -U"
|
||||
UNICORN_MODE=1
|
||||
@ -128,6 +136,7 @@ Execution control settings:
|
||||
-O - use binary-only instrumentation (FRIDA mode)
|
||||
-Q - use binary-only instrumentation (QEMU mode)
|
||||
-U - use unicorn-based instrumentation (Unicorn mode)
|
||||
-X - use Nyx mode
|
||||
|
||||
Minimization settings:
|
||||
|
||||
@ -206,17 +215,20 @@ if [ ! "$TIMEOUT" = "none" ]; then
|
||||
|
||||
fi
|
||||
|
||||
if [ ! -f "$TARGET_BIN" -o ! -x "$TARGET_BIN" ]; then
|
||||
if [ "$NYX_MODE" = "" ]; then
|
||||
if [ ! -f "$TARGET_BIN" -o ! -x "$TARGET_BIN" ]; then
|
||||
|
||||
TNEW="`which "$TARGET_BIN" 2>/dev/null`"
|
||||
TNEW="`which "$TARGET_BIN" 2>/dev/null`"
|
||||
|
||||
if [ ! -f "$TNEW" -o ! -x "$TNEW" ]; then
|
||||
echo "[-] Error: binary '$TARGET_BIN' not found or not executable." 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TARGET_BIN="$TNEW"
|
||||
|
||||
if [ ! -f "$TNEW" -o ! -x "$TNEW" ]; then
|
||||
echo "[-] Error: binary '$TARGET_BIN' not found or not executable." 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TARGET_BIN="$TNEW"
|
||||
|
||||
fi
|
||||
|
||||
grep -aq AFL_DUMP_MAP_SIZE "./$TARGET_BIN" && {
|
||||
@ -228,7 +240,7 @@ grep -aq AFL_DUMP_MAP_SIZE "./$TARGET_BIN" && {
|
||||
}
|
||||
}
|
||||
|
||||
if [ "$AFL_SKIP_BIN_CHECK" = "" -a "$QEMU_MODE" = "" -a "$FRIDA_MODE" = "" -a "$UNICORN_MODE" = "" ]; then
|
||||
if [ "$AFL_SKIP_BIN_CHECK" = "" -a "$QEMU_MODE" = "" -a "$FRIDA_MODE" = "" -a "$UNICORN_MODE" = "" -a "$NYX_MODE" = "" ]; then
|
||||
|
||||
if ! grep -qF "__AFL_SHM_ID" "$TARGET_BIN"; then
|
||||
echo "[-] Error: binary '$TARGET_BIN' doesn't appear to be instrumented." 1>&2
|
||||
|
4
afl-plot
4
afl-plot
@ -287,9 +287,9 @@ $PLOT_EG
|
||||
|
||||
_EOF_
|
||||
|
||||
) | gnuplot
|
||||
) | gnuplot || echo "Note: if you see errors concerning 'unknown or ambiguous terminal type' then you need to use a gnuplot that has png support compiled in."
|
||||
|
||||
echo "[?] You can also use -g flag to view the plots in an GUI window, and interact with the plots (if you have built afl-plot-ui). Run \"afl-plot-h\" to know more."
|
||||
echo "[?] You can also use -g flag to view the plots in an GUI window, and interact with the plots (if you have built afl-plot-ui). Run \"afl-plot -h\" to know more."
|
||||
|
||||
fi
|
||||
|
||||
|
15
afl-whatsup
15
afl-whatsup
@ -6,7 +6,7 @@
|
||||
# Originally written by Michal Zalewski
|
||||
#
|
||||
# Copyright 2015 Google Inc. All rights reserved.
|
||||
# Copyright 2019-2022 AFLplusplus Project. All rights reserved.
|
||||
# Copyright 2019-2023 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.
|
||||
@ -70,10 +70,10 @@ if [ -d queue ]; then
|
||||
|
||||
fi
|
||||
|
||||
RED=`tput setaf 9 1 1`
|
||||
GREEN=`tput setaf 2 1 1`
|
||||
BLUE=`tput setaf 4 1 1`
|
||||
YELLOW=`tput setaf 11 1 1`
|
||||
RED=`tput setaf 9 1 1 2>/dev/null`
|
||||
GREEN=`tput setaf 2 1 1 2>/dev/null`
|
||||
BLUE=`tput setaf 4 1 1 2>/dev/null`
|
||||
YELLOW=`tput setaf 11 1 1 2>/dev/null`
|
||||
NC=`tput sgr0`
|
||||
RESET="$NC"
|
||||
|
||||
@ -141,7 +141,8 @@ for i in `find . -maxdepth 2 -iname fuzzer_stats | sort`; do
|
||||
|
||||
sed 's/^command_line.*$/_skip:1/;s/[ ]*:[ ]*/="/;s/$/"/' "$i" >"$TMP"
|
||||
. "$TMP"
|
||||
|
||||
DIR=$(dirname "$i")
|
||||
DIR=${DIR##*/}
|
||||
RUN_UNIX=$run_time
|
||||
RUN_DAYS=$((RUN_UNIX / 60 / 60 / 24))
|
||||
RUN_HRS=$(((RUN_UNIX / 60 / 60) % 24))
|
||||
@ -154,7 +155,7 @@ for i in `find . -maxdepth 2 -iname fuzzer_stats | sort`; do
|
||||
|
||||
if [ "$SUMMARY_ONLY" = "" ]; then
|
||||
|
||||
echo ">>> $afl_banner ($RUN_DAYS days, $RUN_HRS hrs) fuzzer PID: $fuzzer_pid <<<"
|
||||
echo ">>> $afl_banner instance: $DIR ($RUN_DAYS days, $RUN_HRS hrs) fuzzer PID: $fuzzer_pid <<<"
|
||||
echo
|
||||
|
||||
fi
|
||||
|
@ -11,6 +11,16 @@ The `./examples` folder contains examples for custom mutators in python and C.
|
||||
|
||||
In `./rust`, you will find rust bindings, including a simple example in `./rust/example` and an example for structured fuzzing, based on lain, in`./rust/example_lain`.
|
||||
|
||||
## The AFL++ grammar agnostic grammar mutator
|
||||
|
||||
In `./autotokens` you find a token-level fuzzer that does not need to know
|
||||
anything about the grammar of an input as long as it is in ascii and allows
|
||||
whitespace.
|
||||
It is very fast and effective.
|
||||
|
||||
If you are looking for an example of how to effectively create a custom
|
||||
mutator take a look at this one.
|
||||
|
||||
## The AFL++ Grammar Mutator
|
||||
|
||||
If you use git to clone AFL++, then the following will incorporate our
|
||||
|
26
custom_mutators/autotokens/Makefile
Normal file
26
custom_mutators/autotokens/Makefile
Normal file
@ -0,0 +1,26 @@
|
||||
ifdef debug
|
||||
CPPLAGS += -fsanitize=address
|
||||
CXXFLAGS += -Wall
|
||||
CC := clang
|
||||
CXX := clang++
|
||||
endif
|
||||
ifdef DEBUG
|
||||
CPPFLAGS += -fsanitize=address
|
||||
CXXFLAGS += -Wall
|
||||
CC := clang
|
||||
CXX := clang++
|
||||
endif
|
||||
|
||||
all: autotokens.so
|
||||
|
||||
afl-fuzz-queue.o: ../../src/afl-fuzz-queue.c
|
||||
$(CC) -D_STANDALONE_MODULE=1 -I../../include -g -O3 $(CPPFLAGS) -fPIC -c -o ./afl-fuzz-queue.o ../../src/afl-fuzz-queue.c
|
||||
|
||||
afl-common.o: ../../src/afl-common.c
|
||||
$(CC) -I../../include -g -O3 $(CPPFLAGS) -DBIN_PATH=\"dummy\" -Wno-pointer-sign -fPIC -c -o ./afl-common.o ../../src/afl-common.c
|
||||
|
||||
autotokens.so: afl-fuzz-queue.o afl-common.o autotokens.cpp
|
||||
$(CXX) -Wno-deprecated -g -O3 $(CXXFLAGS) $(CPPFLAGS) -shared -fPIC -o autotokens.so -I../../include autotokens.cpp ./afl-fuzz-queue.o ../../src/afl-performance.o ./afl-common.o
|
||||
|
||||
clean:
|
||||
rm -f autotokens.so *.o *~ core
|
34
custom_mutators/autotokens/README
Normal file
34
custom_mutators/autotokens/README
Normal file
@ -0,0 +1,34 @@
|
||||
# Autotokens
|
||||
|
||||
This implements an improved autotoken grammar fuzzing idea presented in
|
||||
[Token-Level Fuzzing][https://www.usenix.org/system/files/sec21-salls.pdf].
|
||||
It is a grammar fuzzer without actually knowing the grammar, but only works
|
||||
with text based inputs.
|
||||
|
||||
It is recommended to run with together in an instance with `CMPLOG`.
|
||||
|
||||
If you have a dictionary (`-x`) this improves this custom grammar mutator.
|
||||
|
||||
If **not** running with `CMPLOG`, it is possible to set
|
||||
`AFL_CUSTOM_MUTATOR_ONLY` to concentrate on grammar bug classes.
|
||||
|
||||
Do **not** set `AFL_DISABLE_TRIM` with this custom mutator!
|
||||
|
||||
## Configuration via environment variables
|
||||
|
||||
`AUTOTOKENS_ONLY_FAV` - only use this mutator on favorite queue items
|
||||
`AUTOTOKENS_COMMENT` - what character or string starts a comment which will be
|
||||
removed. Default: `/* ... */`
|
||||
`AUTOTOKENS_FUZZ_COUNT_SHIFT` - reduce the number of fuzzing performed, shifting
|
||||
the value by this number, e.g. 1.
|
||||
`AUTOTOKENS_AUTO_DISABLE` - disable this module if the seeds are not ascii
|
||||
(or no input and no (ascii) dictionary)
|
||||
`AUTOTOKENS_LEARN_DICT` - learn from dictionaries?
|
||||
0 = none
|
||||
1 = only -x or autodict
|
||||
2 = -x, autodict and `CMPLOG`
|
||||
`AUTOTOKENS_CHANGE_MIN` - minimum number of mutations (1-256, default 8)
|
||||
`AUTOTOKENS_CHANGE_MAX` - maximum number of mutations (1-4096, default 64)
|
||||
`AUTOTOKENS_CREATE_FROM_THIN_AIR` - if only one small start file is present and
|
||||
a dictionary loaded then create one initial
|
||||
structure based on the dictionary.
|
1101
custom_mutators/autotokens/autotokens.cpp
Normal file
1101
custom_mutators/autotokens/autotokens.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,342 +0,0 @@
|
||||
#ifndef CUSTOM_MUTATOR_HELPERS
|
||||
#define CUSTOM_MUTATOR_HELPERS
|
||||
|
||||
#include "config.h"
|
||||
#include "types.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
#define INITIAL_GROWTH_SIZE (64)
|
||||
|
||||
#define RAND_BELOW(limit) (rand() % (limit))
|
||||
|
||||
/* Use in a struct: creates a name_buf and a name_size variable. */
|
||||
#define BUF_VAR(type, name) \
|
||||
type * name##_buf; \
|
||||
size_t name##_size;
|
||||
/* this fills in `&structptr->something_buf, &structptr->something_size`. */
|
||||
#define BUF_PARAMS(struct, name) \
|
||||
(void **)&struct->name##_buf, &struct->name##_size
|
||||
|
||||
typedef struct {
|
||||
|
||||
} afl_t;
|
||||
|
||||
static void surgical_havoc_mutate(u8 *out_buf, s32 begin, s32 end) {
|
||||
|
||||
static s8 interesting_8[] = {INTERESTING_8};
|
||||
static s16 interesting_16[] = {INTERESTING_8, INTERESTING_16};
|
||||
static s32 interesting_32[] = {INTERESTING_8, INTERESTING_16, INTERESTING_32};
|
||||
|
||||
switch (RAND_BELOW(12)) {
|
||||
|
||||
case 0: {
|
||||
|
||||
/* Flip a single bit somewhere. Spooky! */
|
||||
|
||||
s32 bit_idx = ((RAND_BELOW(end - begin) + begin) << 3) + RAND_BELOW(8);
|
||||
|
||||
out_buf[bit_idx >> 3] ^= 128 >> (bit_idx & 7);
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case 1: {
|
||||
|
||||
/* Set byte to interesting value. */
|
||||
|
||||
u8 val = interesting_8[RAND_BELOW(sizeof(interesting_8))];
|
||||
out_buf[(RAND_BELOW(end - begin) + begin)] = val;
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case 2: {
|
||||
|
||||
/* Set word to interesting value, randomly choosing endian. */
|
||||
|
||||
if (end - begin < 2) break;
|
||||
|
||||
s32 byte_idx = (RAND_BELOW(end - begin) + begin);
|
||||
|
||||
if (byte_idx >= end - 1) break;
|
||||
|
||||
switch (RAND_BELOW(2)) {
|
||||
|
||||
case 0:
|
||||
*(u16 *)(out_buf + byte_idx) =
|
||||
interesting_16[RAND_BELOW(sizeof(interesting_16) >> 1)];
|
||||
break;
|
||||
case 1:
|
||||
*(u16 *)(out_buf + byte_idx) =
|
||||
SWAP16(interesting_16[RAND_BELOW(sizeof(interesting_16) >> 1)]);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case 3: {
|
||||
|
||||
/* Set dword to interesting value, randomly choosing endian. */
|
||||
|
||||
if (end - begin < 4) break;
|
||||
|
||||
s32 byte_idx = (RAND_BELOW(end - begin) + begin);
|
||||
|
||||
if (byte_idx >= end - 3) break;
|
||||
|
||||
switch (RAND_BELOW(2)) {
|
||||
|
||||
case 0:
|
||||
*(u32 *)(out_buf + byte_idx) =
|
||||
interesting_32[RAND_BELOW(sizeof(interesting_32) >> 2)];
|
||||
break;
|
||||
case 1:
|
||||
*(u32 *)(out_buf + byte_idx) =
|
||||
SWAP32(interesting_32[RAND_BELOW(sizeof(interesting_32) >> 2)]);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case 4: {
|
||||
|
||||
/* Set qword to interesting value, randomly choosing endian. */
|
||||
|
||||
if (end - begin < 8) break;
|
||||
|
||||
s32 byte_idx = (RAND_BELOW(end - begin) + begin);
|
||||
|
||||
if (byte_idx >= end - 7) break;
|
||||
|
||||
switch (RAND_BELOW(2)) {
|
||||
|
||||
case 0:
|
||||
*(u64 *)(out_buf + byte_idx) =
|
||||
(s64)interesting_32[RAND_BELOW(sizeof(interesting_32) >> 2)];
|
||||
break;
|
||||
case 1:
|
||||
*(u64 *)(out_buf + byte_idx) = SWAP64(
|
||||
(s64)interesting_32[RAND_BELOW(sizeof(interesting_32) >> 2)]);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case 5: {
|
||||
|
||||
/* Randomly subtract from byte. */
|
||||
|
||||
out_buf[(RAND_BELOW(end - begin) + begin)] -= 1 + RAND_BELOW(ARITH_MAX);
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case 6: {
|
||||
|
||||
/* Randomly add to byte. */
|
||||
|
||||
out_buf[(RAND_BELOW(end - begin) + begin)] += 1 + RAND_BELOW(ARITH_MAX);
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case 7: {
|
||||
|
||||
/* Randomly subtract from word, random endian. */
|
||||
|
||||
if (end - begin < 2) break;
|
||||
|
||||
s32 byte_idx = (RAND_BELOW(end - begin) + begin);
|
||||
|
||||
if (byte_idx >= end - 1) break;
|
||||
|
||||
if (RAND_BELOW(2)) {
|
||||
|
||||
*(u16 *)(out_buf + byte_idx) -= 1 + RAND_BELOW(ARITH_MAX);
|
||||
|
||||
} else {
|
||||
|
||||
u16 num = 1 + RAND_BELOW(ARITH_MAX);
|
||||
|
||||
*(u16 *)(out_buf + byte_idx) =
|
||||
SWAP16(SWAP16(*(u16 *)(out_buf + byte_idx)) - num);
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case 8: {
|
||||
|
||||
/* Randomly add to word, random endian. */
|
||||
|
||||
if (end - begin < 2) break;
|
||||
|
||||
s32 byte_idx = (RAND_BELOW(end - begin) + begin);
|
||||
|
||||
if (byte_idx >= end - 1) break;
|
||||
|
||||
if (RAND_BELOW(2)) {
|
||||
|
||||
*(u16 *)(out_buf + byte_idx) += 1 + RAND_BELOW(ARITH_MAX);
|
||||
|
||||
} else {
|
||||
|
||||
u16 num = 1 + RAND_BELOW(ARITH_MAX);
|
||||
|
||||
*(u16 *)(out_buf + byte_idx) =
|
||||
SWAP16(SWAP16(*(u16 *)(out_buf + byte_idx)) + num);
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case 9: {
|
||||
|
||||
/* Randomly subtract from dword, random endian. */
|
||||
|
||||
if (end - begin < 4) break;
|
||||
|
||||
s32 byte_idx = (RAND_BELOW(end - begin) + begin);
|
||||
|
||||
if (byte_idx >= end - 3) break;
|
||||
|
||||
if (RAND_BELOW(2)) {
|
||||
|
||||
*(u32 *)(out_buf + byte_idx) -= 1 + RAND_BELOW(ARITH_MAX);
|
||||
|
||||
} else {
|
||||
|
||||
u32 num = 1 + RAND_BELOW(ARITH_MAX);
|
||||
|
||||
*(u32 *)(out_buf + byte_idx) =
|
||||
SWAP32(SWAP32(*(u32 *)(out_buf + byte_idx)) - num);
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case 10: {
|
||||
|
||||
/* Randomly add to dword, random endian. */
|
||||
|
||||
if (end - begin < 4) break;
|
||||
|
||||
s32 byte_idx = (RAND_BELOW(end - begin) + begin);
|
||||
|
||||
if (byte_idx >= end - 3) break;
|
||||
|
||||
if (RAND_BELOW(2)) {
|
||||
|
||||
*(u32 *)(out_buf + byte_idx) += 1 + RAND_BELOW(ARITH_MAX);
|
||||
|
||||
} else {
|
||||
|
||||
u32 num = 1 + RAND_BELOW(ARITH_MAX);
|
||||
|
||||
*(u32 *)(out_buf + byte_idx) =
|
||||
SWAP32(SWAP32(*(u32 *)(out_buf + byte_idx)) + num);
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case 11: {
|
||||
|
||||
/* Just set a random byte to a random value. Because,
|
||||
why not. We use XOR with 1-255 to eliminate the
|
||||
possibility of a no-op. */
|
||||
|
||||
out_buf[(RAND_BELOW(end - begin) + begin)] ^= 1 + RAND_BELOW(255);
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* This function calculates the next power of 2 greater or equal its argument.
|
||||
@return The rounded up power of 2 (if no overflow) or 0 on overflow.
|
||||
*/
|
||||
static inline size_t next_pow2(size_t in) {
|
||||
|
||||
if (in == 0 || in > (size_t)-1)
|
||||
return 0; /* avoid undefined behaviour under-/overflow */
|
||||
size_t out = in - 1;
|
||||
out |= out >> 1;
|
||||
out |= out >> 2;
|
||||
out |= out >> 4;
|
||||
out |= out >> 8;
|
||||
out |= out >> 16;
|
||||
return out + 1;
|
||||
|
||||
}
|
||||
|
||||
/* This function makes sure *size is > size_needed after call.
|
||||
It will realloc *buf otherwise.
|
||||
*size will grow exponentially as per:
|
||||
https://blog.mozilla.org/nnethercote/2014/11/04/please-grow-your-buffers-exponentially/
|
||||
Will return NULL and free *buf if size_needed is <1 or realloc failed.
|
||||
@return For convenience, this function returns *buf.
|
||||
*/
|
||||
static inline void *maybe_grow(void **buf, size_t *size, size_t size_needed) {
|
||||
|
||||
/* No need to realloc */
|
||||
if (likely(size_needed && *size >= size_needed)) return *buf;
|
||||
|
||||
/* No initial size was set */
|
||||
if (size_needed < INITIAL_GROWTH_SIZE) size_needed = INITIAL_GROWTH_SIZE;
|
||||
|
||||
/* grow exponentially */
|
||||
size_t next_size = next_pow2(size_needed);
|
||||
|
||||
/* handle overflow */
|
||||
if (!next_size) { next_size = size_needed; }
|
||||
|
||||
/* alloc */
|
||||
*buf = realloc(*buf, next_size);
|
||||
*size = *buf ? next_size : 0;
|
||||
|
||||
return *buf;
|
||||
|
||||
}
|
||||
|
||||
/* Swaps buf1 ptr and buf2 ptr, as well as their sizes */
|
||||
static inline void afl_swap_bufs(void **buf1, size_t *size1, void **buf2,
|
||||
size_t *size2) {
|
||||
|
||||
void * scratch_buf = *buf1;
|
||||
size_t scratch_size = *size1;
|
||||
*buf1 = *buf2;
|
||||
*size1 = *size2;
|
||||
*buf2 = scratch_buf;
|
||||
*size2 = scratch_size;
|
||||
|
||||
}
|
||||
|
||||
#undef INITIAL_GROWTH_SIZE
|
||||
|
||||
#endif
|
||||
|
@ -1,9 +1,14 @@
|
||||
//
|
||||
// This is an example on how to use afl_custom_send
|
||||
// It writes each mutated data set to /tmp/foo
|
||||
// You can modify this to send to IPC, shared memory, etc.
|
||||
//
|
||||
// cc -O3 -fPIC -shared -g -o custom_send.so -I../../include custom_send.c
|
||||
// cd ../..
|
||||
// afl-cc -o test-instr test-instr.c
|
||||
// afl-fuzz -i in -o out -- ./test-instr -f /tmp/foo
|
||||
|
||||
#include "custom_mutator_helpers.h"
|
||||
// AFL_CUSTOM_MUTATOR_LIBRARY=custom_mutators/examples/custom_send.so \
|
||||
// afl-fuzz -i in -o out -- ./test-instr -f /tmp/foo
|
||||
//
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
@ -11,13 +16,15 @@
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "afl-fuzz.h"
|
||||
|
||||
typedef struct my_mutator {
|
||||
|
||||
afl_t *afl;
|
||||
afl_state_t *afl;
|
||||
|
||||
} my_mutator_t;
|
||||
|
||||
my_mutator_t *afl_custom_init(afl_t *afl, unsigned int seed) {
|
||||
my_mutator_t *afl_custom_init(afl_state_t *afl, unsigned int seed) {
|
||||
|
||||
my_mutator_t *data = calloc(1, sizeof(my_mutator_t));
|
||||
if (!data) {
|
||||
|
@ -6,8 +6,8 @@
|
||||
Dominik Maier <mail@dmnk.co>
|
||||
*/
|
||||
|
||||
// You need to use -I /path/to/AFLplusplus/include
|
||||
#include "custom_mutator_helpers.h"
|
||||
// You need to use -I/path/to/AFLplusplus/include -I.
|
||||
#include "afl-fuzz.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
@ -26,19 +26,14 @@ static const char *commands[] = {
|
||||
|
||||
typedef struct my_mutator {
|
||||
|
||||
afl_t *afl;
|
||||
afl_state_t *afl;
|
||||
|
||||
// any additional data here!
|
||||
size_t trim_size_current;
|
||||
int trimmming_steps;
|
||||
int cur_step;
|
||||
|
||||
// Reused buffers:
|
||||
BUF_VAR(u8, fuzz);
|
||||
BUF_VAR(u8, data);
|
||||
BUF_VAR(u8, havoc);
|
||||
BUF_VAR(u8, trim);
|
||||
BUF_VAR(u8, post_process);
|
||||
u8 *mutated_out, *post_process_buf, *trim_buf;
|
||||
|
||||
} my_mutator_t;
|
||||
|
||||
@ -53,7 +48,7 @@ typedef struct my_mutator {
|
||||
* There may be multiple instances of this mutator in one afl-fuzz run!
|
||||
* Return NULL on error.
|
||||
*/
|
||||
my_mutator_t *afl_custom_init(afl_t *afl, unsigned int seed) {
|
||||
my_mutator_t *afl_custom_init(afl_state_t *afl, unsigned int seed) {
|
||||
|
||||
srand(seed); // needed also by surgical_havoc_mutate()
|
||||
|
||||
@ -65,6 +60,27 @@ my_mutator_t *afl_custom_init(afl_t *afl, unsigned int seed) {
|
||||
|
||||
}
|
||||
|
||||
if ((data->mutated_out = (u8 *)malloc(MAX_FILE)) == NULL) {
|
||||
|
||||
perror("afl_custom_init malloc");
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
if ((data->post_process_buf = (u8 *)malloc(MAX_FILE)) == NULL) {
|
||||
|
||||
perror("afl_custom_init malloc");
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
if ((data->trim_buf = (u8 *)malloc(MAX_FILE)) == NULL) {
|
||||
|
||||
perror("afl_custom_init malloc");
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
data->afl = afl;
|
||||
|
||||
return data;
|
||||
@ -96,29 +112,14 @@ size_t afl_custom_fuzz(my_mutator_t *data, uint8_t *buf, size_t buf_size,
|
||||
// the fuzzer
|
||||
size_t mutated_size = DATA_SIZE <= max_size ? DATA_SIZE : max_size;
|
||||
|
||||
// maybe_grow is optimized to be quick for reused buffers.
|
||||
u8 *mutated_out = maybe_grow(BUF_PARAMS(data, fuzz), mutated_size);
|
||||
if (!mutated_out) {
|
||||
|
||||
*out_buf = NULL;
|
||||
perror("custom mutator allocation (maybe_grow)");
|
||||
return 0; /* afl-fuzz will very likely error out after this. */
|
||||
|
||||
}
|
||||
memcpy(data->mutated_out, buf, buf_size);
|
||||
|
||||
// Randomly select a command string to add as a header to the packet
|
||||
memcpy(mutated_out, commands[rand() % 3], 3);
|
||||
memcpy(data->mutated_out, commands[rand() % 3], 3);
|
||||
|
||||
// Mutate the payload of the packet
|
||||
int i;
|
||||
for (i = 0; i < 8; ++i) {
|
||||
if (mutated_size > max_size) { mutated_size = max_size; }
|
||||
|
||||
// Randomly perform one of the (no len modification) havoc mutations
|
||||
surgical_havoc_mutate(mutated_out, 3, mutated_size);
|
||||
|
||||
}
|
||||
|
||||
*out_buf = mutated_out;
|
||||
*out_buf = data->mutated_out;
|
||||
return mutated_size;
|
||||
|
||||
}
|
||||
@ -142,24 +143,16 @@ size_t afl_custom_fuzz(my_mutator_t *data, uint8_t *buf, size_t buf_size,
|
||||
size_t afl_custom_post_process(my_mutator_t *data, uint8_t *buf,
|
||||
size_t buf_size, uint8_t **out_buf) {
|
||||
|
||||
uint8_t *post_process_buf =
|
||||
maybe_grow(BUF_PARAMS(data, post_process), buf_size + 5);
|
||||
if (!post_process_buf) {
|
||||
if (buf_size + 5 > MAX_FILE) { buf_size = MAX_FILE - 5; }
|
||||
|
||||
perror("custom mutator realloc failed.");
|
||||
*out_buf = NULL;
|
||||
return 0;
|
||||
memcpy(data->post_process_buf + 5, buf, buf_size);
|
||||
data->post_process_buf[0] = 'A';
|
||||
data->post_process_buf[1] = 'F';
|
||||
data->post_process_buf[2] = 'L';
|
||||
data->post_process_buf[3] = '+';
|
||||
data->post_process_buf[4] = '+';
|
||||
|
||||
}
|
||||
|
||||
memcpy(post_process_buf + 5, buf, buf_size);
|
||||
post_process_buf[0] = 'A';
|
||||
post_process_buf[1] = 'F';
|
||||
post_process_buf[2] = 'L';
|
||||
post_process_buf[3] = '+';
|
||||
post_process_buf[4] = '+';
|
||||
|
||||
*out_buf = post_process_buf;
|
||||
*out_buf = data->post_process_buf;
|
||||
|
||||
return buf_size + 5;
|
||||
|
||||
@ -195,13 +188,6 @@ int32_t afl_custom_init_trim(my_mutator_t *data, uint8_t *buf,
|
||||
|
||||
data->cur_step = 0;
|
||||
|
||||
if (!maybe_grow(BUF_PARAMS(data, trim), buf_size)) {
|
||||
|
||||
perror("init_trim grow");
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
memcpy(data->trim_buf, buf, buf_size);
|
||||
|
||||
data->trim_size_current = buf_size;
|
||||
@ -282,27 +268,11 @@ int32_t afl_custom_post_trim(my_mutator_t *data, int success) {
|
||||
size_t afl_custom_havoc_mutation(my_mutator_t *data, u8 *buf, size_t buf_size,
|
||||
u8 **out_buf, size_t max_size) {
|
||||
|
||||
if (buf_size == 0) {
|
||||
*out_buf = buf; // in-place mutation
|
||||
|
||||
*out_buf = maybe_grow(BUF_PARAMS(data, havoc), 1);
|
||||
if (!*out_buf) {
|
||||
if (buf_size <= sizeof(size_t)) { return buf_size; }
|
||||
|
||||
perror("custom havoc: maybe_grow");
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
**out_buf = rand() % 256;
|
||||
buf_size = 1;
|
||||
|
||||
} else {
|
||||
|
||||
// We reuse buf here. It's legal and faster.
|
||||
*out_buf = buf;
|
||||
|
||||
}
|
||||
|
||||
size_t victim = rand() % buf_size;
|
||||
size_t victim = rand() % (buf_size - sizeof(size_t));
|
||||
(*out_buf)[victim] += rand() % 10;
|
||||
|
||||
return buf_size;
|
||||
@ -369,9 +339,7 @@ uint8_t afl_custom_queue_new_entry(my_mutator_t *data,
|
||||
void afl_custom_deinit(my_mutator_t *data) {
|
||||
|
||||
free(data->post_process_buf);
|
||||
free(data->havoc_buf);
|
||||
free(data->data_buf);
|
||||
free(data->fuzz_buf);
|
||||
free(data->mutated_out);
|
||||
free(data->trim_buf);
|
||||
free(data);
|
||||
|
||||
|
@ -45,9 +45,8 @@
|
||||
1) If you don't want to modify the test case, simply set `*out_buf = in_buf`
|
||||
and return the original `len`.
|
||||
|
||||
NOTE: the following is currently NOT true, we abort in this case!
|
||||
2) If you want to skip this test case altogether and have AFL generate a
|
||||
new one, return 0 or set `*out_buf = NULL`.
|
||||
new one, return 0.
|
||||
Use this sparingly - it's faster than running the target program
|
||||
with patently useless inputs, but still wastes CPU time.
|
||||
|
||||
@ -59,8 +58,6 @@
|
||||
Note that the buffer will *not* be freed for you. To avoid memory leaks,
|
||||
you need to free it or reuse it on subsequent calls (as shown below).
|
||||
|
||||
*** Feel free to reuse the original 'in_buf' BUFFER and return it. ***
|
||||
|
||||
Alright. The example below shows a simple postprocessor that tries to make
|
||||
sure that all input files start with "GIF89a".
|
||||
|
||||
@ -72,7 +69,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "alloc-inl.h"
|
||||
#include "afl-fuzz.h"
|
||||
|
||||
/* Header that must be present at the beginning of every test case: */
|
||||
|
||||
@ -80,8 +77,7 @@
|
||||
|
||||
typedef struct post_state {
|
||||
|
||||
unsigned char *buf;
|
||||
size_t size;
|
||||
size_t size;
|
||||
|
||||
} post_state_t;
|
||||
|
||||
@ -95,15 +91,6 @@ void *afl_custom_init(void *afl) {
|
||||
|
||||
}
|
||||
|
||||
state->buf = calloc(sizeof(unsigned char), 4096);
|
||||
if (!state->buf) {
|
||||
|
||||
free(state);
|
||||
perror("calloc");
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
return state;
|
||||
|
||||
}
|
||||
@ -113,6 +100,10 @@ void *afl_custom_init(void *afl) {
|
||||
size_t afl_custom_post_process(post_state_t *data, unsigned char *in_buf,
|
||||
unsigned int len, unsigned char **out_buf) {
|
||||
|
||||
/* we do in-place modification as we do not increase the size */
|
||||
|
||||
*out_buf = in_buf;
|
||||
|
||||
/* Skip execution altogether for buffers shorter than 6 bytes (just to
|
||||
show how it's done). We can trust len to be sane. */
|
||||
|
||||
@ -120,34 +111,7 @@ size_t afl_custom_post_process(post_state_t *data, unsigned char *in_buf,
|
||||
|
||||
/* Do nothing for buffers that already start with the expected header. */
|
||||
|
||||
if (!memcmp(in_buf, HEADER, strlen(HEADER))) {
|
||||
|
||||
*out_buf = in_buf;
|
||||
return len;
|
||||
|
||||
}
|
||||
|
||||
/* Allocate memory for new buffer, reusing previous allocation if
|
||||
possible. Note we have to use afl-fuzz's own realloc!
|
||||
Note that you should only do this if you need to grow the buffer,
|
||||
otherwise work with in_buf, and assign it to *out_buf instead. */
|
||||
|
||||
*out_buf = afl_realloc(out_buf, len);
|
||||
|
||||
/* If we're out of memory, the most graceful thing to do is to return the
|
||||
original buffer and give up on modifying it. Let AFL handle OOM on its
|
||||
own later on. */
|
||||
|
||||
if (!*out_buf) {
|
||||
|
||||
*out_buf = in_buf;
|
||||
return len;
|
||||
|
||||
}
|
||||
|
||||
if (len > strlen(HEADER))
|
||||
memcpy(*out_buf + strlen(HEADER), in_buf + strlen(HEADER),
|
||||
len - strlen(HEADER));
|
||||
if (!memcmp(in_buf, HEADER, strlen(HEADER))) { return len; }
|
||||
|
||||
/* Insert the new header. */
|
||||
|
||||
@ -162,7 +126,6 @@ size_t afl_custom_post_process(post_state_t *data, unsigned char *in_buf,
|
||||
/* Gets called afterwards */
|
||||
void afl_custom_deinit(post_state_t *data) {
|
||||
|
||||
free(data->buf);
|
||||
free(data);
|
||||
|
||||
}
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include <string.h>
|
||||
#include <zlib.h>
|
||||
#include <arpa/inet.h>
|
||||
#include "alloc-inl.h"
|
||||
#include "afl-fuzz.h"
|
||||
|
||||
/* A macro to round an integer up to 4 kB. */
|
||||
|
||||
@ -53,7 +53,7 @@ void *afl_custom_init(void *afl) {
|
||||
|
||||
}
|
||||
|
||||
state->buf = calloc(sizeof(unsigned char), 4096);
|
||||
state->buf = calloc(sizeof(unsigned char), MAX_FILE);
|
||||
if (!state->buf) {
|
||||
|
||||
free(state);
|
||||
@ -80,21 +80,7 @@ size_t afl_custom_post_process(post_state_t *data, const unsigned char *in_buf,
|
||||
|
||||
}
|
||||
|
||||
/* This is not a good way to do it, if you do not need to grow the buffer
|
||||
then just work with in_buf instead for speed reasons.
|
||||
But we want to show how to grow a buffer, so this is how it's done: */
|
||||
|
||||
unsigned int pos = 8;
|
||||
unsigned char *new_buf = afl_realloc(out_buf, UP4K(len));
|
||||
|
||||
if (!new_buf) {
|
||||
|
||||
*out_buf = in_buf;
|
||||
return len;
|
||||
|
||||
}
|
||||
|
||||
memcpy(new_buf, in_buf, len);
|
||||
unsigned int pos = 8;
|
||||
|
||||
/* Minimum size of a zero-length PNG chunk is 12 bytes; if we
|
||||
don't have that, we can bail out. */
|
||||
@ -124,7 +110,7 @@ size_t afl_custom_post_process(post_state_t *data, const unsigned char *in_buf,
|
||||
|
||||
if (real_cksum != file_cksum) {
|
||||
|
||||
*(uint32_t *)(new_buf + pos + 8 + chunk_len) = real_cksum;
|
||||
*(uint32_t *)(data->buf + pos + 8 + chunk_len) = real_cksum;
|
||||
|
||||
}
|
||||
|
||||
@ -134,7 +120,7 @@ size_t afl_custom_post_process(post_state_t *data, const unsigned char *in_buf,
|
||||
|
||||
}
|
||||
|
||||
*out_buf = new_buf;
|
||||
*out_buf = data->buf;
|
||||
return len;
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
// This simple example just creates random buffer <= 100 filled with 'A'
|
||||
// needs -I /path/to/AFLplusplus/include
|
||||
#include "custom_mutator_helpers.h"
|
||||
#include "afl-fuzz.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
@ -13,14 +13,14 @@
|
||||
|
||||
typedef struct my_mutator {
|
||||
|
||||
afl_t *afl;
|
||||
afl_state_t *afl;
|
||||
|
||||
// Reused buffers:
|
||||
BUF_VAR(u8, fuzz);
|
||||
u8 *fuzz_buf;
|
||||
|
||||
} my_mutator_t;
|
||||
|
||||
my_mutator_t *afl_custom_init(afl_t *afl, unsigned int seed) {
|
||||
my_mutator_t *afl_custom_init(afl_state_t *afl, unsigned int seed) {
|
||||
|
||||
srand(seed);
|
||||
my_mutator_t *data = calloc(1, sizeof(my_mutator_t));
|
||||
@ -31,6 +31,14 @@ my_mutator_t *afl_custom_init(afl_t *afl, unsigned int seed) {
|
||||
|
||||
}
|
||||
|
||||
data->fuzz_buf = (u8 *)malloc(MAX_FILE);
|
||||
if (!data->fuzz_buf) {
|
||||
|
||||
perror("afl_custom_init malloc");
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
data->afl = afl;
|
||||
|
||||
return data;
|
||||
@ -44,18 +52,10 @@ size_t afl_custom_fuzz(my_mutator_t *data, uint8_t *buf, size_t buf_size,
|
||||
|
||||
int size = (rand() % 100) + 1;
|
||||
if (size > max_size) size = max_size;
|
||||
u8 *mutated_out = maybe_grow(BUF_PARAMS(data, fuzz), size);
|
||||
if (!mutated_out) {
|
||||
|
||||
*out_buf = NULL;
|
||||
perror("custom mutator allocation (maybe_grow)");
|
||||
return 0; /* afl-fuzz will very likely error out after this. */
|
||||
memset(data->fuzz_buf, _FIXED_CHAR, size);
|
||||
|
||||
}
|
||||
|
||||
memset(mutated_out, _FIXED_CHAR, size);
|
||||
|
||||
*out_buf = mutated_out;
|
||||
*out_buf = data->fuzz_buf;
|
||||
return size;
|
||||
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
# Adapted for AFLplusplus by Dominik Maier <mail@dmnk.co>
|
||||
#
|
||||
# Copyright 2017 Battelle Memorial Institute. All rights reserved.
|
||||
# Copyright 2019-2022 AFLplusplus Project. All rights reserved.
|
||||
# Copyright 2019-2023 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.
|
||||
|
@ -14,7 +14,7 @@
|
||||
# <andreafioraldi@gmail.com>
|
||||
#
|
||||
# Copyright 2017 Battelle Memorial Institute. All rights reserved.
|
||||
# Copyright 2019-2022 AFLplusplus Project. All rights reserved.
|
||||
# Copyright 2019-2023 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.
|
||||
|
@ -6,7 +6,7 @@ edition = "2021"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
libafl = { git = "https://github.com/AFLplusplus/LibAFL.git", rev = "62614ce1016c86e3f00f35b56399292ceabd486b" }
|
||||
libafl = { git = "https://github.com/AFLplusplus/LibAFL.git", rev = "266677bb88abe75165430f34e7de897c35560504" }
|
||||
custom_mutator = { path = "../rust/custom_mutator", features = ["afl_internals"] }
|
||||
serde = { version = "1.0", default-features = false, features = ["alloc"] } # serialization lib
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
#![cfg(unix)]
|
||||
#![allow(unused_variables)]
|
||||
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
use std::{
|
||||
@ -18,10 +17,12 @@ use libafl::{
|
||||
scheduled::{havoc_mutations, tokens_mutations, StdScheduledMutator, Tokens},
|
||||
Mutator,
|
||||
},
|
||||
state::{HasCorpus, HasMaxSize, HasMetadata, HasRand, State},
|
||||
prelude::UsesInput,
|
||||
state::{HasCorpus, HasMaxSize, HasMetadata, HasRand, State, UsesState},
|
||||
Error,
|
||||
};
|
||||
|
||||
#[allow(clippy::identity_op)]
|
||||
const MAX_FILE: usize = 1 * 1024 * 1024;
|
||||
|
||||
static mut AFL: Option<&'static afl_state> = None;
|
||||
@ -64,24 +65,32 @@ impl<'de> Deserialize<'de> for AFLCorpus {
|
||||
}
|
||||
}
|
||||
|
||||
impl Corpus<BytesInput> for AFLCorpus {
|
||||
impl UsesState for AFLCorpus {
|
||||
type State = AFLState;
|
||||
}
|
||||
|
||||
impl Corpus for AFLCorpus {
|
||||
#[inline]
|
||||
fn count(&self) -> usize {
|
||||
afl().queued_items as usize
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn add(&mut self, testcase: Testcase<BytesInput>) -> Result<usize, Error> {
|
||||
fn add(&mut self, _testcase: Testcase<BytesInput>) -> Result<usize, Error> {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn replace(&mut self, idx: usize, testcase: Testcase<BytesInput>) -> Result<(), Error> {
|
||||
fn replace(
|
||||
&mut self,
|
||||
_idx: usize,
|
||||
_testcase: Testcase<BytesInput>,
|
||||
) -> Result<Testcase<Self::Input>, Error> {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn remove(&mut self, idx: usize) -> Result<Option<Testcase<BytesInput>>, Error> {
|
||||
fn remove(&mut self, _idx: usize) -> Result<Option<Testcase<BytesInput>>, Error> {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
@ -92,7 +101,7 @@ impl Corpus<BytesInput> for AFLCorpus {
|
||||
entries.entry(idx).or_insert_with(|| {
|
||||
let queue_buf = std::slice::from_raw_parts_mut(afl().queue_buf, self.count());
|
||||
let entry = queue_buf[idx].as_mut().unwrap();
|
||||
let fname = CStr::from_ptr((entry.fname as *mut i8).as_ref().unwrap())
|
||||
let fname = CStr::from_ptr((entry.fname.cast::<i8>()).as_ref().unwrap())
|
||||
.to_str()
|
||||
.unwrap()
|
||||
.to_owned();
|
||||
@ -127,9 +136,10 @@ pub struct AFLState {
|
||||
}
|
||||
|
||||
impl AFLState {
|
||||
#[must_use]
|
||||
pub fn new(seed: u32) -> Self {
|
||||
Self {
|
||||
rand: StdRand::with_seed(seed as u64),
|
||||
rand: StdRand::with_seed(u64::from(seed)),
|
||||
corpus: AFLCorpus::default(),
|
||||
metadata: SerdeAnyMap::new(),
|
||||
max_size: MAX_FILE,
|
||||
@ -153,7 +163,11 @@ impl HasRand for AFLState {
|
||||
}
|
||||
}
|
||||
|
||||
impl HasCorpus<BytesInput> for AFLState {
|
||||
impl UsesInput for AFLState {
|
||||
type Input = BytesInput;
|
||||
}
|
||||
|
||||
impl HasCorpus for AFLState {
|
||||
type Corpus = AFLCorpus;
|
||||
|
||||
#[inline]
|
||||
@ -208,7 +222,7 @@ impl CustomMutator for LibAFLBaseCustomMutator {
|
||||
tokens.push(data.to_vec());
|
||||
}
|
||||
if !tokens.is_empty() {
|
||||
state.add_metadata(Tokens::new(tokens));
|
||||
state.add_metadata(Tokens::from(tokens));
|
||||
}
|
||||
Ok(Self {
|
||||
state,
|
||||
@ -220,7 +234,7 @@ impl CustomMutator for LibAFLBaseCustomMutator {
|
||||
fn fuzz<'b, 's: 'b>(
|
||||
&'s mut self,
|
||||
buffer: &'b mut [u8],
|
||||
add_buff: Option<&[u8]>,
|
||||
_add_buff: Option<&[u8]>,
|
||||
max_size: usize,
|
||||
) -> Result<Option<&'b [u8]>, Self::Error> {
|
||||
self.state.set_max_size(max_size);
|
||||
|
@ -1,12 +1,12 @@
|
||||
[package]
|
||||
name = "custom_mutator-sys"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
authors = ["Julius Hohnerlein <julihoh@users.noreply.github.com>"]
|
||||
edition = "2018"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
|
||||
[build-dependencies]
|
||||
bindgen = "0.56"
|
||||
bindgen = "0.63"
|
||||
|
@ -15,8 +15,8 @@ fn main() {
|
||||
// The input header we would like to generate
|
||||
// bindings for.
|
||||
.header("wrapper.h")
|
||||
.whitelist_type("afl_state_t")
|
||||
.blacklist_type(r"u\d+")
|
||||
.allowlist_type("afl_state_t")
|
||||
.blocklist_type(r"u\d+")
|
||||
.opaque_type(r"_.*")
|
||||
.opaque_type("FILE")
|
||||
.opaque_type("in_addr(_t)?")
|
||||
|
@ -1,5 +1,7 @@
|
||||
#![allow(non_upper_case_globals)]
|
||||
#![allow(non_camel_case_types)]
|
||||
#![allow(non_snake_case)]
|
||||
#![allow(clippy::too_many_lines)]
|
||||
#![allow(clippy::used_underscore_binding)]
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
|
||||
|
@ -2,7 +2,7 @@
|
||||
name = "custom_mutator"
|
||||
version = "0.1.0"
|
||||
authors = ["Julius Hohnerlein <julihoh@users.noreply.github.com>"]
|
||||
edition = "2018"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
//! This binding is panic-safe in that it will prevent panics from unwinding into AFL++. Any panic will `abort` at the boundary between the custom mutator and AFL++.
|
||||
//!
|
||||
//! # Access to AFL++ internals
|
||||
//! This crate has an optional feature "afl_internals", which gives access to AFL++'s internal state.
|
||||
//! This crate has an optional feature "`afl_internals`", which gives access to AFL++'s internal state.
|
||||
//! The state is passed to [`CustomMutator::init`], when the feature is activated.
|
||||
//!
|
||||
//! _This is completely unsafe and uses automatically generated types extracted from the AFL++ source._
|
||||
@ -115,7 +115,7 @@ pub mod wrappers {
|
||||
impl<M: RawCustomMutator> FFIContext<M> {
|
||||
fn from(ptr: *mut c_void) -> ManuallyDrop<Box<Self>> {
|
||||
assert!(!ptr.is_null());
|
||||
ManuallyDrop::new(unsafe { Box::from_raw(ptr as *mut Self) })
|
||||
ManuallyDrop::new(unsafe { Box::from_raw(ptr.cast::<Self>()) })
|
||||
}
|
||||
|
||||
fn into_ptr(self: Box<Self>) -> *const c_void {
|
||||
@ -141,27 +141,28 @@ pub mod wrappers {
|
||||
}
|
||||
|
||||
/// panic handler called for every panic
|
||||
fn panic_handler(method: &str, panic_info: Box<dyn Any + Send + 'static>) -> ! {
|
||||
fn panic_handler(method: &str, panic_info: &Box<dyn Any + Send + 'static>) -> ! {
|
||||
use std::ops::Deref;
|
||||
let cause = panic_info
|
||||
.downcast_ref::<String>()
|
||||
.map(String::deref)
|
||||
.unwrap_or_else(|| {
|
||||
let cause = panic_info.downcast_ref::<String>().map_or_else(
|
||||
|| {
|
||||
panic_info
|
||||
.downcast_ref::<&str>()
|
||||
.copied()
|
||||
.unwrap_or("<cause unknown>")
|
||||
});
|
||||
eprintln!("A panic occurred at {}: {}", method, cause);
|
||||
},
|
||||
String::deref,
|
||||
);
|
||||
eprintln!("A panic occurred at {method}: {cause}");
|
||||
abort()
|
||||
}
|
||||
|
||||
/// Internal function used in the macro
|
||||
#[cfg(not(feature = "afl_internals"))]
|
||||
#[must_use]
|
||||
pub fn afl_custom_init_<M: RawCustomMutator>(seed: u32) -> *const c_void {
|
||||
match catch_unwind(|| FFIContext::<M>::new(seed).into_ptr()) {
|
||||
Ok(ret) => ret,
|
||||
Err(err) => panic_handler("afl_custom_init", err),
|
||||
Err(err) => panic_handler("afl_custom_init", &err),
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,7 +177,7 @@ pub mod wrappers {
|
||||
FFIContext::<M>::new(afl, seed).into_ptr()
|
||||
}) {
|
||||
Ok(ret) => ret,
|
||||
Err(err) => panic_handler("afl_custom_init", err),
|
||||
Err(err) => panic_handler("afl_custom_init", &err),
|
||||
}
|
||||
}
|
||||
|
||||
@ -196,32 +197,27 @@ pub mod wrappers {
|
||||
) -> usize {
|
||||
match catch_unwind(|| {
|
||||
let mut context = FFIContext::<M>::from(data);
|
||||
if buf.is_null() {
|
||||
panic!("null buf passed to afl_custom_fuzz")
|
||||
}
|
||||
if out_buf.is_null() {
|
||||
panic!("null out_buf passed to afl_custom_fuzz")
|
||||
}
|
||||
|
||||
assert!(!buf.is_null(), "null buf passed to afl_custom_fuzz");
|
||||
assert!(!out_buf.is_null(), "null out_buf passed to afl_custom_fuzz");
|
||||
|
||||
let buff_slice = slice::from_raw_parts_mut(buf, buf_size);
|
||||
let add_buff_slice = if add_buf.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(slice::from_raw_parts(add_buf, add_buf_size))
|
||||
};
|
||||
match context.mutator.fuzz(buff_slice, add_buff_slice, max_size) {
|
||||
Some(buffer) => {
|
||||
*out_buf = buffer.as_ptr();
|
||||
buffer.len()
|
||||
}
|
||||
None => {
|
||||
// return the input buffer with 0-length to let AFL skip this mutation attempt
|
||||
*out_buf = buf;
|
||||
0
|
||||
}
|
||||
if let Some(buffer) = context.mutator.fuzz(buff_slice, add_buff_slice, max_size) {
|
||||
*out_buf = buffer.as_ptr();
|
||||
buffer.len()
|
||||
} else {
|
||||
// return the input buffer with 0-length to let AFL skip this mutation attempt
|
||||
*out_buf = buf;
|
||||
0
|
||||
}
|
||||
}) {
|
||||
Ok(ret) => ret,
|
||||
Err(err) => panic_handler("afl_custom_fuzz", err),
|
||||
Err(err) => panic_handler("afl_custom_fuzz", &err),
|
||||
}
|
||||
}
|
||||
|
||||
@ -237,9 +233,8 @@ pub mod wrappers {
|
||||
) -> u32 {
|
||||
match catch_unwind(|| {
|
||||
let mut context = FFIContext::<M>::from(data);
|
||||
if buf.is_null() {
|
||||
panic!("null buf passed to afl_custom_fuzz")
|
||||
}
|
||||
assert!(!buf.is_null(), "null buf passed to afl_custom_fuzz");
|
||||
|
||||
let buf_slice = slice::from_raw_parts(buf, buf_size);
|
||||
// see https://doc.rust-lang.org/nomicon/borrow-splitting.html
|
||||
let ctx = &mut **context;
|
||||
@ -247,37 +242,39 @@ pub mod wrappers {
|
||||
mutator.fuzz_count(buf_slice)
|
||||
}) {
|
||||
Ok(ret) => ret,
|
||||
Err(err) => panic_handler("afl_custom_fuzz_count", err),
|
||||
Err(err) => panic_handler("afl_custom_fuzz_count", &err),
|
||||
}
|
||||
}
|
||||
|
||||
/// Internal function used in the macro
|
||||
pub fn afl_custom_queue_new_entry_<M: RawCustomMutator>(
|
||||
pub unsafe fn afl_custom_queue_new_entry_<M: RawCustomMutator>(
|
||||
data: *mut c_void,
|
||||
filename_new_queue: *const c_char,
|
||||
filename_orig_queue: *const c_char,
|
||||
) -> bool {
|
||||
match catch_unwind(|| {
|
||||
let mut context = FFIContext::<M>::from(data);
|
||||
if filename_new_queue.is_null() {
|
||||
panic!("received null filename_new_queue in afl_custom_queue_new_entry");
|
||||
}
|
||||
assert!(
|
||||
!filename_new_queue.is_null(),
|
||||
"received null filename_new_queue in afl_custom_queue_new_entry"
|
||||
);
|
||||
|
||||
let filename_new_queue = Path::new(OsStr::from_bytes(
|
||||
unsafe { CStr::from_ptr(filename_new_queue) }.to_bytes(),
|
||||
));
|
||||
let filename_orig_queue = if !filename_orig_queue.is_null() {
|
||||
let filename_orig_queue = if filename_orig_queue.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(Path::new(OsStr::from_bytes(
|
||||
unsafe { CStr::from_ptr(filename_orig_queue) }.to_bytes(),
|
||||
)))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
context
|
||||
.mutator
|
||||
.queue_new_entry(filename_new_queue, filename_orig_queue)
|
||||
}) {
|
||||
Ok(ret) => ret,
|
||||
Err(err) => panic_handler("afl_custom_queue_new_entry", err),
|
||||
Err(err) => panic_handler("afl_custom_queue_new_entry", &err),
|
||||
}
|
||||
}
|
||||
|
||||
@ -292,7 +289,7 @@ pub mod wrappers {
|
||||
ManuallyDrop::into_inner(FFIContext::<M>::from(data));
|
||||
}) {
|
||||
Ok(ret) => ret,
|
||||
Err(err) => panic_handler("afl_custom_deinit", err),
|
||||
Err(err) => panic_handler("afl_custom_deinit", &err),
|
||||
}
|
||||
}
|
||||
|
||||
@ -306,13 +303,13 @@ pub mod wrappers {
|
||||
buf.extend_from_slice(res.as_bytes());
|
||||
buf.push(0);
|
||||
// unwrapping here, as the error case should be extremely rare
|
||||
CStr::from_bytes_with_nul(&buf).unwrap().as_ptr()
|
||||
CStr::from_bytes_with_nul(buf).unwrap().as_ptr()
|
||||
} else {
|
||||
null()
|
||||
}
|
||||
}) {
|
||||
Ok(ret) => ret,
|
||||
Err(err) => panic_handler("afl_custom_introspection", err),
|
||||
Err(err) => panic_handler("afl_custom_introspection", &err),
|
||||
}
|
||||
}
|
||||
|
||||
@ -329,18 +326,18 @@ pub mod wrappers {
|
||||
buf.extend_from_slice(res.as_bytes());
|
||||
buf.push(0);
|
||||
// unwrapping here, as the error case should be extremely rare
|
||||
CStr::from_bytes_with_nul(&buf).unwrap().as_ptr()
|
||||
CStr::from_bytes_with_nul(buf).unwrap().as_ptr()
|
||||
} else {
|
||||
null()
|
||||
}
|
||||
}) {
|
||||
Ok(ret) => ret,
|
||||
Err(err) => panic_handler("afl_custom_describe", err),
|
||||
Err(err) => panic_handler("afl_custom_describe", &err),
|
||||
}
|
||||
}
|
||||
|
||||
/// Internal function used in the macro
|
||||
pub fn afl_custom_queue_get_<M: RawCustomMutator>(
|
||||
pub unsafe fn afl_custom_queue_get_<M: RawCustomMutator>(
|
||||
data: *mut c_void,
|
||||
filename: *const c_char,
|
||||
) -> u8 {
|
||||
@ -348,12 +345,12 @@ pub mod wrappers {
|
||||
let mut context = FFIContext::<M>::from(data);
|
||||
assert!(!filename.is_null());
|
||||
|
||||
context.mutator.queue_get(Path::new(OsStr::from_bytes(
|
||||
u8::from(context.mutator.queue_get(Path::new(OsStr::from_bytes(
|
||||
unsafe { CStr::from_ptr(filename) }.to_bytes(),
|
||||
))) as u8
|
||||
))))
|
||||
}) {
|
||||
Ok(ret) => ret,
|
||||
Err(err) => panic_handler("afl_custom_queue_get", err),
|
||||
Err(err) => panic_handler("afl_custom_queue_get", &err),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -373,7 +370,7 @@ macro_rules! _define_afl_custom_init {
|
||||
};
|
||||
}
|
||||
|
||||
/// An exported macro to defined afl_custom_init meant for insternal usage
|
||||
/// An exported macro to defined `afl_custom_init` meant for internal usage
|
||||
#[cfg(not(feature = "afl_internals"))]
|
||||
#[macro_export]
|
||||
macro_rules! _define_afl_custom_init {
|
||||
@ -444,7 +441,7 @@ macro_rules! export_mutator {
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn afl_custom_queue_new_entry(
|
||||
pub unsafe extern "C" fn afl_custom_queue_new_entry(
|
||||
data: *mut ::std::os::raw::c_void,
|
||||
filename_new_queue: *const ::std::os::raw::c_char,
|
||||
filename_orig_queue: *const ::std::os::raw::c_char,
|
||||
@ -457,7 +454,7 @@ macro_rules! export_mutator {
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn afl_custom_queue_get(
|
||||
pub unsafe extern "C" fn afl_custom_queue_get(
|
||||
data: *mut ::std::os::raw::c_void,
|
||||
filename: *const ::std::os::raw::c_char,
|
||||
) -> u8 {
|
||||
@ -520,9 +517,10 @@ mod sanity_test {
|
||||
export_mutator!(ExampleMutator);
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
/// A custom mutator.
|
||||
/// [`CustomMutator::handle_error`] will be called in case any method returns an [`Result::Err`].
|
||||
#[allow(unused_variables)]
|
||||
#[allow(clippy::missing_errors_doc)]
|
||||
pub trait CustomMutator {
|
||||
/// The error type. All methods must return the same error type.
|
||||
type Error: Debug;
|
||||
@ -537,7 +535,7 @@ pub trait CustomMutator {
|
||||
.map(|v| !v.is_empty())
|
||||
.unwrap_or(false)
|
||||
{
|
||||
eprintln!("Error in custom mutator: {:?}", err)
|
||||
eprintln!("Error in custom mutator: {err:?}");
|
||||
}
|
||||
}
|
||||
|
||||
@ -759,8 +757,7 @@ mod truncate_test {
|
||||
let actual_output = truncate_str_unicode_safe(input, *max_len);
|
||||
assert_eq!(
|
||||
&actual_output, expected_output,
|
||||
"{:#?} truncated to {} bytes should be {:#?}, but is {:#?}",
|
||||
input, max_len, expected_output, actual_output
|
||||
"{input:#?} truncated to {max_len} bytes should be {expected_output:#?}, but is {actual_output:#?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
name = "example_mutator"
|
||||
version = "0.1.0"
|
||||
authors = ["Julius Hohnerlein <julihoh@users.noreply.github.com>"]
|
||||
edition = "2018"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
name = "example_lain"
|
||||
version = "0.1.0"
|
||||
authors = ["Julius Hohnerlein <julihoh@users.noreply.github.com>"]
|
||||
edition = "2018"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
|
@ -3,18 +3,57 @@
|
||||
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.05a (dev)
|
||||
### Version ++4.06c (release)
|
||||
- afl-fuzz:
|
||||
- ensure temporary file descriptor is closed when not used
|
||||
- added `AFL_NO_WARN_INSTABILITY`
|
||||
- added time_wo_finds to fuzzer_stats
|
||||
- fixed a crash in pizza (1st april easter egg) mode. Sorry for
|
||||
everyone who was affected!
|
||||
- allow pizza mode to be disabled when AFL_PIZZA_MODE is set to -1
|
||||
- option `-p mmopt` now also selects new queue items more often
|
||||
- fix bug in post_process custom mutator implementation
|
||||
- print name of custom mutator in UI
|
||||
- slight changes that improve fuzzer performance
|
||||
- afl-cc:
|
||||
- add CFI sanitizer variant to gcc targets
|
||||
- llvm 16 + 17 support (thanks to @devnexen!)
|
||||
- support llvm 15 native pcguard changes
|
||||
- support for LLVMFuzzerTestOneInput -1 return
|
||||
- LTO autoken and llvm_mode: added AFL_LLVM_DICT2FILE_NO_MAIN support
|
||||
- qemu_mode:
|
||||
- fix _RANGES envs to allow hyphens in the filenames
|
||||
- basic riscv support
|
||||
- frida_mode:
|
||||
- added `AFL_FRIDA_STATS_INTERVAL`
|
||||
- fix issue on MacOS
|
||||
- unicorn_mode:
|
||||
- updated and minor issues fixed
|
||||
- nyx_mode support for all tools
|
||||
- better sanitizer default options support for all tools
|
||||
- new custom module: autotoken, a grammar free fuzzer for text inputs
|
||||
- fixed custom mutator C examples
|
||||
- more minor fixes and cross-platform support
|
||||
|
||||
### Version ++4.05c (release)
|
||||
- MacOS: libdislocator, libtokencap etc. do not work with modern
|
||||
MacOS anymore, but could be patched to work, see this issue if you
|
||||
want to make the effort and send a PR:
|
||||
https://github.com/AFLplusplus/AFLplusplus/issues/1594
|
||||
- afl-fuzz:
|
||||
- added afl_custom_fuzz_send custom mutator feature. Now your can
|
||||
send fuzz data to the target as you need, e.g. via IPC.
|
||||
- cmplog mode now has -l R option for random colorization, thanks
|
||||
- cmplog mode now has a -l R option for random colorization, thanks
|
||||
to guyf2010 for the PR!
|
||||
- queue statistics are written every 30 minutes to
|
||||
out/NAME/queue_data - likely this will be moved to a debug flag
|
||||
in the future.
|
||||
out/NAME/queue_data if compiled with INTROSPECTION
|
||||
- new env: AFL_FORK_SERVER_KILL_SIGNAL
|
||||
- afl-showmap/afl-cmin
|
||||
- -t none now translates to -t 120000 (120 seconds)
|
||||
- `-t none` now translates to `-t 120000` (120 seconds)
|
||||
- unicorn_mode updated
|
||||
- updated rust custom mutator dependencies and LibAFL custom mutator
|
||||
- overall better sanitizer default setting handling
|
||||
- several minor bugfixes
|
||||
|
||||
### Version ++4.04c (release)
|
||||
- fix gramatron and grammar_mutator build scripts
|
||||
|
@ -483,6 +483,7 @@ directory. This includes:
|
||||
- `fuzzer_pid` - PID of the fuzzer process
|
||||
- `cycles_done` - queue cycles completed so far
|
||||
- `cycles_wo_finds` - number of cycles without any new paths found
|
||||
- `time_wo_finds` - longest time in seconds no new path was found
|
||||
- `execs_done` - number of execve() calls attempted
|
||||
- `execs_per_sec` - overall number of execs per second
|
||||
- `corpus_count` - total number of entries in the queue
|
||||
|
@ -48,6 +48,7 @@ C/C++:
|
||||
```c
|
||||
void *afl_custom_init(afl_state_t *afl, unsigned int seed);
|
||||
unsigned int afl_custom_fuzz_count(void *data, const unsigned char *buf, size_t buf_size);
|
||||
void afl_custom_splice_optout(void *data);
|
||||
size_t afl_custom_fuzz(void *data, unsigned char *buf, size_t buf_size, unsigned char **out_buf, unsigned char *add_buf, size_t add_buf_size, size_t max_size);
|
||||
const char *afl_custom_describe(void *data, size_t max_description_len);
|
||||
size_t afl_custom_post_process(void *data, unsigned char *buf, size_t buf_size, unsigned char **out_buf);
|
||||
@ -72,6 +73,9 @@ def init(seed):
|
||||
def fuzz_count(buf):
|
||||
return cnt
|
||||
|
||||
def splice_optout()
|
||||
pass
|
||||
|
||||
def fuzz(buf, add_buf, max_size):
|
||||
return mutated_out
|
||||
|
||||
@ -114,7 +118,7 @@ def deinit(): # optional for Python
|
||||
|
||||
### Custom Mutation
|
||||
|
||||
- `init`:
|
||||
- `init` (optional in Python):
|
||||
|
||||
This method is called when AFL++ starts up and is used to seed RNG and set
|
||||
up buffers and state.
|
||||
@ -132,6 +136,13 @@ def deinit(): # optional for Python
|
||||
for a specific queue entry, use this function. This function is most useful
|
||||
if `AFL_CUSTOM_MUTATOR_ONLY` is **not** used.
|
||||
|
||||
- `splice_optout` (optional):
|
||||
|
||||
If this function is present, no splicing target is passed to the `fuzz`
|
||||
function. This saves time if splicing data is not needed by the custom
|
||||
fuzzing function.
|
||||
This function is never called, just needs to be present to activate.
|
||||
|
||||
- `fuzz` (optional):
|
||||
|
||||
This method performs custom mutations on a given input. It also accepts an
|
||||
@ -139,6 +150,7 @@ def deinit(): # optional for Python
|
||||
sense to use it. You would only skip this if `post_process` is used to fix
|
||||
checksums etc. so if you are using it, e.g., as a post processing library.
|
||||
Note that a length > 0 *must* be returned!
|
||||
The returned output buffer is under **your** memory management!
|
||||
|
||||
- `describe` (optional):
|
||||
|
||||
@ -172,6 +184,11 @@ def deinit(): # optional for Python
|
||||
to the target, e.g. if it is too short, too corrupted, etc. If so,
|
||||
return a NULL buffer and zero length (or a 0 length string in Python).
|
||||
|
||||
NOTE: Do not make any random changes to the data in this function!
|
||||
|
||||
PERFORMANCE for C/C++: If possible make the changes in-place (so modify
|
||||
the `*data` directly, and return it as `*outbuf = data`.
|
||||
|
||||
- `fuzz_send` (optional):
|
||||
|
||||
This method can be used if you want to send data to the target yourself,
|
||||
@ -190,7 +207,7 @@ def deinit(): # optional for Python
|
||||
discovered if compiled with INTROSPECTION. The custom mutator can then
|
||||
return a string (const char *) that reports the exact mutations used.
|
||||
|
||||
- `deinit`:
|
||||
- `deinit` (optional in Python):
|
||||
|
||||
The last method to be called, deinitializing the state.
|
||||
|
||||
|
@ -129,6 +129,9 @@ subset of the settings discussed in section 1, with the exception of:
|
||||
write all constant string comparisons to this file to be used later with
|
||||
afl-fuzz' `-x` option.
|
||||
|
||||
- An option to `AFL_LLVM_DICT2FILE` is `AFL_LLVM_DICT2FILE_NO_MAIN=1` which
|
||||
skill not parse `main()`.
|
||||
|
||||
- `TMPDIR` and `AFL_KEEP_ASSEMBLY`, since no temporary assembly files are
|
||||
created.
|
||||
|
||||
@ -354,6 +357,9 @@ checks or alter some of the more exotic semantics of the tool:
|
||||
- Setting `AFL_KEEP_TIMEOUTS` will keep longer running inputs if they reach
|
||||
new coverage
|
||||
|
||||
- On the contrary, if you are not interested in any timeouts, you can set
|
||||
`AFL_IGNORE_TIMEOUTS` to get a bit of speed instead.
|
||||
|
||||
- `AFL_EXIT_ON_SEED_ISSUES` will restore the vanilla afl-fuzz behavior which
|
||||
does not allow crashes or timeout seeds in the initial -i corpus.
|
||||
|
||||
@ -474,7 +480,10 @@ checks or alter some of the more exotic semantics of the tool:
|
||||
output from afl-fuzz is redirected to a file or to a pipe.
|
||||
|
||||
- Setting `AFL_NO_STARTUP_CALIBRATION` will skip the initial calibration
|
||||
of all starting seeds, and start fuzzing at once.
|
||||
of all starting seeds, and start fuzzing at once. Use with care, this
|
||||
degrades the fuzzing performance!
|
||||
|
||||
- Setting `AFL_NO_WARN_INSTABILITY` will suppress instability warnings.
|
||||
|
||||
- In QEMU mode (-Q) and FRIDA mode (-O), `AFL_PATH` will be searched for
|
||||
afl-qemu-trace and afl-frida-trace.so.
|
||||
@ -572,9 +581,15 @@ checks or alter some of the more exotic semantics of the tool:
|
||||
constructors in your target, you can set `AFL_EARLY_FORKSERVER`.
|
||||
Note that this is not a compile time option but a runtime option :-)
|
||||
|
||||
- Set `AFL_PIZZA_MODE` to 1 to enable the April 1st stats menu, set to 0
|
||||
- Set `AFL_PIZZA_MODE` to 1 to enable the April 1st stats menu, set to -1
|
||||
to disable although it is 1st of April.
|
||||
|
||||
- If you need a specific interval to update fuzzer_stats file, you can
|
||||
set `AFL_FUZZER_STATS_UPDATE_INTERVAL` to the interval in seconds you'd
|
||||
the file to be updated.
|
||||
Note that will not be exact and with slow targets it can take seconds
|
||||
until there is a slice for the time test.
|
||||
|
||||
## 5) Settings for afl-qemu-trace
|
||||
|
||||
The QEMU wrapper used to instrument binary-only code supports several settings:
|
||||
|
@ -201,10 +201,10 @@ afl-clang-fast's.
|
||||
### RetroWrite
|
||||
|
||||
RetroWrite is a static binary rewriter that can be combined with AFL++. If you
|
||||
have an x86_64 binary that still has its symbols (i.e., not stripped binary), is
|
||||
compiled with position independent code (PIC/PIE), and does not contain C++
|
||||
exceptions, then the RetroWrite solution might be for you. It decompiles to ASM
|
||||
files which can then be instrumented with afl-gcc.
|
||||
have an x86_64 or arm64 binary that does not contain C++ exceptions and - if
|
||||
x86_64 - still has it's symbols and compiled with position independent code
|
||||
(PIC/PIE), then the RetroWrite solution might be for you.
|
||||
It decompiles to ASM files which can then be instrumented with afl-gcc.
|
||||
|
||||
Binaries that are statically instrumented for fuzzing using RetroWrite are close
|
||||
in performance to compiler-instrumented binaries and outperform the QEMU-based
|
||||
|
@ -534,6 +534,8 @@ dictionaries/FORMAT.dict`.
|
||||
* With `afl-clang-fast`, you can set
|
||||
`AFL_LLVM_DICT2FILE=/full/path/to/new/file.dic` to automatically generate a
|
||||
dictionary during target compilation.
|
||||
Adding `AFL_LLVM_DICT2FILE_NO_MAIN=1` to not parse main (usually command line
|
||||
parameter parsing) is often a good idea too.
|
||||
* You also have the option to generate a dictionary yourself during an
|
||||
independent run of the target, see
|
||||
[utils/libtokencap/README.md](../utils/libtokencap/README.md).
|
||||
@ -628,7 +630,8 @@ If you have a large corpus, a corpus from a previous run or are fuzzing in a CI,
|
||||
then also set `export AFL_CMPLOG_ONLY_NEW=1` and `export AFL_FAST_CAL=1`.
|
||||
If the queue in the CI is huge and/or the execution time is slow then you can
|
||||
also add `AFL_NO_STARTUP_CALIBRATION=1` to skip the initial queue calibration
|
||||
phase and start fuzzing at once.
|
||||
phase and start fuzzing at once - but only do this if the calibration phase
|
||||
would be too long for your fuzz run time.
|
||||
|
||||
You can also use different fuzzers. If you are using AFL spinoffs or AFL
|
||||
conforming fuzzers, then just use the same -o directory and give it a unique
|
||||
@ -914,7 +917,8 @@ normal fuzzing campaigns as these are much shorter runnings.
|
||||
|
||||
If the queue in the CI is huge and/or the execution time is slow then you can
|
||||
also add `AFL_NO_STARTUP_CALIBRATION=1` to skip the initial queue calibration
|
||||
phase and start fuzzing at once.
|
||||
phase and start fuzzing at once. But only do that if the calibration time is
|
||||
too long for your overall available fuzz run time.
|
||||
|
||||
1. Always:
|
||||
* LTO has a much longer compile time which is diametrical to short fuzzing -
|
||||
@ -935,7 +939,7 @@ phase and start fuzzing at once.
|
||||
3. Also randomize the afl-fuzz runtime options, e.g.:
|
||||
* 65% for `AFL_DISABLE_TRIM`
|
||||
* 50% for `AFL_KEEP_TIMEOUTS`
|
||||
* 50% use a dictionary generated by `AFL_LLVM_DICT2FILE`
|
||||
* 50% use a dictionary generated by `AFL_LLVM_DICT2FILE` + `AFL_LLVM_DICT2FILE_NO_MAIN=1`
|
||||
* 40% use MOpt (`-L 0`)
|
||||
* 40% for `AFL_EXPAND_HAVOC_NOW`
|
||||
* 20% for old queue processing (`-Z`)
|
||||
|
@ -3,6 +3,8 @@
|
||||
In the following, we describe a variety of ideas that could be implemented for
|
||||
future AFL++ versions.
|
||||
|
||||
**NOTE:** Our GSoC participation is concerning [libafl](https://github.com/AFLplusplus/libafl), not AFL++.
|
||||
|
||||
## Analysis software
|
||||
|
||||
Currently analysis is done by using afl-plot, which is rather outdated. A GTK or
|
||||
@ -16,17 +18,6 @@ and Y axis, zoom factor, log scaling on-off, etc.
|
||||
|
||||
Mentor: vanhauser-thc
|
||||
|
||||
## WASM Instrumentation
|
||||
|
||||
Currently, AFL++ can be used for source code fuzzing and traditional binaries.
|
||||
With the rise of WASM as a compile target, however, a novel way of
|
||||
instrumentation needs to be implemented for binaries compiled to Webassembly.
|
||||
This can either be done by inserting instrumentation directly into the WASM AST,
|
||||
or by patching feedback into a WASM VM of choice, similar to the current Unicorn
|
||||
instrumentation.
|
||||
|
||||
Mentor: any
|
||||
|
||||
## Support other programming languages
|
||||
|
||||
Other programming languages also use llvm hence they could be (easily?)
|
||||
|
@ -1,5 +1,10 @@
|
||||
# Tools that help fuzzing with AFL++
|
||||
|
||||
## AFL++ and other development languages
|
||||
|
||||
* [afl-rs](https://github.com/rust-fuzz/afl.rs) - AFL++ for RUST
|
||||
* [WASM](https://github.com/fgsect/WAFL) - AFL++ for WASM
|
||||
|
||||
## Speeding up fuzzing
|
||||
|
||||
* [libfiowrapper](https://github.com/marekzmyslowski/libfiowrapper) - if the
|
||||
|
@ -54,4 +54,5 @@
|
||||
"__sanitizer_cov_trace_pc_guard";
|
||||
"__sanitizer_cov_trace_pc_guard_init";
|
||||
"__sanitizer_cov_trace_switch";
|
||||
"LLVMFuzzerTestOneInput";
|
||||
};
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
PWD:=$(shell pwd)/
|
||||
ROOT:=$(PWD)../
|
||||
INC_DIR:=$(PWD)include/
|
||||
@ -98,6 +99,25 @@ ifeq "$(shell uname)" "Darwin"
|
||||
OS:=macos
|
||||
AFL_CFLAGS:=$(AFL_CFLAGS) -Wno-deprecated-declarations
|
||||
GUM_ARCH:=""
|
||||
ifeq "$(ARCH)" "arm64"
|
||||
TARGET_CC= \
|
||||
"clang" \
|
||||
"-target" \
|
||||
"arm64-apple-macos10.9"
|
||||
TARGET_CXX= \
|
||||
"clang++" \
|
||||
"-target" \
|
||||
"arm64-apple-macos10.9"
|
||||
else
|
||||
TARGET_CC= \
|
||||
"clang" \
|
||||
"-target" \
|
||||
"x86_64-apple-macos10.9"
|
||||
TARGET_CXX= \
|
||||
"clang++" \
|
||||
"-target" \
|
||||
"x86_64-apple-macos10.9"
|
||||
endif
|
||||
else
|
||||
ifdef DEBUG
|
||||
AFL_CFLAGS:=$(AFL_CFLAGS) -Wno-prio-ctor-dtor
|
||||
@ -145,7 +165,7 @@ ifndef OS
|
||||
$(error "Operating system unsupported")
|
||||
endif
|
||||
|
||||
GUM_DEVKIT_VERSION=16.0.1
|
||||
GUM_DEVKIT_VERSION=16.0.11
|
||||
GUM_DEVKIT_FILENAME=frida-gumjs-devkit-$(GUM_DEVKIT_VERSION)-$(OS)-$(ARCH).tar.xz
|
||||
GUM_DEVKIT_URL="https://github.com/frida/frida/releases/download/$(GUM_DEVKIT_VERSION)/$(GUM_DEVKIT_FILENAME)"
|
||||
|
||||
@ -191,6 +211,9 @@ all: $(FRIDA_TRACE) $(FRIDA_TRACE_LIB) $(AFLPP_FRIDA_DRIVER_HOOK_OBJ) $(AFLPP_QE
|
||||
32:
|
||||
CFLAGS="-m32" LDFLAGS="-m32" ARCH="x86" make all
|
||||
|
||||
arm:
|
||||
CFLAGS="-marm" LDFLAGS="-marm" ARCH="armhf" TARGET_CC=arm-linux-gnueabihf-gcc TARGET_CXX=arm-linux-gnueabihf-g++ make all
|
||||
|
||||
$(BUILD_DIR):
|
||||
mkdir -p $(BUILD_DIR)
|
||||
|
||||
|
@ -193,6 +193,13 @@ instrumented address block translations.
|
||||
backpatching information. By default, the child will report applied
|
||||
backpatches to the parent so that they can be applied and then be inherited by
|
||||
the next child on fork.
|
||||
* `AFL_FRIDA_INST_NO_SUPPRESS` - Disable deterministic branch suppression.
|
||||
Deterministic branch suppression skips the preamble which generates coverage
|
||||
information at the start of each block, if the block is reached by a
|
||||
deterministic branch. This reduces map polution, and may improve performance
|
||||
when all the executing blocks have been prefetched and backpatching applied.
|
||||
However, in the event that backpatching is incomplete, this may incur a
|
||||
performance penatly as branch instructions are disassembled on each branch.
|
||||
* `AFL_FRIDA_INST_SEED` - Sets the initial seed for the hash function used to
|
||||
generate block (and hence edge) IDs. Setting this to a constant value may be
|
||||
useful for debugging purposes, e.g., investigating unstable edges.
|
||||
|
@ -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-2022 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2023 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:
|
||||
|
@ -22,6 +22,7 @@
|
||||
js_api_set_instrument_no_optimize;
|
||||
js_api_set_instrument_regs_file;
|
||||
js_api_set_instrument_seed;
|
||||
js_api_set_instrument_suppress_disable;
|
||||
js_api_set_instrument_trace;
|
||||
js_api_set_instrument_trace_unique;
|
||||
js_api_set_instrument_unstable_coverage_file;
|
||||
|
@ -15,6 +15,7 @@ extern guint64 instrument_hash_zero;
|
||||
extern char *instrument_coverage_unstable_filename;
|
||||
extern gboolean instrument_coverage_insn;
|
||||
extern char *instrument_regs_filename;
|
||||
extern gboolean instrument_suppress;
|
||||
|
||||
extern gboolean instrument_use_fixed_seed;
|
||||
extern guint64 instrument_fixed_seed;
|
||||
|
@ -27,6 +27,7 @@ gboolean instrument_optimize = false;
|
||||
gboolean instrument_unique = false;
|
||||
guint64 instrument_hash_zero = 0;
|
||||
guint64 instrument_hash_seed = 0;
|
||||
gboolean instrument_suppress = false;
|
||||
|
||||
gboolean instrument_use_fixed_seed = FALSE;
|
||||
guint64 instrument_fixed_seed = 0;
|
||||
@ -290,6 +291,7 @@ void instrument_config(void) {
|
||||
(getenv("AFL_FRIDA_INST_UNSTABLE_COVERAGE_FILE"));
|
||||
instrument_coverage_insn = (getenv("AFL_FRIDA_INST_INSN") != NULL);
|
||||
instrument_regs_filename = getenv("AFL_FRIDA_INST_REGS_FILE");
|
||||
instrument_suppress = (getenv("AFL_FRIDA_INST_NO_SUPPRESS") == NULL);
|
||||
|
||||
instrument_debug_config();
|
||||
instrument_coverage_config();
|
||||
@ -321,6 +323,9 @@ void instrument_init(void) {
|
||||
FOKF(cBLU "Instrumentation" cRST " - " cGRN "instructions:" cYEL " [%c]",
|
||||
instrument_coverage_insn ? 'X' : ' ');
|
||||
|
||||
FOKF(cBLU "Instrumentation" cRST " - " cGRN "suppression:" cYEL " [%c]",
|
||||
instrument_suppress ? 'X' : ' ');
|
||||
|
||||
if (instrument_tracing && instrument_optimize) {
|
||||
|
||||
WARNF("AFL_FRIDA_INST_TRACE implies AFL_FRIDA_INST_NO_OPTIMIZE");
|
||||
|
@ -273,7 +273,19 @@ void instrument_flush(GumStalkerOutput *output) {
|
||||
|
||||
gpointer instrument_cur(GumStalkerOutput *output) {
|
||||
|
||||
return gum_arm_writer_cur(output->writer.arm);
|
||||
gpointer curr = NULL;
|
||||
|
||||
if (output->encoding == GUM_INSTRUCTION_SPECIAL) {
|
||||
|
||||
curr = gum_thumb_writer_cur(output->writer.thumb);
|
||||
|
||||
} else {
|
||||
|
||||
curr = gum_arm_writer_cur(output->writer.arm);
|
||||
|
||||
}
|
||||
|
||||
return curr;
|
||||
|
||||
}
|
||||
|
||||
|
@ -196,6 +196,14 @@ static void instrument_coverage_switch(GumStalkerObserver *self,
|
||||
insn = instrument_disassemble(from_insn);
|
||||
deterministic = instrument_is_deterministic(insn);
|
||||
cs_free(insn, 1);
|
||||
|
||||
/*
|
||||
* If the branch is deterministic, then we should start execution at the
|
||||
* begining of the block. From here, we will branch and skip the coverage
|
||||
* code and jump right to the target code of the instrumented block.
|
||||
* Otherwise, if the branch is non-deterministic, then we need to branch
|
||||
* part way into the block to where the coverage instrumentation starts.
|
||||
*/
|
||||
if (deterministic) { return; }
|
||||
|
||||
/*
|
||||
@ -305,7 +313,7 @@ void instrument_coverage_optimize(const cs_insn *instr,
|
||||
|
||||
// gum_arm64_writer_put_brk_imm(cw, 0x0);
|
||||
|
||||
instrument_coverage_suppress_init();
|
||||
if (instrument_suppress) { instrument_coverage_suppress_init(); }
|
||||
|
||||
code_addr = cw->pc;
|
||||
|
||||
@ -325,9 +333,13 @@ void instrument_coverage_optimize(const cs_insn *instr,
|
||||
block_start =
|
||||
GSIZE_TO_POINTER(GUM_ADDRESS(cw->code) - GUM_RESTORATION_PROLOG_SIZE);
|
||||
|
||||
if (!g_hash_table_add(coverage_blocks, block_start)) {
|
||||
if (instrument_suppress) {
|
||||
|
||||
FATAL("Failed - g_hash_table_add");
|
||||
if (!g_hash_table_add(coverage_blocks, block_start)) {
|
||||
|
||||
FATAL("Failed - g_hash_table_add");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -363,7 +375,17 @@ void instrument_coverage_optimize(const cs_insn *instr,
|
||||
|
||||
code.code.mov_x1_curr_loc_shr_1 |= (area_offset_ror << 5);
|
||||
|
||||
gum_arm64_writer_put_bytes(cw, code.bytes, sizeof(afl_log_code));
|
||||
if (instrument_suppress) {
|
||||
|
||||
gum_arm64_writer_put_bytes(cw, code.bytes, sizeof(afl_log_code));
|
||||
|
||||
} else {
|
||||
|
||||
size_t offset = offsetof(afl_log_code, code.stp_x0_x1);
|
||||
gum_arm64_writer_put_bytes(cw, &code.bytes[offset],
|
||||
sizeof(afl_log_code) - offset);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -380,11 +380,15 @@ void instrument_coverage_optimize(const cs_insn *instr,
|
||||
|
||||
}
|
||||
|
||||
instrument_coverage_suppress_init();
|
||||
if (instrument_suppress) {
|
||||
|
||||
if (!g_hash_table_add(coverage_blocks, GSIZE_TO_POINTER(cw->code))) {
|
||||
instrument_coverage_suppress_init();
|
||||
|
||||
FATAL("Failed - g_hash_table_add");
|
||||
if (!g_hash_table_add(coverage_blocks, GSIZE_TO_POINTER(cw->code))) {
|
||||
|
||||
FATAL("Failed - g_hash_table_add");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -203,13 +203,17 @@ void instrument_coverage_optimize(const cs_insn *instr,
|
||||
|
||||
code.code = template;
|
||||
|
||||
instrument_coverage_suppress_init();
|
||||
if (instrument_suppress) {
|
||||
|
||||
// gum_x86_writer_put_breakpoint(cw);
|
||||
instrument_coverage_suppress_init();
|
||||
|
||||
if (!g_hash_table_add(coverage_blocks, GSIZE_TO_POINTER(cw->code))) {
|
||||
// gum_x86_writer_put_breakpoint(cw);
|
||||
|
||||
FATAL("Failed - g_hash_table_add");
|
||||
if (!g_hash_table_add(coverage_blocks, GSIZE_TO_POINTER(cw->code))) {
|
||||
|
||||
FATAL("Failed - g_hash_table_add");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -170,6 +170,12 @@ class Afl {
|
||||
static setInstrumentSeed(seed) {
|
||||
Afl.jsApiSetInstrumentSeed(seed);
|
||||
}
|
||||
/*
|
||||
* See `AFL_FRIDA_INST_NO_SUPPRESS`
|
||||
*/
|
||||
static setInstrumentSuppressDisable() {
|
||||
Afl.jsApiSetInstrumentSuppressDisable();
|
||||
}
|
||||
/**
|
||||
* See `AFL_FRIDA_INST_TRACE_UNIQUE`.
|
||||
*/
|
||||
@ -339,6 +345,7 @@ Afl.jsApiSetInstrumentLibraries = Afl.jsApiGetFunction("js_api_set_instrument_li
|
||||
Afl.jsApiSetInstrumentNoOptimize = Afl.jsApiGetFunction("js_api_set_instrument_no_optimize", "void", []);
|
||||
Afl.jsApiSetInstrumentRegsFile = Afl.jsApiGetFunction("js_api_set_instrument_regs_file", "void", ["pointer"]);
|
||||
Afl.jsApiSetInstrumentSeed = Afl.jsApiGetFunction("js_api_set_instrument_seed", "void", ["uint64"]);
|
||||
Afl.jsApiSetInstrumentSuppressDisable = Afl.jsApiGetFunction("js_api_set_instrument_suppress_disable", "void", []);
|
||||
Afl.jsApiSetInstrumentTrace = Afl.jsApiGetFunction("js_api_set_instrument_trace", "void", []);
|
||||
Afl.jsApiSetInstrumentTraceUnique = Afl.jsApiGetFunction("js_api_set_instrument_trace_unique", "void", []);
|
||||
Afl.jsApiSetInstrumentUnstableCoverageFile = Afl.jsApiGetFunction("js_api_set_instrument_unstable_coverage_file", "void", ["pointer"]);
|
||||
|
@ -289,6 +289,13 @@ __attribute__((visibility("default"))) void js_api_set_instrument_cache_size(
|
||||
|
||||
}
|
||||
|
||||
__attribute__((visibility("default"))) void
|
||||
js_api_set_instrument_suppress_disable(void) {
|
||||
|
||||
instrument_suppress = false;
|
||||
|
||||
}
|
||||
|
||||
__attribute__((visibility("default"))) void js_api_set_js_main_hook(
|
||||
const js_main_hook_t hook) {
|
||||
|
||||
|
@ -2,8 +2,9 @@ PWD:=$(shell pwd)/
|
||||
ROOT:=$(PWD)../../../
|
||||
BUILD_DIR:=$(PWD)build/
|
||||
|
||||
TEST_CMPLOG_BASENAME=compcovtest
|
||||
TEST_CMPLOG_SRC=$(PWD)cmplog.c
|
||||
TEST_CMPLOG_OBJ=$(BUILD_DIR)compcovtest
|
||||
TEST_CMPLOG_OBJ=$(BUILD_DIR)$(TEST_CMPLOG_BASENAME)
|
||||
|
||||
TEST_BIN:=$(PWD)../../build/test
|
||||
|
||||
@ -13,7 +14,7 @@ CMP_LOG_INPUT:=$(TEST_DATA_DIR)in
|
||||
QEMU_OUT:=$(BUILD_DIR)qemu-out
|
||||
FRIDA_OUT:=$(BUILD_DIR)frida-out
|
||||
|
||||
.PHONY: all 32 clean qemu frida frida-nocmplog format
|
||||
.PHONY: all 32 clean qemu frida frida-nocmplog frida-unprefixedpath format
|
||||
|
||||
all: $(TEST_CMPLOG_OBJ)
|
||||
make -C $(ROOT)frida_mode/
|
||||
@ -64,6 +65,18 @@ frida-nocmplog: $(TEST_CMPLOG_OBJ) $(CMP_LOG_INPUT)
|
||||
-- \
|
||||
$(TEST_CMPLOG_OBJ) @@
|
||||
|
||||
|
||||
frida-unprefixedpath: $(TEST_CMPLOG_OBJ) $(CMP_LOG_INPUT)
|
||||
PATH=$(BUILD_DIR) $(ROOT)afl-fuzz \
|
||||
-O \
|
||||
-i $(TEST_DATA_DIR) \
|
||||
-o $(FRIDA_OUT) \
|
||||
-c 0 \
|
||||
-l 3AT \
|
||||
-Z \
|
||||
-- \
|
||||
$(TEST_CMPLOG_BASENAME) @@
|
||||
|
||||
debug: $(TEST_CMPLOG_OBJ) $(CMP_LOG_INPUT)
|
||||
gdb \
|
||||
--ex 'set environment LD_PRELOAD=$(ROOT)afl-frida-trace.so' \
|
||||
|
@ -19,6 +19,9 @@ frida:
|
||||
frida-nocmplog:
|
||||
@gmake frida-nocmplog
|
||||
|
||||
frida-unprefixedpath:
|
||||
@gmake frida-unprefixedpath
|
||||
|
||||
format:
|
||||
@gmake format
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// Author: Mateusz Jurczyk (mjurczyk@google.com)
|
||||
//
|
||||
// Copyright 2019-2022 Google LLC
|
||||
// Copyright 2019-2023 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-2022 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2023 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-2022 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2023 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-2022 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2023 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-2022 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2023 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-2022 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2023 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-2022 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2023 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-2022 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2023 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-2022 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2023 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-2022 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2023 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:
|
||||
|
@ -7,10 +7,10 @@ LIBPNG_BUILD_DIR:=$(BUILD_DIR)libpng/
|
||||
HARNESS_BUILD_DIR:=$(BUILD_DIR)harness/
|
||||
PNGTEST_BUILD_DIR:=$(BUILD_DIR)pngtest/
|
||||
|
||||
LIBZ_FILE:=$(LIBZ_BUILD_DIR)zlib-1.2.12.tar.gz
|
||||
LIBZ_URL:=http://www.zlib.net/zlib-1.2.12.tar.gz
|
||||
LIBZ_DIR:=$(LIBZ_BUILD_DIR)zlib-1.2.12/
|
||||
LIBZ_PC:=$(ZLIB_DIR)zlib.pc
|
||||
LIBZ_FILE:=$(LIBZ_BUILD_DIR)zlib-1.2.13.tar.gz
|
||||
LIBZ_URL:=http://www.zlib.net/zlib-1.2.13.tar.gz
|
||||
LIBZ_DIR:=$(LIBZ_BUILD_DIR)zlib-1.2.13/
|
||||
LIBZ_PC:=$(LIBZ_DIR)zlib.pc
|
||||
LIBZ_LIB:=$(LIBZ_DIR)libz.a
|
||||
|
||||
LIBPNG_FILE:=$(LIBPNG_BUILD_DIR)libpng-1.2.56.tar.gz
|
||||
@ -25,7 +25,7 @@ HARNESS_URL:="https://raw.githubusercontent.com/llvm/llvm-project/main/compiler-
|
||||
|
||||
PNGTEST_FILE:=$(PNGTEST_BUILD_DIR)target.cc
|
||||
PNGTEST_OBJ:=$(PNGTEST_BUILD_DIR)target.o
|
||||
PNGTEST_URL:="https://raw.githubusercontent.com/google/fuzzbench/master/benchmarks/libpng-1.2.56/target.cc"
|
||||
PNGTEST_URL:="https://raw.githubusercontent.com/google/fuzzbench/e0c4a994b6999bae46e8dec5bcea9a73251b8dba/benchmarks/libpng-1.2.56/target.cc"
|
||||
|
||||
TEST_BIN:=$(BUILD_DIR)test
|
||||
ifeq "$(shell uname)" "Darwin"
|
||||
@ -48,7 +48,7 @@ all: $(TEST_BIN)
|
||||
CFLAGS="-m32" LDFLAGS="-m32" make $(TEST_BIN)
|
||||
|
||||
arm:
|
||||
ARCH="arm" CC="arm-linux-gnueabihf-gcc" CXX="arm-linux-gnueabihf-g++" make $(TEST_BIN)
|
||||
CFLAGS="-marm" LDFLAGS="-marm" CC="arm-linux-gnueabihf-gcc" CXX="arm-linux-gnueabihf-g++" make $(TEST_BIN)
|
||||
|
||||
$(BUILD_DIR):
|
||||
mkdir -p $@
|
||||
@ -96,7 +96,7 @@ $(LIBZ_PC): | $(LIBZ_DIR)
|
||||
--static \
|
||||
--archs="$(ARCH)"
|
||||
|
||||
$(LIBZ_LIB): $(LIBZ_PC)
|
||||
$(LIBZ_LIB): | $(LIBZ_PC)
|
||||
CFLAGS="$(CFLAGS) -fPIC" \
|
||||
make \
|
||||
-C $(LIBZ_DIR) \
|
||||
@ -133,7 +133,7 @@ png: $(LIBPNG_LIB)
|
||||
|
||||
######### TEST ########
|
||||
|
||||
$(TEST_BIN): $(HARNESS_OBJ) $(PNGTEST_OBJ) $(LIBPNG_LIB)
|
||||
$(TEST_BIN): $(HARNESS_OBJ) $(PNGTEST_OBJ) $(LIBPNG_LIB) $(LIBZ_LIB)
|
||||
$(CXX) \
|
||||
$(CFLAGS) \
|
||||
$(LDFLAGS) \
|
||||
|
@ -18,6 +18,9 @@ all: $(TESTINSTBIN)
|
||||
32:
|
||||
CFLAGS="-m32" LDFLAGS="-m32" ARCH="x86" make all
|
||||
|
||||
arm:
|
||||
CFLAGS="-marm" LDFLAGS="-marm" CC="arm-linux-gnueabihf-gcc" CXX="arm-linux-gnueabihf-g++" make $(TESTINSTBIN)
|
||||
|
||||
$(BUILD_DIR):
|
||||
mkdir -p $@
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
--------------------------------------------------------
|
||||
Originally written by Michal Zalewski
|
||||
Copyright 2014 Google Inc. All rights reserved.
|
||||
Copyright 2019-2022 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2023 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-2022 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2023 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:
|
||||
|
@ -201,6 +201,13 @@ class Afl {
|
||||
Afl.jsApiSetInstrumentSeed(seed);
|
||||
}
|
||||
|
||||
/*
|
||||
* See `AFL_FRIDA_INST_NO_SUPPRESS`
|
||||
*/
|
||||
public static setInstrumentSuppressDisable(): void{
|
||||
Afl.jsApiSetInstrumentSuppressDisable();
|
||||
}
|
||||
|
||||
/**
|
||||
* See `AFL_FRIDA_INST_TRACE_UNIQUE`.
|
||||
*/
|
||||
@ -451,6 +458,11 @@ class Afl {
|
||||
"void",
|
||||
["uint64"]);
|
||||
|
||||
private static readonly jsApiSetInstrumentSuppressDisable = Afl.jsApiGetFunction(
|
||||
"js_api_set_instrument_suppress_disable",
|
||||
"void",
|
||||
[]);
|
||||
|
||||
private static readonly jsApiSetInstrumentTrace = Afl.jsApiGetFunction(
|
||||
"js_api_set_instrument_trace",
|
||||
"void",
|
||||
|
432
frida_mode/ts/package-lock.json
generated
432
frida_mode/ts/package-lock.json
generated
@ -1,11 +1,433 @@
|
||||
{
|
||||
"requires": true,
|
||||
"name": "@worksbutnottested/aflplusplus-frida",
|
||||
"version": "1.0.1",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"tsc": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/tsc/-/tsc-2.0.3.tgz",
|
||||
"integrity": "sha512-SN+9zBUtrpUcOpaUO7GjkEHgWtf22c7FKbKCA4e858eEM7Qz86rRDpgOU2lBIDf0fLCsEg65ms899UMUIB2+Ow==",
|
||||
"@babel/code-frame": {
|
||||
"version": "7.18.6",
|
||||
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.18.6.tgz",
|
||||
"integrity": "sha512-TDCmlK5eOvH+eH7cdAFlNXeVJqWIQ7gW9tY1GJIpUtFb6CmjVyq2VM3u71bOyR8CRihcCgMUYoDNyLXao3+70Q==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@babel/highlight": "^7.18.6"
|
||||
}
|
||||
},
|
||||
"@babel/helper-validator-identifier": {
|
||||
"version": "7.19.1",
|
||||
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz",
|
||||
"integrity": "sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==",
|
||||
"dev": true
|
||||
},
|
||||
"@babel/highlight": {
|
||||
"version": "7.18.6",
|
||||
"resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.18.6.tgz",
|
||||
"integrity": "sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@babel/helper-validator-identifier": "^7.18.6",
|
||||
"chalk": "^2.0.0",
|
||||
"js-tokens": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"@types/frida-gum": {
|
||||
"version": "16.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/frida-gum/-/frida-gum-16.5.1.tgz",
|
||||
"integrity": "sha512-t+2HZG6iBO2cEKtb2KvtP33m/7TGmzSd42YqznToA34+TkS97NttsFZ9OY2s0hPyDQOg+hZTjR1QggRkEL/Ovg=="
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "14.18.36",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.36.tgz",
|
||||
"integrity": "sha512-FXKWbsJ6a1hIrRxv+FoukuHnGTgEzKYGi7kilfMae96AL9UNkPFNWJEEYWzdRI9ooIkbr4AKldyuSTLql06vLQ==",
|
||||
"dev": true
|
||||
},
|
||||
"ansi-styles": {
|
||||
"version": "3.2.1",
|
||||
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
|
||||
"integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"color-convert": "^1.9.0"
|
||||
}
|
||||
},
|
||||
"argparse": {
|
||||
"version": "1.0.10",
|
||||
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
|
||||
"integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"sprintf-js": "~1.0.2"
|
||||
}
|
||||
},
|
||||
"balanced-match": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
|
||||
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
|
||||
"dev": true
|
||||
},
|
||||
"brace-expansion": {
|
||||
"version": "1.1.11",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
||||
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"balanced-match": "^1.0.0",
|
||||
"concat-map": "0.0.1"
|
||||
}
|
||||
},
|
||||
"builtin-modules": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz",
|
||||
"integrity": "sha512-wxXCdllwGhI2kCC0MnvTGYTMvnVZTvqgypkiTI8Pa5tcz2i6VqsqwYGgqwXji+4RgCzms6EajE4IxiUH6HH8nQ==",
|
||||
"dev": true
|
||||
},
|
||||
"chalk": {
|
||||
"version": "2.4.2",
|
||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
|
||||
"integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ansi-styles": "^3.2.1",
|
||||
"escape-string-regexp": "^1.0.5",
|
||||
"supports-color": "^5.3.0"
|
||||
}
|
||||
},
|
||||
"color-convert": {
|
||||
"version": "1.9.3",
|
||||
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
|
||||
"integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"color-name": "1.1.3"
|
||||
}
|
||||
},
|
||||
"color-name": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
|
||||
"integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==",
|
||||
"dev": true
|
||||
},
|
||||
"commander": {
|
||||
"version": "2.20.3",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz",
|
||||
"integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==",
|
||||
"dev": true
|
||||
},
|
||||
"concat-map": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||
"integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",
|
||||
"dev": true
|
||||
},
|
||||
"diff": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz",
|
||||
"integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==",
|
||||
"dev": true
|
||||
},
|
||||
"escape-string-regexp": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
|
||||
"integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==",
|
||||
"dev": true
|
||||
},
|
||||
"esprima": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
|
||||
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==",
|
||||
"dev": true
|
||||
},
|
||||
"fs.realpath": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
||||
"integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==",
|
||||
"dev": true
|
||||
},
|
||||
"function-bind": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
|
||||
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==",
|
||||
"dev": true
|
||||
},
|
||||
"get-caller-file": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz",
|
||||
"integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==",
|
||||
"dev": true
|
||||
},
|
||||
"glob": {
|
||||
"version": "7.2.3",
|
||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz",
|
||||
"integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"fs.realpath": "^1.0.0",
|
||||
"inflight": "^1.0.4",
|
||||
"inherits": "2",
|
||||
"minimatch": "^3.1.1",
|
||||
"once": "^1.3.0",
|
||||
"path-is-absolute": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"has": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
|
||||
"integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"function-bind": "^1.1.1"
|
||||
}
|
||||
},
|
||||
"has-flag": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
|
||||
"integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==",
|
||||
"dev": true
|
||||
},
|
||||
"inflight": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
|
||||
"integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"once": "^1.3.0",
|
||||
"wrappy": "1"
|
||||
}
|
||||
},
|
||||
"inherits": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
|
||||
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
|
||||
"dev": true
|
||||
},
|
||||
"is-core-module": {
|
||||
"version": "2.11.0",
|
||||
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.11.0.tgz",
|
||||
"integrity": "sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"has": "^1.0.3"
|
||||
}
|
||||
},
|
||||
"js-tokens": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
|
||||
"integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==",
|
||||
"dev": true
|
||||
},
|
||||
"js-yaml": {
|
||||
"version": "3.14.1",
|
||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz",
|
||||
"integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"argparse": "^1.0.7",
|
||||
"esprima": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"minimatch": {
|
||||
"version": "3.1.2",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
|
||||
"integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"brace-expansion": "^1.1.7"
|
||||
}
|
||||
},
|
||||
"minimist": {
|
||||
"version": "1.2.7",
|
||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.7.tgz",
|
||||
"integrity": "sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g==",
|
||||
"dev": true
|
||||
},
|
||||
"mkdirp": {
|
||||
"version": "0.5.6",
|
||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz",
|
||||
"integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"minimist": "^1.2.6"
|
||||
}
|
||||
},
|
||||
"mock-require": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/mock-require/-/mock-require-3.0.3.tgz",
|
||||
"integrity": "sha512-lLzfLHcyc10MKQnNUCv7dMcoY/2Qxd6wJfbqCcVk3LDb8An4hF6ohk5AztrvgKhJCqj36uyzi/p5se+tvyD+Wg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"get-caller-file": "^1.0.2",
|
||||
"normalize-path": "^2.1.1"
|
||||
}
|
||||
},
|
||||
"normalize-path": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz",
|
||||
"integrity": "sha512-3pKJwH184Xo/lnH6oyP1q2pMd7HcypqqmRs91/6/i2CGtWwIKGCkOOMTm/zXbgTEWHw1uNpNi/igc3ePOYHb6w==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"remove-trailing-separator": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"once": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
||||
"integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"wrappy": "1"
|
||||
}
|
||||
},
|
||||
"path-is-absolute": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
|
||||
"integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==",
|
||||
"dev": true
|
||||
},
|
||||
"path-parse": {
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz",
|
||||
"integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==",
|
||||
"dev": true
|
||||
},
|
||||
"remove-trailing-separator": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz",
|
||||
"integrity": "sha512-/hS+Y0u3aOfIETiaiirUFwDBDzmXPvO+jAfKTitUngIPzdKc6Z0LoFjM/CK5PL4C+eKwHohlHAb6H0VFfmmUsw==",
|
||||
"dev": true
|
||||
},
|
||||
"resolve": {
|
||||
"version": "1.22.1",
|
||||
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz",
|
||||
"integrity": "sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"is-core-module": "^2.9.0",
|
||||
"path-parse": "^1.0.7",
|
||||
"supports-preserve-symlinks-flag": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"semver": {
|
||||
"version": "5.7.1",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
|
||||
"integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==",
|
||||
"dev": true
|
||||
},
|
||||
"sprintf-js": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
|
||||
"integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==",
|
||||
"dev": true
|
||||
},
|
||||
"supports-color": {
|
||||
"version": "5.5.0",
|
||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
|
||||
"integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"has-flag": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"supports-preserve-symlinks-flag": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz",
|
||||
"integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==",
|
||||
"dev": true
|
||||
},
|
||||
"tslib": {
|
||||
"version": "1.14.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
|
||||
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
|
||||
"dev": true
|
||||
},
|
||||
"tslint": {
|
||||
"version": "6.1.3",
|
||||
"resolved": "https://registry.npmjs.org/tslint/-/tslint-6.1.3.tgz",
|
||||
"integrity": "sha512-IbR4nkT96EQOvKE2PW/djGz8iGNeJ4rF2mBfiYaR/nvUWYKJhLwimoJKgjIFEIDibBtOevj7BqCRL4oHeWWUCg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@babel/code-frame": "^7.0.0",
|
||||
"builtin-modules": "^1.1.1",
|
||||
"chalk": "^2.3.0",
|
||||
"commander": "^2.12.1",
|
||||
"diff": "^4.0.1",
|
||||
"glob": "^7.1.1",
|
||||
"js-yaml": "^3.13.1",
|
||||
"minimatch": "^3.0.4",
|
||||
"mkdirp": "^0.5.3",
|
||||
"resolve": "^1.3.2",
|
||||
"semver": "^5.3.0",
|
||||
"tslib": "^1.13.0",
|
||||
"tsutils": "^2.29.0"
|
||||
}
|
||||
},
|
||||
"tsutils": {
|
||||
"version": "2.29.0",
|
||||
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz",
|
||||
"integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"tslib": "^1.8.1"
|
||||
}
|
||||
},
|
||||
"typescript": {
|
||||
"version": "4.9.5",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz",
|
||||
"integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==",
|
||||
"dev": true
|
||||
},
|
||||
"typescript-tslint-plugin": {
|
||||
"version": "0.5.5",
|
||||
"resolved": "https://registry.npmjs.org/typescript-tslint-plugin/-/typescript-tslint-plugin-0.5.5.tgz",
|
||||
"integrity": "sha512-tR5igNQP+6FhxaPJYRlUBVsEl0n5cSuXRbg7L1y80mL4B1jUHb8uiIcbQBJ9zWyypJEdFYFUccpXxvMwZR8+AA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"minimatch": "^3.0.4",
|
||||
"mock-require": "^3.0.3",
|
||||
"vscode-languageserver": "^5.2.1"
|
||||
}
|
||||
},
|
||||
"vscode-jsonrpc": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-4.0.0.tgz",
|
||||
"integrity": "sha512-perEnXQdQOJMTDFNv+UF3h1Y0z4iSiaN9jIlb0OqIYgosPCZGYh/MCUlkFtV2668PL69lRDO32hmvL2yiidUYg==",
|
||||
"dev": true
|
||||
},
|
||||
"vscode-languageserver": {
|
||||
"version": "5.2.1",
|
||||
"resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-5.2.1.tgz",
|
||||
"integrity": "sha512-GuayqdKZqAwwaCUjDvMTAVRPJOp/SLON3mJ07eGsx/Iq9HjRymhKWztX41rISqDKhHVVyFM+IywICyZDla6U3A==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"vscode-languageserver-protocol": "3.14.1",
|
||||
"vscode-uri": "^1.0.6"
|
||||
}
|
||||
},
|
||||
"vscode-languageserver-protocol": {
|
||||
"version": "3.14.1",
|
||||
"resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.14.1.tgz",
|
||||
"integrity": "sha512-IL66BLb2g20uIKog5Y2dQ0IiigW0XKrvmWiOvc0yXw80z3tMEzEnHjaGAb3ENuU7MnQqgnYJ1Cl2l9RvNgDi4g==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"vscode-jsonrpc": "^4.0.0",
|
||||
"vscode-languageserver-types": "3.14.0"
|
||||
}
|
||||
},
|
||||
"vscode-languageserver-types": {
|
||||
"version": "3.14.0",
|
||||
"resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.14.0.tgz",
|
||||
"integrity": "sha512-lTmS6AlAlMHOvPQemVwo3CezxBp0sNB95KNPkqp3Nxd5VFEnuG1ByM0zlRWos0zjO3ZWtkvhal0COgiV1xIA4A==",
|
||||
"dev": true
|
||||
},
|
||||
"vscode-uri": {
|
||||
"version": "1.0.8",
|
||||
"resolved": "https://registry.npmjs.org/vscode-uri/-/vscode-uri-1.0.8.tgz",
|
||||
"integrity": "sha512-obtSWTlbJ+a+TFRYGaUumtVwb+InIUVI0Lu0VBUAPmj2cU5JutEXg3xUE0c2J5Tcy7h2DEKVJBFi+Y9ZSFzzPQ==",
|
||||
"dev": true
|
||||
},
|
||||
"wrappy": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||
"integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
Dominik Maier <mail@dmnk.co>
|
||||
|
||||
Copyright 2016, 2017 Google Inc. All rights reserved.
|
||||
Copyright 2019-2022 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2023 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-2022 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2023 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.
|
||||
@ -169,12 +169,16 @@ struct queue_entry {
|
||||
|
||||
u32 bitmap_size, /* Number of bits set in bitmap */
|
||||
fuzz_level, /* Number of fuzzing iterations */
|
||||
n_fuzz_entry, /* offset in n_fuzz */
|
||||
n_fuzz_entry /* offset in n_fuzz */
|
||||
#ifdef INTROSPECTION
|
||||
,
|
||||
stats_selected, /* stats: how often selected */
|
||||
stats_skipped, /* stats: how often skipped */
|
||||
stats_finds, /* stats: # of saved finds */
|
||||
stats_crashes, /* stats: # of saved crashes */
|
||||
stats_tmouts; /* stats: # of saved timeouts */
|
||||
stats_tmouts /* stats: # of saved timeouts */
|
||||
#endif
|
||||
;
|
||||
|
||||
u64 exec_us, /* Execution time (us) */
|
||||
handicap, /* Number of queue cycles behind */
|
||||
@ -340,6 +344,7 @@ enum {
|
||||
/* 12 */ PY_FUNC_INTROSPECTION,
|
||||
/* 13 */ PY_FUNC_DESCRIBE,
|
||||
/* 14 */ PY_FUNC_FUZZ_SEND,
|
||||
/* 15 */ PY_FUNC_SPLICE_OPTOUT,
|
||||
PY_FUNC_COUNT
|
||||
|
||||
};
|
||||
@ -393,8 +398,8 @@ typedef struct afl_env_vars {
|
||||
afl_bench_until_crash, afl_debug_child, afl_autoresume, afl_cal_fast,
|
||||
afl_cycle_schedules, afl_expand_havoc, afl_statsd, afl_cmplog_only_new,
|
||||
afl_exit_on_seed_issues, afl_try_affinity, afl_ignore_problems,
|
||||
afl_keep_timeouts, afl_pizza_mode, afl_no_crash_readme,
|
||||
afl_no_startup_calibration;
|
||||
afl_keep_timeouts, afl_no_crash_readme, afl_ignore_timeouts,
|
||||
afl_no_startup_calibration, afl_no_warn_instability;
|
||||
|
||||
u8 *afl_tmpdir, *afl_custom_mutator_library, *afl_python_module, *afl_path,
|
||||
*afl_hang_tmout, *afl_forksrv_init_tmout, *afl_preload,
|
||||
@ -403,6 +408,8 @@ typedef struct afl_env_vars {
|
||||
*afl_testcache_entries, *afl_child_kill_signal, *afl_fsrv_kill_signal,
|
||||
*afl_target_env, *afl_persistent_record, *afl_exit_on_time;
|
||||
|
||||
s32 afl_pizza_mode;
|
||||
|
||||
} afl_env_vars_t;
|
||||
|
||||
struct afl_pass_stat {
|
||||
@ -491,6 +498,7 @@ typedef struct afl_state {
|
||||
no_unlink, /* do not unlink cur_input */
|
||||
debug, /* Debug mode */
|
||||
custom_only, /* Custom mutator only mode */
|
||||
custom_splice_optout, /* Custom mutator no splice buffer */
|
||||
is_main_node, /* if this is the main node */
|
||||
is_secondary_node, /* if this is a secondary instance */
|
||||
pizza_is_served; /* pizza mode */
|
||||
@ -585,6 +593,7 @@ typedef struct afl_state {
|
||||
last_find_time, /* Time for most recent path (ms) */
|
||||
last_crash_time, /* Time for most recent crash (ms) */
|
||||
last_hang_time, /* Time for most recent hang (ms) */
|
||||
longest_find_time, /* Longest time taken for a find */
|
||||
exit_on_time, /* Delay to exit if no new paths */
|
||||
sync_time; /* Sync time (ms) */
|
||||
|
||||
@ -687,6 +696,7 @@ typedef struct afl_state {
|
||||
|
||||
/* statistics file */
|
||||
double last_bitmap_cvg, last_stability, last_eps;
|
||||
u64 stats_file_update_freq_msecs; /* Stats update frequency (msecs) */
|
||||
|
||||
/* plot file saves from last run */
|
||||
u32 plot_prev_qp, plot_prev_pf, plot_prev_pnf, plot_prev_ce, plot_prev_md;
|
||||
@ -825,17 +835,29 @@ struct custom_mutator {
|
||||
u32 (*afl_custom_fuzz_count)(void *data, const u8 *buf, size_t buf_size);
|
||||
|
||||
/**
|
||||
* Perform custom mutations on a given input
|
||||
* Opt-out of a splicing input for the fuzz mutator
|
||||
*
|
||||
* (Optional for now. Required in the future)
|
||||
* Empty dummy function. It's presence tells afl-fuzz not to pass a
|
||||
* splice data pointer and len.
|
||||
*
|
||||
* @param data pointer returned in afl_custom_init by this custom mutator
|
||||
* @noreturn
|
||||
*/
|
||||
void (*afl_custom_splice_optout)(void *data);
|
||||
|
||||
/**
|
||||
* Perform custom mutations on a given input
|
||||
*
|
||||
* (Optional)
|
||||
*
|
||||
* Getting an add_buf can be skipped by using afl_custom_splice_optout().
|
||||
*
|
||||
* @param[in] data Pointer returned in afl_custom_init by this custom mutator
|
||||
* @param[in] buf Pointer to the input data to be mutated and the mutated
|
||||
* output
|
||||
* @param[in] buf_size Size of the input/output data
|
||||
* @param[out] out_buf the new buffer. We may reuse *buf if large enough.
|
||||
* *out_buf = NULL is treated as FATAL.
|
||||
* @param[in] add_buf Buffer containing the additional test case
|
||||
* @param[out] out_buf The new buffer, under your memory mgmt.
|
||||
* @param[in] add_buf Buffer containing an additional test case (splicing)
|
||||
* @param[in] add_buf_size Size of the additional test case
|
||||
* @param[in] max_size Maximum size of the mutated output. The mutation must
|
||||
* not produce data larger than max_size.
|
||||
@ -863,14 +885,19 @@ struct custom_mutator {
|
||||
* A post-processing function to use right before AFL writes the test case to
|
||||
* disk in order to execute the target.
|
||||
*
|
||||
* (Optional) If this functionality is not needed, simply don't define this
|
||||
* NOTE: Do not do any random changes to the data in this function!
|
||||
*
|
||||
* PERFORMANCE: If you can modify the data in-place you will have a better
|
||||
* performance. Modify *data and set `*out_buf = data`.
|
||||
*
|
||||
* (Optional) If this functionality is not needed, simply do not define this
|
||||
* function.
|
||||
*
|
||||
* @param[in] data pointer returned in afl_custom_init by this custom mutator
|
||||
* @param[in] buf Buffer containing the test case to be executed
|
||||
* @param[in] buf_size Size of the test case
|
||||
* @param[out] out_buf Pointer to the buffer storing the test case after
|
||||
* processing. External library should allocate memory for out_buf.
|
||||
* processing. The external library should allocate memory for out_buf.
|
||||
* It can chose to alter buf in-place, if the space is large enough.
|
||||
* @return Size of the output buffer.
|
||||
*/
|
||||
@ -1053,6 +1080,7 @@ u8 havoc_mutation_probability_py(void *);
|
||||
u8 queue_get_py(void *, const u8 *);
|
||||
const char *introspection_py(void *);
|
||||
u8 queue_new_entry_py(void *, const u8 *, const u8 *);
|
||||
void splice_optout(void *);
|
||||
void deinit_py(void *);
|
||||
|
||||
#endif
|
||||
|
@ -10,7 +10,7 @@
|
||||
Dominik Maier <mail@dmnk.co>
|
||||
|
||||
Copyright 2016, 2017 Google Inc. All rights reserved.
|
||||
Copyright 2019-2022 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2023 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-2022 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2023 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-2022 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2023 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-2022 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2023 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.
|
||||
@ -43,6 +43,7 @@ u32 check_binary_signatures(u8 *fn);
|
||||
void detect_file_args(char **argv, u8 *prog_in, bool *use_stdin);
|
||||
void print_suggested_envs(char *mispelled_env);
|
||||
void check_environment_vars(char **env);
|
||||
void set_sanitizer_defaults();
|
||||
|
||||
char **argv_cpy_dup(int argc, char **argv);
|
||||
void argv_cpy_free(char **argv);
|
||||
@ -142,5 +143,15 @@ FILE *create_ffile(u8 *fn);
|
||||
/* create a file */
|
||||
s32 create_file(u8 *fn);
|
||||
|
||||
/* memmem implementation as not all platforms support this */
|
||||
void *afl_memmem(const void *haystack, size_t haystacklen, const void *needle,
|
||||
size_t needlelen);
|
||||
|
||||
#ifdef __linux__
|
||||
/* Nyx helper functions to create and remove tmp workdirs */
|
||||
char *create_nyx_tmp_workdir(void);
|
||||
void remove_nyx_tmp_workdir(afl_forkserver_t *fsrv, char *nyx_out_dir_path);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
Dominik Maier <mail@dmnk.co>
|
||||
|
||||
Copyright 2016, 2017 Google Inc. All rights reserved.
|
||||
Copyright 2019-2022 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2023 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.05a"
|
||||
#define VERSION "++4.06c"
|
||||
|
||||
/******************************************************
|
||||
* *
|
||||
@ -364,9 +364,9 @@
|
||||
* *
|
||||
***********************************************************/
|
||||
|
||||
/* Call count interval between reseeding the libc PRNG from /dev/urandom: */
|
||||
/* Call count interval between reseeding the PRNG from /dev/urandom: */
|
||||
|
||||
#define RESEED_RNG 100000
|
||||
#define RESEED_RNG 2500000
|
||||
|
||||
/* The default maximum testcase cache size in MB, 0 = disable.
|
||||
A value between 50 and 250 is a good default value. Note that the
|
||||
@ -491,10 +491,14 @@
|
||||
|
||||
#define AFL_TXT_MIN_LEN 12
|
||||
|
||||
/* Maximum length of a queue input to be evaluated for "is_ascii"? */
|
||||
|
||||
#define AFL_TXT_MAX_LEN 65535
|
||||
|
||||
/* What is the minimum percentage of ascii characters present to be classifed
|
||||
as "is_ascii"? */
|
||||
|
||||
#define AFL_TXT_MIN_PERCENT 94
|
||||
#define AFL_TXT_MIN_PERCENT 99
|
||||
|
||||
/* How often to perform ASCII mutations 0 = disable, 1-8 are good values */
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
Dominik Maier <mail@dmnk.co>
|
||||
|
||||
Copyright 2016, 2017 Google Inc. All rights reserved.
|
||||
Copyright 2019-2022 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2023 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.
|
||||
|
@ -68,6 +68,7 @@ static char *afl_environment_variables[] = {
|
||||
"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",
|
||||
@ -90,6 +91,7 @@ static char *afl_environment_variables[] = {
|
||||
"AFL_FRIDA_TRACEABLE",
|
||||
"AFL_FRIDA_VERBOSE",
|
||||
"AFL_FUZZER_ARGS", // oss-fuzz
|
||||
"AFL_FUZZER_STATS_UPDATE_INTERVAL",
|
||||
"AFL_GDB",
|
||||
"AFL_GCC_ALLOWLIST",
|
||||
"AFL_GCC_DENYLIST",
|
||||
@ -103,6 +105,7 @@ static char *afl_environment_variables[] = {
|
||||
"AFL_HARDEN",
|
||||
"AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES",
|
||||
"AFL_IGNORE_PROBLEMS",
|
||||
"AFL_IGNORE_TIMEOUTS",
|
||||
"AFL_IGNORE_UNKNOWN_ENVS",
|
||||
"AFL_IMPORT_FIRST",
|
||||
"AFL_INPUT_LEN_MIN",
|
||||
@ -124,12 +127,15 @@ static char *afl_environment_variables[] = {
|
||||
"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",
|
||||
@ -168,6 +174,7 @@ static char *afl_environment_variables[] = {
|
||||
"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",
|
||||
|
@ -12,7 +12,7 @@
|
||||
Dominik Maier <mail@dmnk.co>>
|
||||
|
||||
Copyright 2016, 2017 Google Inc. All rights reserved.
|
||||
Copyright 2019-2022 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2023 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.
|
||||
@ -43,7 +43,7 @@ typedef enum NyxReturnValue {
|
||||
Normal,
|
||||
Crash,
|
||||
Asan,
|
||||
Timout,
|
||||
Timeout,
|
||||
InvalidWriteToPayload,
|
||||
Error,
|
||||
IoError,
|
||||
@ -51,16 +51,28 @@ typedef enum NyxReturnValue {
|
||||
|
||||
} NyxReturnValue;
|
||||
|
||||
typedef enum NyxProcessRole {
|
||||
|
||||
StandAlone,
|
||||
Parent,
|
||||
Child,
|
||||
|
||||
} NyxProcessRole;
|
||||
|
||||
typedef struct {
|
||||
|
||||
void *(*nyx_new)(const char *sharedir, const char *workdir, uint32_t cpu_id,
|
||||
uint32_t input_buffer_size,
|
||||
bool input_buffer_write_protection);
|
||||
void *(*nyx_new_parent)(const char *sharedir, const char *workdir,
|
||||
uint32_t cpu_id, uint32_t input_buffer_size,
|
||||
bool input_buffer_write_protection);
|
||||
void *(*nyx_new_child)(const char *sharedir, const char *workdir,
|
||||
uint32_t cpu_id, uint32_t worker_id);
|
||||
void *(*nyx_config_load)(const char *sharedir);
|
||||
void (*nyx_config_set_workdir_path)(void *config, const char *workdir);
|
||||
void (*nyx_config_set_input_buffer_size)(void *config,
|
||||
uint32_t input_buffer_size);
|
||||
void (*nyx_config_set_input_buffer_write_protection)(
|
||||
void *config, bool input_buffer_write_protection);
|
||||
void (*nyx_config_set_hprintf_fd)(void *config, int32_t hprintf_fd);
|
||||
void (*nyx_config_set_process_role)(void *config, enum NyxProcessRole role);
|
||||
void (*nyx_config_set_reuse_snapshot_path)(void *config,
|
||||
const char *reuse_snapshot_path);
|
||||
|
||||
void *(*nyx_new)(void *config, uint32_t worker_id);
|
||||
void (*nyx_shutdown)(void *qemu_process);
|
||||
void (*nyx_option_set_reload_mode)(void *qemu_process, bool enable);
|
||||
void (*nyx_option_set_timeout)(void *qemu_process, uint8_t timeout_sec,
|
||||
@ -73,8 +85,13 @@ typedef struct {
|
||||
uint32_t (*nyx_get_aux_string)(void *nyx_process, uint8_t *buffer,
|
||||
uint32_t size);
|
||||
|
||||
bool (*nyx_remove_work_dir)(const char *workdir);
|
||||
|
||||
} nyx_plugin_handler_t;
|
||||
|
||||
/* Imports helper functions to enable Nyx mode (Linux only )*/
|
||||
nyx_plugin_handler_t *afl_load_libnyx_plugin(u8 *libnyx_binary);
|
||||
|
||||
#endif
|
||||
|
||||
typedef struct afl_forkserver {
|
||||
@ -178,6 +195,8 @@ typedef struct afl_forkserver {
|
||||
u32 nyx_id; /* nyx runner id (0 -> master) */
|
||||
u32 nyx_bind_cpu_id; /* nyx runner cpu id */
|
||||
char *nyx_aux_string;
|
||||
bool nyx_use_tmp_workdir;
|
||||
char *nyx_tmp_workdir_path;
|
||||
#endif
|
||||
|
||||
} afl_forkserver_t;
|
||||
|
@ -15,7 +15,7 @@
|
||||
Other code written by Michal Zalewski
|
||||
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
Copyright 2019-2022 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2023 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-2022 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2023 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-2022 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2023 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-2022 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2023 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-2022 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2023 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-2022 Yann Collet
|
||||
* Copyright (C) 2012-2023 Yann Collet
|
||||
*
|
||||
* BSD 2-Clause License (https://www.opensource.org/licenses/bsd-license.php)
|
||||
*
|
||||
|
@ -167,6 +167,10 @@ Just specify `AFL_LLVM_DICT2FILE=/absolute/path/file.txt` and during compilation
|
||||
all constant string compare parameters will be written to this file to be used
|
||||
with afl-fuzz' `-x` option.
|
||||
|
||||
Adding `AFL_LLVM_DICT2FILE_NO_MAIN=1` will skip parsing `main()` which often
|
||||
does command line parsing which has string comparisons that are not helpful
|
||||
for fuzzing.
|
||||
|
||||
## 6) AFL++ Context Sensitive Branch Coverage
|
||||
|
||||
### What is this?
|
||||
|
@ -2,36 +2,37 @@
|
||||
|
||||
## TL;DR:
|
||||
|
||||
This version requires a current llvm 11+ compiled from the GitHub master.
|
||||
This version requires a LLVM 11 or newer.
|
||||
|
||||
1. Use afl-clang-lto/afl-clang-lto++ because it is faster and gives better
|
||||
coverage than anything else that is out there in the AFL world.
|
||||
1. Use afl-clang-lto/afl-clang-lto++ because the resulting binaries run
|
||||
slightly faster and give better coverage.
|
||||
|
||||
2. You can use it together with llvm_mode: laf-intel and the instrument file
|
||||
listing features and can be combined with cmplog/Redqueen.
|
||||
2. You can use it together with COMPCOV, COMPLOG and the instrument file
|
||||
listing features.
|
||||
|
||||
3. It only works with llvm 11+.
|
||||
3. It only works with LLVM 11 or newer.
|
||||
|
||||
4. AUTODICTIONARY feature (see below)!
|
||||
4. AUTODICTIONARY feature (see below)
|
||||
|
||||
5. If any problems arise, be sure to set `AR=llvm-ar RANLIB=llvm-ranlib`. Some
|
||||
targets might need `LD=afl-clang-lto` and others `LD=afl-ld-lto`.
|
||||
5. If any problems arise, be sure to set `AR=llvm-ar RANLIB=llvm-ranlib AS=llvm-as`.
|
||||
Some targets might need `LD=afl-clang-lto` and others `LD=afl-ld-lto`.
|
||||
|
||||
## Introduction and problem description
|
||||
|
||||
A big issue with how AFL++ works is that the basic block IDs that are set during
|
||||
compilation are random - and hence naturally the larger the number of
|
||||
instrumented locations, the higher the number of edge collisions are in the map.
|
||||
This can result in not discovering new paths and therefore degrade the
|
||||
A big issue with how vanilla AFL worked was that the basic block IDs that are
|
||||
set during compilation are random - and hence naturally the larger the number
|
||||
of instrumented locations, the higher the number of edge collisions are in the
|
||||
map. This can result in not discovering new paths and therefore degrade the
|
||||
efficiency of the fuzzing process.
|
||||
|
||||
*This issue is underestimated in the fuzzing community!* With a 2^16 = 64kb
|
||||
*This issue is underestimated in the fuzzing community* With a 2^16 = 64kb
|
||||
standard map at already 256 instrumented blocks, there is on average one
|
||||
collision. On average, a target has 10.000 to 50.000 instrumented blocks, hence
|
||||
the real collisions are between 750-18.000!
|
||||
|
||||
To reach a solution that prevents any collisions took several approaches and
|
||||
many dead ends until we got to this:
|
||||
Note that PCGUARD (our own modified implementation and the SANCOV PCGUARD
|
||||
implementation from libfuzzer) also provides collision free coverage.
|
||||
It is a bit slower though and can a few targets with very early constructors.
|
||||
|
||||
* We instrument at link time when we have all files pre-compiled.
|
||||
* To instrument at link time, we compile in LTO (link time optimization) mode.
|
||||
@ -45,9 +46,9 @@ many dead ends until we got to this:
|
||||
The result:
|
||||
|
||||
* 10-25% speed gain compared to llvm_mode
|
||||
* guaranteed non-colliding edge coverage :-)
|
||||
* guaranteed non-colliding edge coverage
|
||||
* The compile time, especially for binaries to an instrumented library, can be
|
||||
much longer.
|
||||
much (and sometimes much much) longer.
|
||||
|
||||
Example build output from a libtiff build:
|
||||
|
||||
@ -59,71 +60,30 @@ 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 11+
|
||||
|
||||
### Installing llvm version 11 or 12
|
||||
### Installing llvm
|
||||
|
||||
llvm 11 or even 12 should be available in all current Linux repositories. If you
|
||||
use an outdated Linux distribution, read the next section.
|
||||
|
||||
### Installing llvm from the llvm repository (version 12+)
|
||||
|
||||
Installing the llvm snapshot builds is easy and mostly painless:
|
||||
|
||||
In the following line, change `NAME` for your Debian or Ubuntu release name
|
||||
(e.g., buster, focal, eon, etc.):
|
||||
The best way to install LLVM is to follow [https://apt.llvm.org/](https://apt.llvm.org/)
|
||||
|
||||
e.g. for LLVM 15:
|
||||
```
|
||||
echo deb http://apt.llvm.org/NAME/ llvm-toolchain-NAME NAME >> /etc/apt/sources.list
|
||||
wget https://apt.llvm.org/llvm.sh
|
||||
chmod +x llvm.sh
|
||||
sudo ./llvm.sh 15 all
|
||||
```
|
||||
|
||||
Then add the pgp key of llvm and install the packages:
|
||||
LLVM 11 to 16 should be available in all current Linux repositories.
|
||||
|
||||
## How to build afl-clang-lto
|
||||
|
||||
That part is easy.
|
||||
Just set `LLVM_CONFIG` to the llvm-config-VERSION and build AFL++, e.g. for
|
||||
LLVM 15:
|
||||
|
||||
```
|
||||
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
|
||||
apt-get update && apt-get upgrade -y
|
||||
apt-get install -y clang-12 clang-tools-12 libc++1-12 libc++-12-dev \
|
||||
libc++abi1-12 libc++abi-12-dev libclang1-12 libclang-12-dev \
|
||||
libclang-common-12-dev libclang-cpp12 libclang-cpp12-dev liblld-12 \
|
||||
liblld-12-dev liblldb-12 liblldb-12-dev libllvm12 libomp-12-dev \
|
||||
libomp5-12 lld-12 lldb-12 llvm-12 llvm-12-dev llvm-12-runtime llvm-12-tools
|
||||
```
|
||||
|
||||
### Building llvm yourself (version 12+)
|
||||
|
||||
Building llvm from GitHub takes quite some time and is not painless:
|
||||
|
||||
```sh
|
||||
sudo apt install binutils-dev # this is *essential*!
|
||||
git clone --depth=1 https://github.com/llvm/llvm-project
|
||||
cd llvm-project
|
||||
mkdir build
|
||||
cd build
|
||||
|
||||
# Add -G Ninja if ninja-build installed
|
||||
# "Building with ninja significantly improves your build time, especially with
|
||||
# incremental builds, and improves your memory usage."
|
||||
cmake \
|
||||
-DCLANG_INCLUDE_DOCS="OFF" \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DLLVM_BINUTILS_INCDIR=/usr/include/ \
|
||||
-DLLVM_BUILD_LLVM_DYLIB="ON" \
|
||||
-DLLVM_ENABLE_BINDINGS="OFF" \
|
||||
-DLLVM_ENABLE_PROJECTS='clang;compiler-rt;libcxx;libcxxabi;libunwind;lld' \
|
||||
-DLLVM_ENABLE_WARNINGS="OFF" \
|
||||
-DLLVM_INCLUDE_BENCHMARKS="OFF" \
|
||||
-DLLVM_INCLUDE_DOCS="OFF" \
|
||||
-DLLVM_INCLUDE_EXAMPLES="OFF" \
|
||||
-DLLVM_INCLUDE_TESTS="OFF" \
|
||||
-DLLVM_LINK_LLVM_DYLIB="ON" \
|
||||
-DLLVM_TARGETS_TO_BUILD="host" \
|
||||
../llvm/
|
||||
# NOTE: for llvm 16 this needs to be changed to:
|
||||
# -DLLVM_ENABLE_PROJECTS='clang;compiler-rt;lld' \
|
||||
# -DLLVM_ENABLE_RUNTIMES='libcxx;libcxxabi' \
|
||||
cmake --build . -j4
|
||||
export LLVM_CONFIG="$(pwd)/bin/llvm-config"
|
||||
cd /path/to/AFLplusplus/
|
||||
cd ~/AFLplusplus
|
||||
export LLVM_CONFIG=llvm-config-15
|
||||
make
|
||||
sudo make install
|
||||
```
|
||||
@ -136,10 +96,10 @@ Also, the instrument file listing (AFL_LLVM_ALLOWLIST/AFL_LLVM_DENYLIST ->
|
||||
[README.instrument_list.md](README.instrument_list.md)) and laf-intel/compcov
|
||||
(AFL_LLVM_LAF_* -> [README.laf-intel.md](README.laf-intel.md)) work.
|
||||
|
||||
Example:
|
||||
Example (note that you might need to add the version, e.g. `llvm-ar-15`:
|
||||
|
||||
```
|
||||
CC=afl-clang-lto CXX=afl-clang-lto++ RANLIB=llvm-ranlib AR=llvm-ar ./configure
|
||||
CC=afl-clang-lto CXX=afl-clang-lto++ RANLIB=llvm-ranlib AR=llvm-ar AS=llvm-as ./configure
|
||||
make
|
||||
```
|
||||
|
||||
@ -317,13 +277,13 @@ 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 11+ cannot compile, afl-clang-lto cannot compile either -
|
||||
obviously.
|
||||
* Anything that does not compile with LTO, afl-clang-lto cannot compile either -
|
||||
obviously.
|
||||
|
||||
Hence, if building a target with afl-clang-lto fails, try to build it with
|
||||
llvm12 and LTO enabled (`CC=clang-12`, `CXX=clang++-12`, `CFLAGS=-flto=full`,
|
||||
LLVM 12 and LTO enabled (`CC=clang-12`, `CXX=clang++-12`, `CFLAGS=-flto=full`,
|
||||
and `CXXFLAGS=-flto=full`).
|
||||
|
||||
If this succeeds, then there is an issue with afl-clang-lto. Please report at
|
||||
@ -341,7 +301,7 @@ knows what this is doing. And the developer who implemented this didn't respond
|
||||
to emails.)
|
||||
|
||||
In December then came the idea to implement this as a pass that is run via the
|
||||
llvm "opt" program, which is performed via an own linker that afterwards calls
|
||||
LLVM "opt" program, which is performed via an own linker that afterwards calls
|
||||
the real linker. This was first implemented in January and work ... kinda. The
|
||||
LTO time instrumentation worked, however, "how" the basic blocks were
|
||||
instrumented was a problem, as reducing duplicates turned out to be very, very
|
||||
@ -353,13 +313,13 @@ dead-end too.
|
||||
The final idea to solve this came from domenukk who proposed to insert a block
|
||||
into an edge and then just use incremental counters ... and this worked! After
|
||||
some trials and errors to implement this vanhauser-thc found out that there is
|
||||
actually an llvm function for this: SplitEdge() :-)
|
||||
actually an LLVM function for this: SplitEdge() :-)
|
||||
|
||||
Still more problems came up though as this only works without bugs from llvm 9
|
||||
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 11+. The llvm's own linker is now able to load
|
||||
passes and this bypasses all problems we had.
|
||||
|
||||
Happy end :)
|
||||
|
@ -17,7 +17,9 @@
|
||||
#include "llvm/Transforms/Instrumentation/SanitizerCoverage.h"
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/Triple.h"
|
||||
#if LLVM_VERSION_MAJOR < 17
|
||||
#include "llvm/ADT/Triple.h"
|
||||
#endif
|
||||
#include "llvm/Analysis/EHPersonalities.h"
|
||||
#include "llvm/Analysis/PostDominators.h"
|
||||
#include "llvm/Analysis/ValueTracking.h"
|
||||
@ -236,6 +238,7 @@ class ModuleSanitizerCoverageLTO
|
||||
// const SpecialCaseList * Allowlist;
|
||||
// const SpecialCaseList * Blocklist;
|
||||
uint32_t autodictionary = 1;
|
||||
uint32_t autodictionary_no_main = 0;
|
||||
uint32_t inst = 0;
|
||||
uint32_t afl_global_id = 0;
|
||||
uint32_t unhandled = 0;
|
||||
@ -411,7 +414,8 @@ bool ModuleSanitizerCoverageLTO::instrumentModule(
|
||||
|
||||
/* Show a banner */
|
||||
setvbuf(stdout, NULL, _IONBF, 0);
|
||||
if (getenv("AFL_DEBUG")) debug = 1;
|
||||
if (getenv("AFL_DEBUG")) { debug = 1; }
|
||||
if (getenv("AFL_LLVM_DICT2FILE_NO_MAIN")) { autodictionary_no_main = 1; }
|
||||
|
||||
if ((isatty(2) && !getenv("AFL_QUIET")) || debug) {
|
||||
|
||||
@ -429,6 +433,8 @@ bool ModuleSanitizerCoverageLTO::instrumentModule(
|
||||
if ((afl_global_id = atoi(ptr)) < 0)
|
||||
FATAL("AFL_LLVM_LTO_STARTID value of \"%s\" is negative\n", ptr);
|
||||
|
||||
if (afl_global_id < 4) { afl_global_id = 4; }
|
||||
|
||||
if ((ptr = getenv("AFL_LLVM_DOCUMENT_IDS")) != NULL) {
|
||||
|
||||
dFile.open(ptr, std::ofstream::out | std::ofstream::app);
|
||||
@ -503,6 +509,13 @@ bool ModuleSanitizerCoverageLTO::instrumentModule(
|
||||
|
||||
if (!isInInstrumentList(&F, MNAME) || !F.size()) { continue; }
|
||||
|
||||
if (autodictionary_no_main &&
|
||||
(!F.getName().compare("main") || !F.getName().compare("_main"))) {
|
||||
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
for (auto &BB : F) {
|
||||
|
||||
for (auto &IN : BB) {
|
||||
@ -1770,6 +1783,7 @@ INITIALIZE_PASS_END(ModuleSanitizerCoverageLTOLegacyPass, "sancov-lto",
|
||||
"Pass for instrumenting coverage on functions", false,
|
||||
false)
|
||||
|
||||
#if LLVM_VERSION_MAJOR < 16
|
||||
static void registerLTOPass(const PassManagerBuilder &,
|
||||
legacy::PassManagerBase &PM) {
|
||||
|
||||
@ -1784,8 +1798,9 @@ static RegisterStandardPasses RegisterCompTransPass(
|
||||
static RegisterStandardPasses RegisterCompTransPass0(
|
||||
PassManagerBuilder::EP_EnabledOnOptLevel0, registerLTOPass);
|
||||
|
||||
#if LLVM_VERSION_MAJOR >= 11
|
||||
#if LLVM_VERSION_MAJOR >= 11
|
||||
static RegisterStandardPasses RegisterCompTransPassLTO(
|
||||
PassManagerBuilder::EP_FullLinkTimeOptimizationLast, registerLTOPass);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -13,7 +13,9 @@
|
||||
#include "llvm/Transforms/Instrumentation/SanitizerCoverage.h"
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/Triple.h"
|
||||
#if LLVM_VERSION_MAJOR < 17
|
||||
#include "llvm/ADT/Triple.h"
|
||||
#endif
|
||||
#include "llvm/Analysis/EHPersonalities.h"
|
||||
#include "llvm/Analysis/PostDominators.h"
|
||||
#include "llvm/IR/CFG.h"
|
||||
@ -728,7 +730,11 @@ GlobalVariable *ModuleSanitizerCoverageAFL::CreateFunctionLocalArrayInSection(
|
||||
Array->setSection(getSectionName(Section));
|
||||
#if (LLVM_VERSION_MAJOR >= 11) || \
|
||||
(LLVM_VERSION_MAJOR == 10 && LLVM_VERSION_MINOR >= 1)
|
||||
#if LLVM_VERSION_MAJOR >= 16
|
||||
Array->setAlignment(Align(DL->getTypeStoreSize(Ty).getFixedValue()));
|
||||
#else
|
||||
Array->setAlignment(Align(DL->getTypeStoreSize(Ty).getFixedSize()));
|
||||
#endif
|
||||
#else
|
||||
Array->setAlignment(Align(4)); // cheating
|
||||
#endif
|
||||
|
@ -3,7 +3,7 @@
|
||||
------------------------------------------------
|
||||
|
||||
Copyright 2015, 2016 Google Inc. All rights reserved.
|
||||
Copyright 2019-2022 AFLplusplus Project. All rights reserved.
|
||||
Copyright 2019-2023 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.
|
||||
@ -113,7 +113,7 @@ int __afl_selective_coverage __attribute__((weak));
|
||||
int __afl_selective_coverage_start_off __attribute__((weak));
|
||||
static int __afl_selective_coverage_temp = 1;
|
||||
|
||||
#if defined(__ANDROID__) || defined(__HAIKU__)
|
||||
#if defined(__ANDROID__) || defined(__HAIKU__) || defined(NO_TLS)
|
||||
PREV_LOC_T __afl_prev_loc[NGRAM_SIZE_MAX];
|
||||
PREV_LOC_T __afl_prev_caller[CTX_MAX_K];
|
||||
u32 __afl_prev_ctx;
|
||||
@ -149,6 +149,7 @@ u32 __afl_already_initialized_shm;
|
||||
u32 __afl_already_initialized_forkserver;
|
||||
u32 __afl_already_initialized_first;
|
||||
u32 __afl_already_initialized_second;
|
||||
u32 __afl_already_initialized_early;
|
||||
u32 __afl_already_initialized_init;
|
||||
|
||||
/* Dummy pipe for area_is_valid() */
|
||||
@ -1373,6 +1374,9 @@ __attribute__((constructor(EARLY_FS_PRIO))) void __early_forkserver(void) {
|
||||
|
||||
__attribute__((constructor(CTOR_PRIO))) void __afl_auto_early(void) {
|
||||
|
||||
if (__afl_already_initialized_early) return;
|
||||
__afl_already_initialized_early = 1;
|
||||
|
||||
is_persistent = !!getenv(PERSIST_ENV_VAR);
|
||||
|
||||
if (getenv("AFL_DISABLE_LLVM_INSTRUMENTATION")) return;
|
||||
@ -1514,6 +1518,14 @@ void __sanitizer_cov_trace_pc_guard_init(uint32_t *start, uint32_t *stop) {
|
||||
|
||||
_is_sancov = 1;
|
||||
|
||||
if (!getenv("AFL_DUMP_MAP_SIZE")) {
|
||||
|
||||
__afl_auto_first();
|
||||
__afl_auto_second();
|
||||
__afl_auto_early();
|
||||
|
||||
}
|
||||
|
||||
if (__afl_debug) {
|
||||
|
||||
fprintf(stderr,
|
||||
@ -1524,7 +1536,21 @@ void __sanitizer_cov_trace_pc_guard_init(uint32_t *start, uint32_t *stop) {
|
||||
|
||||
}
|
||||
|
||||
if (start == stop || *start) return;
|
||||
if (start == stop || *start) { return; }
|
||||
|
||||
x = getenv("AFL_INST_RATIO");
|
||||
if (x) {
|
||||
|
||||
inst_ratio = (u32)atoi(x);
|
||||
|
||||
if (!inst_ratio || inst_ratio > 100) {
|
||||
|
||||
fprintf(stderr, "[-] ERROR: Invalid AFL_INST_RATIO (must be 1-100).\n");
|
||||
abort();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// If a dlopen of an instrumented library happens after the forkserver then
|
||||
// we have a problem as we cannot increase the coverage map anymore.
|
||||
@ -1537,85 +1563,55 @@ void __sanitizer_cov_trace_pc_guard_init(uint32_t *start, uint32_t *stop) {
|
||||
"[-] FATAL: forkserver is already up, but an instrumented dlopen() "
|
||||
"library loaded afterwards. You must AFL_PRELOAD such libraries to "
|
||||
"be able to fuzz them or LD_PRELOAD to run outside of afl-fuzz.\n"
|
||||
"To ignore this set AFL_IGNORE_PROBLEMS=1.\n");
|
||||
"To ignore this set AFL_IGNORE_PROBLEMS=1 but this will be bad for "
|
||||
"coverage.\n");
|
||||
abort();
|
||||
|
||||
} else {
|
||||
|
||||
static u32 offset = 4;
|
||||
static u32 offset = 5;
|
||||
|
||||
while (start < stop) {
|
||||
|
||||
*(start++) = offset;
|
||||
if (unlikely(++offset >= __afl_final_loc)) { offset = 4; }
|
||||
if (likely(inst_ratio == 100) || R(100) < inst_ratio) {
|
||||
|
||||
*(start++) = offset;
|
||||
|
||||
} else {
|
||||
|
||||
*(start++) = 0; // write to map[0]
|
||||
|
||||
}
|
||||
|
||||
if (unlikely(++offset >= __afl_final_loc)) { offset = 5; }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
x = getenv("AFL_INST_RATIO");
|
||||
if (x) { inst_ratio = (u32)atoi(x); }
|
||||
|
||||
if (!inst_ratio || inst_ratio > 100) {
|
||||
|
||||
fprintf(stderr, "[-] ERROR: Invalid AFL_INST_RATIO (must be 1-100).\n");
|
||||
abort();
|
||||
return; // we are done for this special case
|
||||
|
||||
}
|
||||
|
||||
/* instrumented code is loaded *after* our forkserver is up. this is a
|
||||
problem. We cannot prevent collisions then :( */
|
||||
/*
|
||||
if (__afl_already_initialized_forkserver &&
|
||||
__afl_final_loc + 1 + stop - start > __afl_map_size) {
|
||||
|
||||
if (__afl_debug) {
|
||||
|
||||
fprintf(stderr, "Warning: new instrumented code after the forkserver!\n");
|
||||
|
||||
}
|
||||
|
||||
__afl_final_loc = 2;
|
||||
|
||||
if (1 + stop - start > __afl_map_size) {
|
||||
|
||||
*(start++) = ++__afl_final_loc;
|
||||
|
||||
while (start < stop) {
|
||||
|
||||
if (R(100) < inst_ratio)
|
||||
*start = ++__afl_final_loc % __afl_map_size;
|
||||
else
|
||||
*start = 4;
|
||||
|
||||
start++;
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
/* Make sure that the first element in the range is always set - we use that
|
||||
to avoid duplicate calls (which can happen as an artifact of the underlying
|
||||
implementation in LLVM). */
|
||||
|
||||
if (__afl_final_loc < 5) __afl_final_loc = 5; // we skip the first 5 entries
|
||||
|
||||
*(start++) = ++__afl_final_loc;
|
||||
|
||||
while (start < stop) {
|
||||
|
||||
if (R(100) < inst_ratio)
|
||||
*start = ++__afl_final_loc;
|
||||
else
|
||||
*start = 4;
|
||||
if (likely(inst_ratio == 100) || R(100) < inst_ratio) {
|
||||
|
||||
start++;
|
||||
*(start++) = ++__afl_final_loc;
|
||||
|
||||
} else {
|
||||
|
||||
*(start++) = 0; // write to map[0]
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1627,17 +1623,23 @@ void __sanitizer_cov_trace_pc_guard_init(uint32_t *start, uint32_t *stop) {
|
||||
|
||||
}
|
||||
|
||||
if (__afl_already_initialized_shm && __afl_final_loc > __afl_map_size) {
|
||||
if (__afl_already_initialized_shm) {
|
||||
|
||||
if (__afl_debug) {
|
||||
if (__afl_final_loc > __afl_map_size) {
|
||||
|
||||
fprintf(stderr, "Reinit shm necessary (+%u)\n",
|
||||
__afl_final_loc - __afl_map_size);
|
||||
if (__afl_debug) {
|
||||
|
||||
fprintf(stderr, "Reinit shm necessary (+%u)\n",
|
||||
__afl_final_loc - __afl_map_size);
|
||||
|
||||
}
|
||||
|
||||
__afl_unmap_shm();
|
||||
__afl_map_shm();
|
||||
|
||||
}
|
||||
|
||||
__afl_unmap_shm();
|
||||
__afl_map_shm();
|
||||
__afl_map_size = __afl_final_loc + 1;
|
||||
|
||||
}
|
||||
|
||||
|
@ -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-2022 AdaCore
|
||||
Copyright 2019-2023 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-2022 AdaCore
|
||||
Copyright 2019-2023 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-2022 AdaCore
|
||||
Copyright 2019-2023 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-2022 AdaCore
|
||||
Copyright 2019-2023 AdaCore
|
||||
|
||||
Written by Alexandre Oliva <oliva@adacore.com>, based on the AFL
|
||||
LLVM pass by Laszlo Szekeres <lszekeres@google.com> and Michal
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <cmath>
|
||||
|
||||
#include <llvm/Support/raw_ostream.h>
|
||||
|
||||
@ -288,6 +289,7 @@ void scanForDangerousFunctions(llvm::Module *M) {
|
||||
|
||||
StringRef ifunc_name = IF.getName();
|
||||
Constant *r = IF.getResolver();
|
||||
if (r->getNumOperands() == 0) { continue; }
|
||||
StringRef r_name = cast<Function>(r->getOperand(0))->getName();
|
||||
if (!be_quiet)
|
||||
fprintf(stderr,
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <optional>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include "llvm/Config/llvm-config.h"
|
||||
@ -35,6 +36,12 @@ typedef long double max_align_t;
|
||||
#if LLVM_VERSION_MAJOR >= 11
|
||||
#define MNAME M.getSourceFileName()
|
||||
#define FMNAME F.getParent()->getSourceFileName()
|
||||
#if LLVM_VERSION_MAJOR >= 16
|
||||
// None becomes deprecated
|
||||
// the standard std::nullopt_t is recommended instead
|
||||
// from C++17 and onwards.
|
||||
constexpr std::nullopt_t None = std::nullopt;
|
||||
#endif
|
||||
#else
|
||||
#define MNAME std::string("")
|
||||
#define FMNAME std::string("")
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user