Release Version: 2.68c
Github Version: 3.00a
Repository: https://github.com/AFLplusplus/AFLplusplus
afl++ is maintained by:
Originally developed by Michał "lcamtuf" Zalewski.
afl++ is a superior fork to Google's afl - more speed, more and better mutations, more and better instrumentation, custom module support, etc.
If you want to use afl++ for your academic work, check the papers page on the website.
With afl++ 3.0 we introduced changes that break some previous afl and afl++ behaviours and defaults:
instrumentation/
folder.-S default is assumed, so more
fuzzers can easily be added later-i input directory option now descends into subdirectories. It also
does not fatal on crashes and too large files, instead it skips them
and uses them for splicing mutationsAFL_TESTCACHE_SIZE (in MB). Good values are between 50-500 (default: 50).afl++ supports llvm up to version 12, very fast binary fuzzing with QEMU 5.1 with laf-intel and redqueen, unicorn mode, gcc plugin, full *BSD, Solaris and Android support and much, much, much more.
| Feature/Instrumentation | afl-gcc | llvm | gcc_plugin | qemu_mode | unicorn_mode |
|---|---|---|---|---|---|
| NeverZero | x86[_64] | x(1) | x | x | x |
| Persistent Mode | x | x | x86[_64]/arm[64] | x | |
| LAF-Intel / CompCov | x | x86[_64]/arm[64] | x86[_64]/arm | ||
| CmpLog | x | x86[_64]/arm[64] | |||
| Selective Instrumentation | x | x | x | ||
| Non-Colliding Coverage | x(4) | (x)(5) | |||
| Ngram prev_loc Coverage | x(6) | ||||
| Context Coverage | x(6) | ||||
| Auto Dictionary | x(7) | ||||
| Snapshot LKM Support | x | x | (x)(5) |
-xAmong others, the following features and patches have been integrated:
So all in all this is the best-of afl that is out there :-)
For new versions and additional information, check out: https://github.com/AFLplusplus/AFLplusplus
To compare notes with other users or get notified about major new features, send a mail to [email protected].
See docs/QuickStartGuide.md if you don't have time to read this file - however this is not recommended!
The following branches exist:
For releases, please see the Releases tab.
We were happy to be part of Google Summer of Code 2020 and we will try to participate again in 2021!
We have several ideas we would like to see in AFL++ to make it even better. However, we already work on so many things that we do not have the time for all the big ideas.
This can be your way to support and contribute to AFL++ - extend it to do something cool.
We have an idea list in docs/ideas.md.
For everyone who wants to contribute (and send pull requests) please read CONTRIBUTING.md before your submit.
An easy way to install afl++ with everything compiled is available via docker: You can use the Dockerfile (which has gcc-10 and clang-11 - hence afl-clang-lto is available!) or just pull directly from the docker hub:
docker pull aflplusplus/aflplusplus
docker run -ti -v /location/of/your/target:/src aflplusplus/aflplusplus
This image is automatically generated when a push to the stable repo happens. You will find your target source code in /src in the container.
If you want to build afl++ yourself you have many options. The easiest choice is to build and install everything:
sudo apt install build-essential python3-dev automake flex bison libglib2.0-dev libpixman-1-dev clang python3-setuptools llvm
make distrib
sudo make install
It is recommended to install the newest available gcc, clang and llvm-dev possible in your distribution!
Note that "make distrib" also builds instrumentation, qemu_mode, unicorn_mode and more. If you just want plain afl++ then do "make all", however compiling and using at least instrumentation is highly recommended for much better results - hence in this case
make source-only
is what you should choose.
These build targets exist:
Unless you are on Mac OS X you can also build statically linked versions of the afl++ binaries by passing the STATIC=1 argument to make:
make all STATIC=1
These build options exist:
e.g.: make ASAN_BUILD=1
Here are some good writeups to show how to effectively use AFL++:
If you are interested in fuzzing structured data (where you define what the structure is), these links have you covered:
If you find other good ones, please send them to us :-)
The following describes how to fuzz with a target if source code is available. If you have a binary-only target please skip to [#Instrumenting binary-only apps](#Instrumenting binary-only apps)
Fuzzing source code is a three-step process.
afl++ comes with a central compiler afl-cc that incorporates various different
kinds of compiler targets and and instrumentation options.
The following evaluation flow will help you to select the best possible.
It is highly recommended to have the newest llvm version possible installed, anything below 9 is not recommended.
+--------------------------------+
| clang/clang++ 11+ is available | --> use LTO mode (afl-clang-lto/afl-clang-lto++)
+--------------------------------+ see [instrumentation/README.lto.md](instrumentation/README.lto.md)
|
| if not, or if the target fails with LTO afl-clang-lto/++
|
v
+---------------------------------+
| clang/clang++ 3.3+ is available | --> use LLVM mode (afl-clang-fast/afl-clang-fast++)
+---------------------------------+ see [instrumentation/README.llvm.md](instrumentation/README.llvm.md)
|
| if not, or if the target fails with LLVM afl-clang-fast/++
|
v
+--------------------------------+
| if you want to instrument only | -> use GCC_PLUGIN mode (afl-gcc-fast/afl-g++-fast)
| parts of the target | see [instrumentation/README.gcc_plugin.md](instrumentation/README.gcc_plugin.md) and
+--------------------------------+ [instrumentation/README.instrument_list.md](instrumentation/README.instrument_list.md)
|
| if not, or if you do not have a gcc with plugin support
|
v
use GCC mode (afl-gcc/afl-g++) (or afl-clang/afl-clang++ for clang)
Clickable README links for the chosen compiler:
You can select the mode for the afl-cc compiler by:
MODE can be one of: LTO (afl-clang-lto*), LLVM (afl-clang-fast*), GCC_PLUGIN (afl-g*-fast) or GCC (afl-gcc/afl-g++).
Because no afl specific command-line options are accepted (beside the
--afl-MODE command), the compile-time tools make fairly broad use of environment
variables, which can be listed with afl-cc -hh or by reading docs/env_variables.md.
The following options are available when you instrument with LTO mode (afl-clang-fast/afl-clang-lto):
export AFL_LLVM_LAF_ALL=1
You can read more about this in instrumentation/README.laf-intel.mdinput to state or redqueen.
If you want to use this technique, then you have to compile the target
twice, once specifically with/for this mode, and pass this binary to afl-fuzz
via the -c parameter.
Note that you can compile also just a cmplog binary and use that for both
however there will be a performance penality.
You can read more about this in instrumentation/README.cmplog.mdIf you use LTO, LLVM or GCC_PLUGIN mode (afl-clang-fast/afl-clang-lto/afl-gcc-fast) you have the option to selectively only instrument parts of the target that you are interested in:
export AFL_LLVM_ALLOWLIST=allowlist.txt or
export AFL_LLVM_DENYLIST=denylist.txt - depending on if you want per
default to instrument unless noted (DENYLIST) or not perform instrumentation
unless requested (ALLOWLIST).
NOTE: During optimization functions might be inlined and then would not match!
See instrumentation/README.instrument_list.md
For afl-clang-fast > 6.0 or if PCGUARD instrumentation is used then use the
llvm sancov allow-list feature: http://clang.llvm.org/docs/SanitizerCoverage.html
The llvm sancov format works with the allowlist/denylist feature of afl++
however afl++'s format is more flexible.There are many more options and modes available however these are most of the time less effective. See:
afl++ performs "never zero" counting in its bitmap. You can read more about this here:
If the target has features that make fuzzing more difficult, e.g. checksums, HMAC, etc. then modify the source code so that this is removed. This can even be done for operational source code by eliminating these checks within this specific defines:
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
// say that the checksum or HMAC was fine - or whatever is required
// to eliminate the need for the fuzzer to guess the right checksum
return 0;
#endif
All afl++ compilers will set this preprocessor definition automatically.
In this step the target source code is compiled so that it can be fuzzed.
Basically you have to tell the target build system that the selected afl++ compiler is used. Also - if possible - you should always configure the build system such that the target is compiled statically and not dynamically. How to do this is described below.
Then build the target. (Usually with make)
NOTE: sometimes configure and build systems are fickle and do not like
stderr output (and think this means a test failure) - which is something
afl++ like to do to show statistics. It is recommended to disable them via
export AFL_QUIET=1.
For configure build systems this is usually done by:
CC=afl-clang-fast CXX=afl-clang-fast++ ./configure --disable-shared
Note that if you are using the (better) afl-clang-lto compiler you also have to set AR to llvm-ar[-VERSION] and RANLIB to llvm-ranlib[-VERSION] - as is described in instrumentation/README.lto.md.
For cmake build systems this is usually done by:
mkdir build; cmake -DCMAKE_C_COMPILERC=afl-cc -DCMAKE_CXX_COMPILER=afl-c++ ..
Note that if you are using the (better) afl-clang-lto compiler you also have to set AR to llvm-ar[-VERSION] and RANLIB to llvm-ranlib[-VERSION] - as is described in instrumentation/README.lto.md.
For meson you have to set the afl++ compiler with the very first command!
CC=afl-cc CXX=afl-c++ meson
Sometimes cmake and configure do not pick up the afl++ compiler, or the ranlib/ar that is needed - because this was just not foreseen by the developer of the target. Or they have non-standard options. Figure out if there is a non-standard way to set this, otherwise set up the build normally and edit the generated build environment afterwards manually to point it to the right compiler (and/or ranlib and ar).
If you just fuzz a target program as-is you are wasting a great opportunity for much more fuzzing speed.
This requires the usage of afl-clang-lto or afl-clang-fast.
This is the so-called persistent mode, which is much, much faster but
requires that you code a source file that is specifically calling the target
functions that you want to fuzz, plus a few specific afl++ functions around
it. See instrumentation/README.persistent_mode.md for details.
Basically if you do not fuzz a target in persistent mode then you are just doing it for a hobby and not professionally :-)
As you fuzz the target with mutated input, having as diverse inputs for the target as possible improves the efficiency a lot.
Try to gather valid inputs for the target from wherever you can. E.g. if it is the PNG picture format try to find as many png files as possible, e.g. from reported bugs, test suites, random downloads from the internet, unit test case data - from all kind of PNG software.
If the input format is not known, you can also modify a target program to write normal data it receives and processes to a file and use these.
Use the afl++ tool afl-cmin to remove inputs from the corpus that do not
produce a new path in the target.
Put all files from step a) into one directory, e.g. INPUTS.
If the target program is to be called by fuzzing as bin/target -d INPUTFILE
the run afl-cmin like this:
afl-cmin -i INPUTS -o INPUTS_UNIQUE -- bin/target -d @@
Note that the INPUTFILE argument that the target program would read from has to be set as @@.
If the target reads from stdin instead, just omit the @@ as this is the
default.
The shorter the input files that still traverse the same path
within the target, the better the fuzzing will be. This is done with afl-tmin
however it is a long process as this has to be done for every file:
mkdir input
cd INPUTS_UNIQUE
for i in *; do
afl-tmin -i "$i" -o "../input/$i" -- bin/target -d @@
done
This step can also be parallelized, e.g. with parallel
The INPUTS_UNIQUE/ directory from step b) - or even better the directory input/ if you minimized the corpus in step c) - is the resulting input corpus directory to be used in fuzzing! :-)
In this final step we fuzz the target. There are not that many important options to run the target - unless you want to use many CPU cores/threads for the fuzzing, which will make the fuzzing much more useful.
If you just use one CPU for fuzzing, then you are fuzzing just for fun and not seriously :-)
Pro tip: load the afl++ snapshot module before the start of afl-fuzz as this improves performance by a x2 speed increase (less if you use a persistent mode harness)!
Before you do even a test run of afl-fuzz execute sudo afl-system-config (on
the ho
Content type
Image
Digest
Size
912.6 MB
Last updated
almost 6 years ago
docker pull thermostatter/aflplusplus