Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AFL++ fuzzing support #351

Merged
merged 1 commit into from
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions fuzz-afl/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[package]
name = "goblin-fuzz-afl"
version = "0.0.1"
authors = ["Andrey Fedotov <[email protected]>"]
edition = "2018"
publish = false

[dependencies.goblin]
path = ".."

[dependencies]
afl = "*"

# Prevent this from interfering with workspaces
[workspace]
members = ["."]

[profile.release]
debug = true

[[bin]]
name = "afl_parse"
path = "fuzz_targets/afl_parse.rs"

[[bin]]
name = "afl_parse_elf"
path = "fuzz_targets/afl_parse_elf.rs"
8 changes: 8 additions & 0 deletions fuzz-afl/fuzz_targets/afl_parse.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#[macro_use]
extern crate afl;

fn main() {
fuzz!(|data: &[u8]| {
let _ = goblin::Object::parse(data);
});
}
26 changes: 26 additions & 0 deletions fuzz-afl/fuzz_targets/afl_parse_elf.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#[macro_use]
extern crate afl;

fn main() {
fuzz!(|data: &[u8]| {
if let Ok(elf) = goblin::elf::Elf::parse(data) {
for section_header in &elf.section_headers {
let _ = elf.shdr_strtab.get_at(section_header.sh_name);
}

for _relocation in &elf.dynrels {}

if let Some(mut it) = elf.iter_note_headers(data) {
while let Some(Ok(_a)) = it.next() {}
}

if let Some(mut it) = elf.iter_note_sections(data, None) {
while let Some(Ok(_a)) = it.next() {}
}

if let Some(mut it) = elf.iter_note_sections(data, Some("x")) {
while let Some(Ok(_a)) = it.next() {}
}
}
});
}
2 changes: 1 addition & 1 deletion fuzz/fuzz_targets/parse_elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use libfuzzer_sys::fuzz_target;
fuzz_target!(|data: &[u8]| {
if let Ok(elf) = goblin::elf::Elf::parse(data) {
for section_header in &elf.section_headers {
let _ = elf.shdr_strtab.get(section_header.sh_name);
let _ = elf.shdr_strtab.get_at(section_header.sh_name);
}

for _relocation in &elf.dynrels {}
Expand Down