libfuzzer clone project
This commit is contained in:
parent
f125029107
commit
c617f3a397
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,4 +1,4 @@
|
||||
/target
|
||||
target
|
||||
Cargo.lock
|
||||
|
||||
.vscode
|
||||
.vscode
|
||||
|
@ -17,4 +17,4 @@ std = []
|
||||
xxhash-rust = { version = "0.8.0-beta.4", features = ["xxh3"] } # xxh3 hashing for rust
|
||||
hashbrown = "0.9" # A faster hashmap, nostd compatible
|
||||
libc = "0.2" # For (*nix) libc
|
||||
num = "*"
|
||||
num = "*"
|
||||
|
10
fuzzers/libfuzzer/libfuzzer/Cargo.toml
Normal file
10
fuzzers/libfuzzer/libfuzzer/Cargo.toml
Normal file
@ -0,0 +1,10 @@
|
||||
[package]
|
||||
name = "libfuzzer"
|
||||
version = "0.1.0"
|
||||
authors = ["Andrea Fioraldi <andreafioraldi@gmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
afl = { path = "../../../" }
|
43
fuzzers/libfuzzer/libfuzzer/src/main.rs
Normal file
43
fuzzers/libfuzzer/libfuzzer/src/main.rs
Normal file
@ -0,0 +1,43 @@
|
||||
use std::boxed::Box;
|
||||
|
||||
use afl::corpus::{Corpus, InMemoryCorpus, Testcase};
|
||||
use afl::engines::{DefaultEngine, DefaultState, Engine};
|
||||
use afl::executors::inmemory::InMemoryExecutor;
|
||||
use afl::executors::{Executor, ExitKind};
|
||||
use afl::inputs::bytes::BytesInput;
|
||||
use afl::mutators::scheduled::{
|
||||
mutation_bitflip, ComposedByMutations, DefaultScheduledMutator,
|
||||
};
|
||||
use afl::stages::mutational::DefaultMutationalStage;
|
||||
use afl::utils::DefaultRand;
|
||||
|
||||
fn harness<I>(_executor: &dyn Executor<I>, _buf: &[u8]) -> ExitKind {
|
||||
ExitKind::Ok
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let rand = DefaultRand::new(0).into();
|
||||
|
||||
let mut corpus = InMemoryCorpus::<BytesInput, _>::new(&rand);
|
||||
let testcase = Testcase::new(vec![0; 4]).into();
|
||||
corpus.add(testcase);
|
||||
|
||||
let executor = InMemoryExecutor::<BytesInput>::new(harness);
|
||||
let mut state = DefaultState::new(corpus, executor);
|
||||
|
||||
let mut engine = DefaultEngine::new();
|
||||
let mut mutator = DefaultScheduledMutator::new(&rand);
|
||||
mutator.add_mutation(mutation_bitflip);
|
||||
let stage = DefaultMutationalStage::new(&rand, mutator);
|
||||
engine.add_stage(Box::new(stage));
|
||||
|
||||
//
|
||||
|
||||
for i in 0..1000 {
|
||||
engine
|
||||
.fuzz_one(&mut state)
|
||||
.expect(&format!("Error in iter {}", i));
|
||||
}
|
||||
println!("OK");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user