# 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 ` | Instrumented target binary to fuzz | | `-s, --san-target ` | Instrumented with \*SAN binary to use | | `-c, --cmpl-target ` | Instrumented with CMPLOG binary to use | | `-l, --cmpc-target ` | 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 ` | Amount of processes to spin up | | `-i, --input-dir ` | Seed corpus directory | | `-o, --output-dir ` | Solution/Crash output directory | | `-x, --dictionary ` | Token dictionary to use | | `-b, --afl-binary ` | Custom path to `afl-fuzz` binary | | `--config ` | Path to TOML config file | | `-m, --mode ` | Select fuzzing mode (`default`, `multiple-cores`, `ci-fuzzing`) | | `--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 ` | Session runner to use (default: `tmux`) | | `--session-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 ` | Instrumented target binary for coverage collection | | `[TARGET_ARGS]...` | Target binary arguments, including `@@` if needed | | `-i, --output-dir ` | 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 ...` | Miscellaneous `llvm-cov show` arguments | | `-r, --report-args ...` | Miscellaneous `llvm-cov report` arguments | | `--config ` | Path to TOML config file | ### `tui` — show stats TUI ``` aflr tui ``` | Argument | Description | |----------|-------------| | `` | 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 `. ### `kill` — kill a running session ``` aflr kill ``` | Argument | Description | |----------|-------------| | `` | 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 ` | Instrumented target binary to fuzz | | `[TARGET_ARGS]...` | Target binary arguments, including `@@` if needed | | `-o, --output-dir ` | Solution/Crash output directory of the running campaign | | `--config ` | Path to TOML config file | | `--seed ` | 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 ``` ## 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.