Merge branch 'dev' into docs_add_overview

This commit is contained in:
Jana Aydinbas
2021-12-13 18:23:28 +01:00
committed by GitHub
16 changed files with 203 additions and 132 deletions

View File

@ -4473,6 +4473,10 @@ static word prim_sys(word op, word a, word b, word c) {
FD_CLOEXEC, FD_CLOEXEC,
F_DUPFD, F_DUPFD,
F_DUPFD_CLOEXEC, F_DUPFD_CLOEXEC,
#if defined(F_DUP2FD)
F_DUP2FD,
F_DUP2FD_CLOEXEC,
#endif
F_GETFD, F_GETFD,
F_SETFD, F_SETFD,
F_GETFL, F_GETFL,

View File

@ -34,6 +34,8 @@ sending a mail to <afl-users+subscribe@googlegroups.com>.
- better banner - better banner
- more effective cmplog mode - more effective cmplog mode
- more often update the UI when in input2stage mode - more often update the UI when in input2stage mode
- qemu_mode/unicorn_mode: fixed OOB write when using libcompcov,
thanks to kotee4ko for reporting!
- frida_mode: - frida_mode:
- better performance, bug fixes - better performance, bug fixes
- David Carlier added Android support :) - David Carlier added Android support :)

View File

@ -33,6 +33,19 @@ If you find an interesting or important question missing, submit it via
Report](https://www.fuzzbench.com/reports/2020-08-03/index.html). Report](https://www.fuzzbench.com/reports/2020-08-03/index.html).
</p></details> </p></details>
<details>
<summary id="is-afl-a-whitebox-graybox-or-blackbox-fuzzer">Is AFL++ a whitebox, graybox, or blackbox fuzzer?</summary><p>
The definition of the terms whitebox, graybox, and blackbox fuzzing varies
from one source to another. For example, "graybox fuzzing" could mean
binary-only or source code fuzzing, or something completely different.
Therefore, we try to avoid them.
[The Fuzzing Book](https://www.fuzzingbook.org/html/GreyboxFuzzer.html#AFL:-An-Effective-Greybox-Fuzzer)
describes the original AFL to be a graybox fuzzer. In that sense, AFL++ is
also a graybox fuzzer.
</p></details>
<details> <details>
<summary id="where-can-i-find-tutorials">Where can I find tutorials?</summary><p> <summary id="where-can-i-find-tutorials">Where can I find tutorials?</summary><p>
@ -126,6 +139,15 @@ If you find an interesting or important question missing, submit it via
## Performance ## Performance
<details>
<summary id="what-makes-a-good-performance">What makes a good performance?</summary><p>
Good performance generally means "making the fuzzing results better". This can
be influenced by various factors, for example, speed (finding lots of paths
quickly) or thoroughness (working with decreased speed, but finding better
mutations).
</p></details>
<details> <details>
<summary id="how-can-i-improve-the-fuzzing-speed">How can I improve the fuzzing speed?</summary><p> <summary id="how-can-i-improve-the-fuzzing-speed">How can I improve the fuzzing speed?</summary><p>
@ -146,8 +168,8 @@ If you find an interesting or important question missing, submit it via
the edge coverage result will be different across runs. Those edges that the edge coverage result will be different across runs. Those edges that
change are then flagged "unstable". change are then flagged "unstable".
The more "unstable" edges, the more difficult for AFL++ to identify valid new The more "unstable" edges there are, the harder it is for AFL++ to identify
paths. valid new paths.
A value above 90% is usually fine and a value above 80% is also still ok, and A value above 90% is usually fine and a value above 80% is also still ok, and
even a value above 20% can still result in successful finds of bugs. However, even a value above 20% can still result in successful finds of bugs. However,

View File

@ -95,38 +95,43 @@ Clickable README links for the chosen compiler:
* GCC/CLANG modes (afl-gcc/afl-clang) have no README as they have no own * GCC/CLANG modes (afl-gcc/afl-clang) have no README as they have no own
features features
You can select the mode for the afl-cc compiler by: You can select the mode for the afl-cc compiler by one of the following methods:
1. use a symlink to afl-cc: afl-gcc, afl-g++, afl-clang, afl-clang++,
afl-clang-fast, afl-clang-fast++, afl-clang-lto, afl-clang-lto++,
afl-gcc-fast, afl-g++-fast (recommended!)
2. using the environment variable AFL_CC_COMPILER with MODE
3. passing --afl-MODE command line options to the compiler via
CFLAGS/CXXFLAGS/CPPFLAGS
MODE can be one of: LTO (afl-clang-lto*), LLVM (afl-clang-fast*), GCC_PLUGIN * Using a symlink to afl-cc: afl-gcc, afl-g++, afl-clang, afl-clang++,
(afl-g*-fast) or GCC (afl-gcc/afl-g++) or CLANG(afl-clang/afl-clang++). afl-clang-fast, afl-clang-fast++, afl-clang-lto, afl-clang-lto++,
afl-gcc-fast, afl-g++-fast (recommended!).
* Using the environment variable `AFL_CC_COMPILER` with `MODE`.
* Passing --afl-MODE command line options to the compiler via
`CFLAGS`/`CXXFLAGS`/`CPPFLAGS`.
`MODE` can be one of the following:
* LTO (afl-clang-lto*)
* LLVM (afl-clang-fast*)
* GCC_PLUGIN (afl-g*-fast) or GCC (afl-gcc/afl-g++)
* CLANG(afl-clang/afl-clang++)
Because no AFL++ specific command-line options are accepted (beside the Because no AFL++ specific command-line options are accepted (beside the
--afl-MODE command), the compile-time tools make fairly broad use of environment --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 variables, which can be listed with `afl-cc -hh` or looked up in
[env_variables.md](env_variables.md). [env_variables.md](env_variables.md).
### b) Selecting instrumentation options ### b) Selecting instrumentation options
The following options are available when you instrument with LTO mode If you instrument with LTO mode (afl-clang-fast/afl-clang-lto), the following
(afl-clang-fast/afl-clang-lto): options are available:
* Splitting integer, string, float and switch comparisons so AFL++ can easier * Splitting integer, string, float, and switch comparisons so AFL++ can easier
solve these. This is an important option if you do not have a very good and solve these. This is an important option if you do not have a very good and
large input corpus. This technique is called laf-intel or COMPCOV. To use this large input corpus. This technique is called laf-intel or COMPCOV. To use
set the following environment variable before compiling the target: `export this, set the following environment variable before compiling the target:
AFL_LLVM_LAF_ALL=1` You can read more about this in `export AFL_LLVM_LAF_ALL=1`. You can read more about this in
[instrumentation/README.laf-intel.md](../instrumentation/README.laf-intel.md). [instrumentation/README.laf-intel.md](../instrumentation/README.laf-intel.md).
* A different technique (and usually a better one than laf-intel) is to * A different technique (and usually a better one than laf-intel) is to
instrument the target so that any compare values in the target are sent to instrument the target so that any compare values in the target are sent to
AFL++ which then tries to put these values into the fuzzing data at different AFL++ which then tries to put these values into the fuzzing data at different
locations. This technique is very fast and good - if the target does not locations. This technique is very fast and good - if the target does not
transform input data before comparison. Therefore this technique is called transform input data before comparison. Therefore, this technique is called
`input to state` or `redqueen`. If you want to use this technique, then you `input 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 by have to compile the target twice, once specifically with/for this mode by
setting `AFL_LLVM_CMPLOG=1`, and pass this binary to afl-fuzz via the `-c` setting `AFL_LLVM_CMPLOG=1`, and pass this binary to afl-fuzz via the `-c`
@ -135,24 +140,25 @@ The following options are available when you instrument with LTO mode
about this in about this in
[instrumentation/README.cmplog.md](../instrumentation/README.cmplog.md). [instrumentation/README.cmplog.md](../instrumentation/README.cmplog.md).
If you use LTO, LLVM or GCC_PLUGIN mode If you use LTO, LLVM, or GCC_PLUGIN mode
(afl-clang-fast/afl-clang-lto/afl-gcc-fast) you have the option to selectively (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: only instrument parts of the target that you are interested in:
* To instrument only those parts of the target that you are interested in create * To instrument only those parts of the target that you are interested in,
a file with all the filenames of the source code that should be instrumented. create a file with all the filenames of the source code that should be
For afl-clang-lto and afl-gcc-fast - or afl-clang-fast if a mode other than instrumented. For afl-clang-lto and afl-gcc-fast - or afl-clang-fast if a mode
DEFAULT/PCGUARD is used or you have llvm > 10.0.0 - just put one filename or other than DEFAULT/PCGUARD is used or you have llvm > 10.0.0 - just put one
function per line (no directory information necessary for filenames9, and filename or function per line (no directory information necessary for
either set `export AFL_LLVM_ALLOWLIST=allowlist.txt` **or** `export filenames), and either set `export AFL_LLVM_ALLOWLIST=allowlist.txt` **or**
AFL_LLVM_DENYLIST=denylist.txt` - depending on if you want per default to `export AFL_LLVM_DENYLIST=denylist.txt` - depending on if you want per default
instrument unless noted (DENYLIST) or not perform instrumentation unless to instrument unless noted (DENYLIST) or not perform instrumentation unless
requested (ALLOWLIST). **NOTE:** During optimization functions might be requested (ALLOWLIST). **NOTE:** During optimization functions might be
inlined and then would not match! See inlined and then would not match! See
[instrumentation/README.instrument_list.md](../instrumentation/README.instrument_list.md) [instrumentation/README.instrument_list.md](../instrumentation/README.instrument_list.md).
There are many more options and modes available, however, these are most of the There are many more options and modes available, however, these are most of the
time less effective. See: time less effective. See:
* [instrumentation/README.llvm.md#6) AFL++ Context Sensitive Branch Coverage](../instrumentation/README.llvm.md#6-afl-context-sensitive-branch-coverage) * [instrumentation/README.llvm.md#6) AFL++ Context Sensitive Branch Coverage](../instrumentation/README.llvm.md#6-afl-context-sensitive-branch-coverage)
* [instrumentation/README.llvm.md#7) AFL++ N-Gram Branch Coverage](../instrumentation/README.llvm.md#7-afl-n-gram-branch-coverage) * [instrumentation/README.llvm.md#7) AFL++ N-Gram Branch Coverage](../instrumentation/README.llvm.md#7-afl-n-gram-branch-coverage)
@ -166,12 +172,13 @@ It is possible to use sanitizers when instrumenting targets for fuzzing, which
allows you to find bugs that would not necessarily result in a crash. allows you to find bugs that would not necessarily result in a crash.
Note that sanitizers have a huge impact on CPU (= less executions per second) Note that sanitizers have a huge impact on CPU (= less executions per second)
and RAM usage. Also you should only run one afl-fuzz instance per sanitizer and RAM usage. Also, you should only run one afl-fuzz instance per sanitizer
type. This is enough because a use-after-free bug will be picked up, e.g., by type. This is enough because a use-after-free bug will be picked up, e.g., by
ASAN (address sanitizer) anyway when syncing to other fuzzing instances, so not ASAN (address sanitizer) anyway when syncing to other fuzzing instances, so not
all fuzzing instances need to be instrumented with ASAN. all fuzzing instances need to be instrumented with ASAN.
The following sanitizers have built-in support in AFL++: The following sanitizers have built-in support in AFL++:
* ASAN = Address SANitizer, finds memory corruption vulnerabilities like * ASAN = Address SANitizer, finds memory corruption vulnerabilities like
use-after-free, NULL pointer dereference, buffer overruns, etc. Enabled with use-after-free, NULL pointer dereference, buffer overruns, etc. Enabled with
`export AFL_USE_ASAN=1` before compiling. `export AFL_USE_ASAN=1` before compiling.
@ -184,7 +191,7 @@ The following sanitizers have built-in support in AFL++:
with `export AFL_USE_UBSAN=1` before compiling. with `export AFL_USE_UBSAN=1` before compiling.
* CFISAN = Control Flow Integrity SANitizer, finds instances where the control * CFISAN = Control Flow Integrity SANitizer, finds instances where the control
flow is found to be illegal. Originally this was rather to prevent return flow is found to be illegal. Originally this was rather to prevent return
oriented programming exploit chains from functioning, in fuzzing this is oriented programming exploit chains from functioning. In fuzzing, this is
mostly reduced to detecting type confusion vulnerabilities - which is, mostly reduced to detecting type confusion vulnerabilities - which is,
however, one of the most important and dangerous C++ memory corruption however, one of the most important and dangerous C++ memory corruption
classes! Enabled with `export AFL_USE_CFISAN=1` before compiling. classes! Enabled with `export AFL_USE_CFISAN=1` before compiling.
@ -227,20 +234,20 @@ All AFL++ compilers will set this preprocessor definition automatically.
### e) Instrumenting the target ### e) Instrumenting the target
In this step the target source code is compiled so that it can be fuzzed. 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++ 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 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 system in such way that the target is compiled statically and not dynamically.
do this is described below. How to do this is described below.
The #1 rule when instrumenting a target is: avoid instrumenting shared libraries The #1 rule when instrumenting a target is: avoid instrumenting shared libraries
at all cost. You would need to set LD_LIBRARY_PATH to point to these, you could at all cost. You would need to set `LD_LIBRARY_PATH` to point to these, you
accidentally type "make install" and install them system wide - so don't. Really could accidentally type "make install" and install them system wide - so don't.
don't. **Always compile libraries you want to have instrumented as static and Really don't. **Always compile libraries you want to have instrumented as static
link these to the target program!** and link these to the target program!**
Then build the target. (Usually with `make`) Then build the target. (Usually with `make`.)
**NOTES** **NOTES**
@ -258,41 +265,49 @@ Then build the target. (Usually with `make`)
#### configure #### configure
For `configure` build systems this is usually done by: For `configure` build systems, this is usually done by:
`CC=afl-clang-fast CXX=afl-clang-fast++ ./configure --disable-shared` ```
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](../instrumentation/README.lto.md).
#### CMake
For CMake build systems, this is usually done by:
```
mkdir build; cd build; cmake -DCMAKE_C_COMPILER=afl-cc -DCMAKE_CXX_COMPILER=afl-c++ ..
```
Note that if you are using the (better) afl-clang-lto compiler you also have to 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 set AR to llvm-ar[-VERSION] and RANLIB to llvm-ranlib[-VERSION] - as is
described in [instrumentation/README.lto.md](../instrumentation/README.lto.md). described in [instrumentation/README.lto.md](../instrumentation/README.lto.md).
#### cmake #### Meson Build System
For `cmake` build systems this is usually done by: For the Meson Build System, you have to set the AFL++ compiler with the very
first command!
`mkdir build; cd build; cmake -DCMAKE_C_COMPILER=afl-cc -DCMAKE_CXX_COMPILER=afl-c++ ..` ```
CC=afl-cc CXX=afl-c++ meson
```
Note that if you are using the (better) afl-clang-lto compiler you also have to #### Other build systems or if configure/cmake didn't work
set AR to llvm-ar[-VERSION] and RANLIB to llvm-ranlib[-VERSION] - as is
described in [instrumentation/README.lto.md](../instrumentation/README.lto.md).
#### 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
For meson you have to set the AFL++ compiler with the very first command! developer of the target. Or they have non-standard options. Figure out if there
`CC=afl-cc CXX=afl-c++ meson` 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
#### other build systems or if configure/cmake didn't work compiler (and/or `RANLIB` and `AR`).
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).
### f) Better instrumentation ### f) Better instrumentation
If you just fuzz a target program as-is you are wasting a great opportunity for If you just fuzz a target program as-is, you are wasting a great opportunity for
much more fuzzing speed. much more fuzzing speed.
This variant requires the usage of afl-clang-lto, afl-clang-fast or This variant requires the usage of afl-clang-lto, afl-clang-fast or
@ -304,7 +319,7 @@ that you want to fuzz, plus a few specific AFL++ functions around it. See
[instrumentation/README.persistent_mode.md](../instrumentation/README.persistent_mode.md) [instrumentation/README.persistent_mode.md](../instrumentation/README.persistent_mode.md)
for details. for details.
Basically if you do not fuzz a target in persistent mode, then you are just Basically, if you do not fuzz a target in persistent mode, then you are just
doing it for a hobby and not professionally :-). doing it for a hobby and not professionally :-).
### g) libfuzzer fuzzer harnesses with LLVMFuzzerTestOneInput() ### g) libfuzzer fuzzer harnesses with LLVMFuzzerTestOneInput()
@ -354,20 +369,24 @@ You can find many good examples of starting files in the
### b) Making the input corpus unique ### b) Making the input corpus unique
Use the AFL++ tool `afl-cmin` to remove inputs from the corpus that do not Use the AFL++ tool `afl-cmin` to remove inputs from the corpus that do not
produce a new path/coverage in the target. produce a new path/coverage in the target:
Put all files from step a) into one directory, e.g., INPUTS. 1. Put all files from [step a](#a-collecting-inputs) into one directory, e.g., INPUTS.
2. Run afl-cmin:
* If the target program is to be called by fuzzing as `bin/target -d
INPUTFILE`, set the INPUTFILE argument that the target program would read
from as `@@`:
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 @@
```
`afl-cmin -i INPUTS -o INPUTS_UNIQUE -- bin/target -d @@` * If the target reads from stdin instead, just omit the `@@` as this is the
default:
Note that the INPUTFILE argument that the target program would read from has to ```
be set as `@@`. afl-cmin -i INPUTS -o INPUTS_UNIQUE -- bin/target -d
```
If the target reads from stdin instead, just omit the `@@` as this is the
default.
This step is highly recommended! This step is highly recommended!
@ -385,14 +404,16 @@ for i in *; do
done done
``` ```
This step can also be parallelized, e.g., with `parallel`. Note that this step This step can also be parallelized, e.g., with `parallel`.
is rather optional though.
Note that this step is rather optional though.
### Done! ### Done!
The INPUTS_UNIQUE/ directory from step b) - or even better the directory input/ The INPUTS_UNIQUE/ directory from [step b](#b-making-the-input-corpus-unique) -
if you minimized the corpus in step c) - is the resulting input corpus directory or even better the directory input/ if you minimized the corpus in
to be used in fuzzing! :-) [step c](#c-minimizing-all-corpus-files) - is the resulting input corpus
directory to be used in fuzzing! :-)
## 3. Fuzzing the target ## 3. Fuzzing the target
@ -405,28 +426,31 @@ seriously :-)
### a) Running afl-fuzz ### a) Running afl-fuzz
Before you do even a test run of afl-fuzz execute `sudo afl-system-config` (on Before you do even a test run of afl-fuzz, execute `sudo afl-system-config` (on
the host if you execute afl-fuzz in a docker container). This reconfigures the the host if you execute afl-fuzz in a Docker container). This reconfigures the
system for optimal speed - which afl-fuzz checks and bails otherwise. Set system for optimal speed - which afl-fuzz checks and bails otherwise. Set
`export AFL_SKIP_CPUFREQ=1` for afl-fuzz to skip this check if you cannot run `export AFL_SKIP_CPUFREQ=1` for afl-fuzz to skip this check if you cannot run
afl-system-config with root privileges on the host for whatever reason. afl-system-config with root privileges on the host for whatever reason.
Note there is also `sudo afl-persistent-config` which sets additional permanent Note:
boot options for a much better fuzzing performance.
Note that both scripts improve your fuzzing performance but also decrease your * There is also `sudo afl-persistent-config` which sets additional permanent
system protection against attacks! So set strong firewall rules and only expose boot options for a much better fuzzing performance.
SSH as a network service if you use these (which is highly recommended). * Both scripts improve your fuzzing performance but also decrease your system
protection against attacks! So set strong firewall rules and only expose SSH
as a network service if you use these (which is highly recommended).
If you have an input corpus from step 2, then specify this directory with the If you have an input corpus from [step 2](#2-preparing-the-fuzzing-campaign),
`-i` option. Otherwise, create a new directory and create a file with any then specify this directory with the `-i` option. Otherwise, create a new
content as test data in there. directory and create a file with any content as test data in there.
If you do not want anything special, the defaults are already usually best, If you do not want anything special, the defaults are already usually best,
hence all you need is to specify the seed input directory with the result of hence all you need is to specify the seed input directory with the result of
step [2a) Collect inputs](#a-collect-inputs): step [2a) Collecting inputs](#a-collecting-inputs):
`afl-fuzz -i input -o output -- bin/target -d @@` ```
afl-fuzz -i input -o output -- bin/target -d @@
```
Note that the directory specified with `-o` will be created if it does not Note that the directory specified with `-o` will be created if it does not
exist. exist.
@ -444,7 +468,9 @@ If you need to stop and re-start the fuzzing, use the same command line options
(or even change them by selecting a different power schedule or another mutation (or even change them by selecting a different power schedule or another mutation
mode!) and switch the input directory with a dash (`-`): mode!) and switch the input directory with a dash (`-`):
`afl-fuzz -i - -o output -- bin/target -d @@` ```
afl-fuzz -i - -o output -- bin/target -d @@
```
Adding a dictionary is helpful. See the directory Adding a dictionary is helpful. See the directory
[dictionaries/](../dictionaries/) if something is already included for your data [dictionaries/](../dictionaries/) if something is already included for your data
@ -461,7 +487,7 @@ specific locations for the input file (`-f`), performing deterministic fuzzing
We highly recommend that you set a memory limit for running the target with `-m` We highly recommend that you set a memory limit for running the target with `-m`
which defines the maximum memory in MB. This prevents a potential out-of-memory which defines the maximum memory in MB. This prevents a potential out-of-memory
problem for your system plus helps you detect missing `malloc()` failure problem for your system plus helps you detect missing `malloc()` failure
handling in the target. Play around with various -m values until you find one handling in the target. Play around with various `-m` values until you find one
that safely works for all your input seeds (if you have good ones and then that safely works for all your input seeds (if you have good ones and then
double or quadruple that. double or quadruple that.
@ -469,8 +495,8 @@ By default, afl-fuzz never stops fuzzing. To terminate AFL++, press Control-C or
send a signal SIGINT. You can limit the number of executions or approximate send a signal SIGINT. You can limit the number of executions or approximate
runtime in seconds with options also. runtime in seconds with options also.
When you start afl-fuzz you will see a user interface that shows what the status When you start afl-fuzz, you will see a user interface that shows what the
is: status is:
![resources/screenshot.png](resources/screenshot.png) ![resources/screenshot.png](resources/screenshot.png)
@ -596,7 +622,8 @@ done
``` ```
You can run this manually, per cron job - as you need it. There is a more You can run this manually, per cron job - as you need it. There is a more
complex and configurable script in `utils/distributed_fuzzing`. complex and configurable script in
[utils/distributed_fuzzing](../utils/distributed_fuzzing).
### e) The status of the fuzz campaign ### e) The status of the fuzz campaign
@ -612,7 +639,7 @@ If you have multiple servers, then use the command after a sync or you have to
execute this script per server. execute this script per server.
Another tool to inspect the current state and history of a specific instance is Another tool to inspect the current state and history of a specific instance is
afl-plot, which generates an index.html file and a graphs that show how the afl-plot, which generates an index.html file and graphs that show how the
fuzzing instance is performing. The syntax is `afl-plot instance_dir web_dir`, fuzzing instance is performing. The syntax is `afl-plot instance_dir web_dir`,
e.g., `afl-plot out/default /srv/www/htdocs/plot`. e.g., `afl-plot out/default /srv/www/htdocs/plot`.
@ -623,7 +650,7 @@ To stop an afl-fuzz run, press Control-C.
To restart an afl-fuzz run, just reuse the same command line but replace the `-i To restart an afl-fuzz run, just reuse the same command line but replace the `-i
directory` with `-i -` or set `AFL_AUTORESUME=1`. directory` with `-i -` or set `AFL_AUTORESUME=1`.
If you want to add new seeds to a fuzzing campaign you can run a temporary If you want to add new seeds to a fuzzing campaign, you can run a temporary
fuzzing instance, e.g., when your main fuzzer is using `-o out` and the new fuzzing instance, e.g., when your main fuzzer is using `-o out` and the new
seeds are in `newseeds/` directory: seeds are in `newseeds/` directory:
@ -686,21 +713,21 @@ or honggfuzz.
### i) Improve the speed! ### i) Improve the speed!
* Use [persistent mode](../instrumentation/README.persistent_mode.md) (x2-x20 * Use [persistent mode](../instrumentation/README.persistent_mode.md) (x2-x20
speed increase) speed increase).
* If you do not use shmem persistent mode, use `AFL_TMPDIR` to point the input * If you do not use shmem persistent mode, use `AFL_TMPDIR` to point the input
file on a tempfs location, see [env_variables.md](env_variables.md) file on a tempfs location, see [env_variables.md](env_variables.md).
* Linux: Improve kernel performance: modify `/etc/default/grub`, set * Linux: Improve kernel performance: modify `/etc/default/grub`, set
`GRUB_CMDLINE_LINUX_DEFAULT="ibpb=off ibrs=off kpti=off l1tf=off mds=off `GRUB_CMDLINE_LINUX_DEFAULT="ibpb=off ibrs=off kpti=off l1tf=off mds=off
mitigations=off no_stf_barrier noibpb noibrs nopcid nopti mitigations=off no_stf_barrier noibpb noibrs nopcid nopti
nospec_store_bypass_disable nospectre_v1 nospectre_v2 pcid=off pti=off nospec_store_bypass_disable nospectre_v1 nospectre_v2 pcid=off pti=off
spec_store_bypass_disable=off spectre_v2=off stf_barrier=off"`; then spec_store_bypass_disable=off spectre_v2=off stf_barrier=off"`; then
`update-grub` and `reboot` (warning: makes the system more insecure) - you can `update-grub` and `reboot` (warning: makes the system more insecure) - you can
also just run `sudo afl-persistent-config` also just run `sudo afl-persistent-config`.
* Linux: Running on an `ext2` filesystem with `noatime` mount option will be a * Linux: Running on an `ext2` filesystem with `noatime` mount option will be a
bit faster than on any other journaling filesystem bit faster than on any other journaling filesystem.
* Use your cores! [3c) Using multiple cores](#c-using-multiple-cores) * Use your cores! See [3c) Using multiple cores](#c-using-multiple-cores).
* Run `sudo afl-system-config` before starting the first afl-fuzz instance after * Run `sudo afl-system-config` before starting the first afl-fuzz instance after
a reboot a reboot.
### j) Going beyond crashes ### j) Going beyond crashes
@ -774,7 +801,7 @@ making it easier to diagnose faults.
Having said that, it's important to acknowledge that some fuzzing crashes can be Having said that, it's important to acknowledge that some fuzzing crashes can be
difficult to quickly evaluate for exploitability without a lot of debugging and difficult to quickly evaluate for exploitability without a lot of debugging and
code analysis work. To assist with this task, afl-fuzz supports a very unique code analysis work. To assist with this task, afl-fuzz supports a very unique
"crash exploration" mode enabled with the -C flag. "crash exploration" mode enabled with the `-C` flag.
In this mode, the fuzzer takes one or more crashing test cases as the input and In this mode, the fuzzer takes one or more crashing test cases as the input and
uses its feedback-driven fuzzing strategies to very quickly enumerate all code uses its feedback-driven fuzzing strategies to very quickly enumerate all code
@ -800,19 +827,19 @@ mode, it will happily accept instrumented and non-instrumented binaries. In the
non-crashing mode, the minimizer relies on standard AFL++ instrumentation to non-crashing mode, the minimizer relies on standard AFL++ instrumentation to
make the file simpler without altering the execution path. make the file simpler without altering the execution path.
The minimizer accepts the -m, -t, -f and @@ syntax in a manner compatible with The minimizer accepts the `-m`, `-t`, `-f`, and `@@` syntax in a manner
afl-fuzz. compatible with afl-fuzz.
Another tool in AFL++ is the afl-analyze tool. It takes an input file, attempts Another tool in AFL++ is the afl-analyze tool. It takes an input file, attempts
to sequentially flip bytes, and observes the behavior of the tested program. It to sequentially flip bytes and observes the behavior of the tested program. It
then color-codes the input based on which sections appear to be critical, and then color-codes the input based on which sections appear to be critical and
which are not; while not bulletproof, it can often offer quick insights into which are not; while not bulletproof, it can often offer quick insights into
complex file formats. complex file formats.
## 5. CI fuzzing ## 5. CI fuzzing
Some notes on CI fuzzing - this fuzzing is different to normal fuzzing campaigns Some notes on continuous integration (CI) fuzzing - this fuzzing is different to
as these are much shorter runnings. normal fuzzing campaigns as these are much shorter runnings.
1. Always: 1. Always:
* LTO has a much longer compile time which is diametrical to short fuzzing - * LTO has a much longer compile time which is diametrical to short fuzzing -
@ -820,10 +847,10 @@ as these are much shorter runnings.
* If you compile with CMPLOG, then you can save fuzzing time and reuse that * If you compile with CMPLOG, then you can save fuzzing time and reuse that
compiled target for both the `-c` option and the main fuzz target. This compiled target for both the `-c` option and the main fuzz target. This
will impact the speed by ~15% though. will impact the speed by ~15% though.
* `AFL_FAST_CAL` - Enable fast calibration, this halves the time the * `AFL_FAST_CAL` - enables fast calibration, this halves the time the
saturated corpus needs to be loaded. saturated corpus needs to be loaded.
* `AFL_CMPLOG_ONLY_NEW` - only perform cmplog on new finds, not the * `AFL_CMPLOG_ONLY_NEW` - only perform cmplog on new finds, not the initial
initial corpus as this very likely has been done for them already. corpus as this very likely has been done for them already.
* Keep the generated corpus, use afl-cmin and reuse it every time! * Keep the generated corpus, use afl-cmin and reuse it every time!
2. Additionally randomize the AFL++ compilation options, e.g.: 2. Additionally randomize the AFL++ compilation options, e.g.:

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 13 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 9.7 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 10 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -11,12 +11,11 @@ see
## Build ## Build
To use CmpLog, you have to build two versions of the instrumented target To use CmpLog, you have to build two versions of the instrumented target
program. program:
The first version is built using the regular AFL++ instrumentation. * The first version is built using the regular AFL++ instrumentation.
* The second one, the CmpLog binary, is built with setting `AFL_LLVM_CMPLOG`
The second one, the CmpLog binary, is built with setting AFL_LLVM_CMPLOG during during the compilation.
the compilation.
For example: For example:

View File

@ -39,13 +39,11 @@ AFL_LLVM_LAF_SPLIT_COMPARES_BITW=<bit_width>`, where bit_width may be 64, 32, or
16. For example, a bit_width of 16 would split larger comparisons down to 16 bit 16. For example, a bit_width of 16 would split larger comparisons down to 16 bit
comparisons. comparisons.
A new experimental feature is splitting floating point comparisons into a series A new unique feature is splitting floating point comparisons into a series
of sign, exponent and mantissa comparisons followed by splitting each of them of sign, exponent and mantissa comparisons followed by splitting each of them
into 8 bit comparisons when necessary. It is activated with the into 8 bit comparisons when necessary. It is activated with the
`AFL_LLVM_LAF_SPLIT_FLOATS` setting. Note that full IEEE 754 functionality is `AFL_LLVM_LAF_SPLIT_FLOATS` setting.
not preserved, that is values of nan and infinity will probably behave
differently.
Note that setting this automatically activates `AFL_LLVM_LAF_SPLIT_COMPARES`. Note that setting this automatically activates `AFL_LLVM_LAF_SPLIT_COMPARES`.
You can also set `AFL_LLVM_LAF_ALL` and have all of the above enabled. :-) You can also set `AFL_LLVM_LAF_ALL` and have all of the above enabled. :-)

