honggfuzz-rs Build Status Crates.io

Fuzz your Rust code with Honggfuzz !

Documentation

asciicast

About Honggfuzz

Honggfuzz is a security oriented fuzzer with powerful analysis options. Supports evolutionary, feedback-driven fuzzing based on code coverage (software- and hardware-based)

Description (from upstream project)

How to use this crate

Install honggfuzz commands to build with instrumentation and fuzz

```sh

installs hfuzz-build, hfuzz-clean and honggfuzz subcommands in cargo

cargo install honggfuzz ```

Add to your dependencies

toml [dependencies] honggfuzz = "0.4"

Create a target to fuzz

```rust

[macro_use] extern crate honggfuzz;

fn main() { // Here you can parse `std::env::args and // setup / initialize your project

// You have full control over the loop but
// you're supposed to call `fuzz` ad vitam aeternam
loop {
    // The fuzz macro gives an arbitrary object (see `arbitrary crate`)
    // to a closure-like block of code.
    // For performance reasons, it is recommended that you use the native type
    // `&[u8]` when possible.
    // Here, this slice will contain a "random" quantity of "random" data.
    fuzz!(|data: &[u8]| {
        if data.len() != 10 {return}
        if data[0] != 'q' as u8 {return}
        if data[1] != 'w' as u8 {return}
        if data[2] != 'e' as u8 {return}
        if data[3] != 'r' as u8 {return}
        if data[4] != 't' as u8 {return}
        if data[5] != 'y' as u8 {return}
        if data[6] != 'u' as u8 {return}
        if data[7] != 'i' as u8 {return}
        if data[8] != 'o' as u8 {return}
        if data[9] != 'p' as u8 {return}
        panic!("BOOM")
    });
}

}

```

Build with instrumentation

```sh

a wrapper on "cargo build" with fuzzing instrumentation enabled.

produces binaries in "fuzzing_target" directory

cargo hfuzz-build ```

Fuzz

```sh mkdir -p workspace/input

a wrapper on honggfuzz executable with settings adapted to work with Rust code

cargo honggfuzz -W workspace -f workspace/input -P -- fuzzingtarget/x8664-unknown-linux-gnu/debug/example ```

Clean

```sh

a wrapper on "cargo clean" which cleans the fuzzing_target directory

cargo hfuzz-clean ```

Relevant documentation about honggfuzz usage

About Rust fuzzing

There is other projects providing Rust fuzzing support at github.com/rust-fuzz.

You'll find support for AFL and LLVM's LibFuzzer and there is also a trophy case ;-) .

This crate was inspired by those projects!