File size: 9,080 Bytes
d086025 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | # AFL Runner
`AFL_Runner` is a modern CLI tool designed to streamline running efficient
multi-core [AFLPlusPlus](https://github.com/AFLplusplus/AFLplusplus) campaigns.
The default configuration is based on the section
[_Using multiple cores_](https://aflplus.plus/docs/fuzzing_in_depth/#c-using-multiple-cores)
of the official documentation.
The executable is named `aflr`.
## Getting Started
Currently, this tool should work on all \*NIX flavor operating-systems.
### Prerequisites
- [Rust toolchain v1.85.0](https://www.rust-lang.org/tools/install)
- [AFLPlusPlus](https://github.com/AFLplusplus/AFLplusplus)
- [pgrep](https://man7.org/linux/man-pages/man1/pgrep.1.html)
- [TMUX](https://github.com/tmux/tmux) or [screen](https://www.gnu.org/software/screen/) (optional, for TUI)
- [LLVM](https://llvm.org/) (optional, for coverage reporting)
### Installation
Compile from source:
```bash
git clone https://github.com/0xricksanchez/AFL_Runner.git
cd AFL_Runner
cargo build --release
./target/release/aflr --help
# Optional: Generate completion scripts
cargo run --features completion --bin generate_completions
```
Or install directly via [crates.io](https://crates.io/crates/afl_runner):
```bash
cargo install afl_runner
aflr --help
# Alternatively, with completion support included
cargo install --path . --features completion
```
## Features
`AFL_Runner` allows you to set the most necessary AFLPlusPlus flags and mimics
the AFLPlusPlus syntax for these options.
Supported AFLPlusPlus flags:
- Corpus directory
- Output directory
- Dictionary file/directory
- Custom `afl-fuzz` binary path for all instances
- Supply arguments to target binary (including `@@`)
- Amount of runner commands to generate
- Support for \*SAN, CMPLOG, CMPCOV binaries
Other features:
- Coverage collection/visualization
- `tmux` or `screen` option to automatically create an appropriate layout for all runners
- TUI
- Provide a configuration file via `--config` to make sharing/storing per-project configurations easier
- Automatically read a configuration named `aflr_cfg.toml` in the current working directory when no `--config` is supplied
- Modes: `default` (vanilla AFL++), `multiple-cores`
([Ref.](https://aflplus.plus/docs/fuzzing_in_depth/#c-using-multiple-cores)), and `ci-fuzzing`
([Ref.](https://aflplus.plus/docs/fuzzing_in_depth/#5-ci-fuzzing))
- _Deterministic_ command generation and AFL++ with seeding
> **Note**: Arguments supplied over the command-line take precedence over any configuration file options.
## Subcommands
| Subcommand | Description |
|------------|-------------|
| `gen` | Only generate commands for the fuzzing campaign, don't run them |
| `run` | Generate the fuzzing campaign and run it |
| `cov` | Collect and visualize fuzzing coverage |
| `tui` | Show stats TUI for a running campaign |
| `kill` | Kill a running session and all spawned processes inside |
| `add-seed` | Add new seeds to a running campaign |
## Usage / Flags
### `gen` — generate commands only
```
aflr gen [OPTIONS] [TARGET_ARGS]...
```
| Flag | Description |
|------|-------------|
| `-t, --target <PATH>` | Instrumented target binary to fuzz |
| `-s, --san-target <PATH>` | Instrumented with \*SAN binary to use |
| `-c, --cmpl-target <PATH>` | Instrumented with CMPLOG binary to use |
| `-l, --cmpc-target <PATH>` | Instrumented with Laf-intel/CMPCOV binary to use |
| `[TARGET_ARGS]...` | Target binary arguments, including `@@` if needed |
| `--nyx-mode` | Use AFL++'s Nyx mode |
| `-n, --runners <NUM_PROCS>` | Amount of processes to spin up |
| `-i, --input-dir <PATH>` | Seed corpus directory |
| `-o, --output-dir <PATH>` | Solution/Crash output directory |
| `-x, --dictionary <DICT_FILE>` | Token dictionary to use |
| `-b, --afl-binary <PATH>` | Custom path to `afl-fuzz` binary |
| `--config <PATH>` | Path to TOML config file |
| `-m, --mode <MODE>` | Select fuzzing mode (`default`, `multiple-cores`, `ci-fuzzing`) |
| `--seed <AFLR_SEED>` | Seed for AFL_Runner's PRNG for deterministic command generation |
| `--use-seed-afl` | Forward AFLR seed to AFL++ (requires `--seed`) |
### `run` — generate and run
```
aflr run [OPTIONS] [TARGET_ARGS]...
```
Accepts all `gen` flags (see above) plus:
| Flag | Description |
|------|-------------|
| `--dry-run` | Output commands without executing |
| `--session-runner <tmux\|screen>` | Session runner to use (default: `tmux`) |
| `--session-name <NAME>` | Custom runner session name |
| `--tui` | Enable TUI mode |
| `--detached` | Start detached from session (not compatible with TUI) |
| `--is-ramdisk` | Use RAMDisk for AFL++ |
### `cov` — coverage collection/visualization
```
aflr cov [OPTIONS] [TARGET_ARGS]...
```
| Flag | Description |
|------|-------------|
| `-t, --target <PATH>` | Instrumented target binary for coverage collection |
| `[TARGET_ARGS]...` | Target binary arguments, including `@@` if needed |
| `-i, --output-dir <PATH>` | Top-level AFL++ output directory |
| `--split-report` | Do *not* merge all coverage files into a single report |
| `--text-report` | Force text-based coverage report |
| `-a, --show-args <ARGS>...` | Miscellaneous `llvm-cov show` arguments |
| `-r, --report-args <ARGS>...` | Miscellaneous `llvm-cov report` arguments |
| `--config <PATH>` | Path to TOML config file |
### `tui` — show stats TUI
```
aflr tui <AFL_OUTPUT>
```
| Argument | Description |
|----------|-------------|
| `<AFL_OUTPUT>` | Path to an AFLPlusPlus campaign directory, e.g. `afl_output` |
> The TUI can be used as a **full** replacement for `afl-whatsup` via `aflr tui <afl_output_dir>`.
### `kill` — kill a running session
```
aflr kill <SESSION_NAME>
```
| Argument | Description |
|----------|-------------|
| `<SESSION_NAME>` | Session name to kill (tab-completion available for tmux sessions) |
### `add-seed` — add seeds to a running campaign
```
aflr add-seed [OPTIONS] [TARGET_ARGS]...
```
| Flag | Description |
|------|-------------|
| `-t, --target <PATH>` | Instrumented target binary to fuzz |
| `[TARGET_ARGS]...` | Target binary arguments, including `@@` if needed |
| `-o, --output-dir <PATH>` | Solution/Crash output directory of the running campaign |
| `--config <PATH>` | Path to TOML config file |
| `--seed <SEED(S)>` | Seed(s) to add to the corpus |
## Configuration File
A configuration file (TOML) can be passed via `--config`. When no `--config` is
supplied, `AFL_Runner` automatically reads a configuration named
`aflr_cfg.toml` in the current working directory.
The configuration is organized into the following sections: `[target]`,
`[coverage]`, `[afl_cfg]`, `[session]`, and `[misc]`.
See [`AFLR_CFG_TEMPL.toml`](AFLR_CFG_TEMPL.toml) for a fully annotated example.
Available modes (in `[afl_cfg]` `mode` or `-m/--mode`):
- `Default` — vanilla AFL++
- `MultipleCores` — recommended multi-core setup (default)
- `CIFuzzing` — CI-fuzzing setup
### Default paths
| Path | Default value |
|------|---------------|
| Input/corpus directory | `/tmp/afl_input` |
| Output directory | `/tmp/afl_output` |
## Shell Completion
The tool supports shell completion for tmux session names when using the
`kill` command. To enable completion:
1. Generate the completion scripts:
```bash
cargo run --bin generate_completions
```
2. Depending on your shell:
For ZSH:
```bash
# Option 1: Source directly
source completions/aflr_dynamic.zsh
# Option 2 (preferred): Install to completion directory
mkdir -p ~/.zsh/completions
cp completions/aflr_dynamic.zsh ~/.zsh/completions/_aflr
# Add to your .zshrc:
fpath=(~/.zsh/completions $fpath)
autoload -U compinit && compinit
```
For Bash:
```bash
# Add to your .bashrc:
source /path/to/completions/aflr_dynamic.bash
```
Once set up, use tab completion to see available tmux sessions:
```bash
aflr kill <TAB>
```
## Example: multi-core fuzzing of libxml2
The repository ships an example that demonstrates using `aflr` to start a
best-practice multi-core fuzzing campaign for the `libxml2` library. The build
is configured via `Makefile.toml`, while the campaign behavior is controlled
from an `aflr_config.toml`.
The default example pulls `libxml2` `v2.10.0`. Testing another version requires:
1. Updating the version number in the `Makefile.toml`
2. Updating `aflr_config.toml` so `aflr` uses the updated `xmllint` builds
### Prerequisites
- `clang`
- `AFL++`
- `make`
- `autoconf`
- Rust toolchain
- `cargo-make`
### Build and run
From the root directory of the project:
```bash
cargo make
```
This fetches all necessary files and builds the different `xmllint` binaries.
If the build succeeds, `aflr` spins up _16_ fuzzing processes (per
`aflr_config.toml`) following the recommended best-practice setup described
[here](https://aflplus.plus/docs/fuzzing_in_depth/#c-using-multiple-cores).
> **Note**: Run `cargo make dry_run` to only run the command generator (requires
> building) instead of running the actual fuzzing.
## License
This project is licensed under the Apache License 2.0. See the `LICENSE` file for details.
|