View File

@ -1 +1 @@
002e473939 ce65a7349e

View File

@ -395,7 +395,7 @@ static void edit_params(u32 argc, char **argv, char **envp) {
snprintf(llvm_fullpath, sizeof(llvm_fullpath), "%s/clang", snprintf(llvm_fullpath, sizeof(llvm_fullpath), "%s/clang",
LLVM_BINDIR); LLVM_BINDIR);
else else
snprintf(llvm_fullpath, sizeof(llvm_fullpath), CLANGPP_BIN); snprintf(llvm_fullpath, sizeof(llvm_fullpath), CLANG_BIN);
alt_cc = llvm_fullpath; alt_cc = llvm_fullpath;
} }

View File

@ -296,9 +296,9 @@ void write_stats_file(afl_state_t *afl, u32 t_bytes, double bitmap_cvg,
((double)(afl->prev_run_time + get_cur_time() - afl->start_time) / ((double)(afl->prev_run_time + get_cur_time() - afl->start_time) /
1000), 1000),
afl->last_avg_execs_saved, afl->queued_items, afl->queued_favored, afl->last_avg_execs_saved, afl->queued_items, afl->queued_favored,
afl->queued_discovered, afl->queued_imported, afl->max_depth, afl->queued_discovered, afl->queued_imported, afl->queued_variable,
afl->current_entry, afl->pending_favored, afl->pending_not_fuzzed, afl->max_depth, afl->current_entry, afl->pending_favored,
afl->queued_variable, stability, bitmap_cvg, afl->saved_crashes, afl->pending_not_fuzzed, stability, bitmap_cvg, afl->saved_crashes,
afl->saved_hangs, afl->last_find_time / 1000, afl->last_crash_time / 1000, afl->saved_hangs, afl->last_find_time / 1000, afl->last_crash_time / 1000,
afl->last_hang_time / 1000, afl->fsrv.total_execs - afl->last_crash_execs, afl->last_hang_time / 1000, afl->fsrv.total_execs - afl->last_crash_execs,
afl->fsrv.exec_tmout, afl->slowest_exec_ms, afl->fsrv.exec_tmout, afl->slowest_exec_ms,

View File

@ -242,8 +242,11 @@ u8 *afl_shm_init(sharedmem_t *shm, size_t map_size,
#else #else
u8 *shm_str; u8 *shm_str;
// for qemu+unicorn we have to increase by 8 to account for potential
// compcov map overwrite
shm->shm_id = shm->shm_id =
shmget(IPC_PRIVATE, map_size, IPC_CREAT | IPC_EXCL | DEFAULT_PERMISSION); shmget(IPC_PRIVATE, map_size == MAP_SIZE ? map_size + 8 : map_size,
IPC_CREAT | IPC_EXCL | DEFAULT_PERMISSION);
if (shm->shm_id < 0) { if (shm->shm_id < 0) {
PFATAL("shmget() failed, try running afl-system-config"); PFATAL("shmget() failed, try running afl-system-config");