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

Libfuzzer #1

Merged
merged 3 commits into from
Mar 11, 2025
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
155 changes: 143 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ members = [
"autarkie",
"autarkie_derive",
"autarkie_test",
"libfuzzer/libafl_libfuzzer",
"libafl_libfuzzer",
"libafl_libfuzzer_runtime",
]

[workspace.dependencies]
libafl = { git = "https://github.com/AFLplusplus/LibAFL", rev = "aa0391ef8d47c229d2306d43f898e4ea28ca4186", features = ["errors_backtrace"]}
libafl_targets = { git = "https://github.com/AFLplusplus/LibAFL", rev = "aa0391ef8d47c229d2306d43f898e4ea28ca4186" }
libafl_bolts = { git = "https://github.com/AFLplusplus/LibAFL", rev = "aa0391ef8d47c229d2306d43f898e4ea28ca4186" }
libafl_bolts = { git = "https://github.com/AFLplusplus/LibAFL", rev = "aa0391ef8d47c229d2306d43f898e4ea28ca4186", features = [] }

2 changes: 1 addition & 1 deletion autarkie/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ borsh = { version = "1.5.3", features = ["derive"], optional = true }

libafl = {workspace = true}
libafl_bolts = {workspace = true}
libafl_targets = {workspace = true}
libafl_targets = { git = "https://github.com/AFLplusplus/LibAFL", rev = "aa0391ef8d47c229d2306d43f898e4ea28ca4186" }
blake3 = "1.5.5"
colored = "3.0.0"
petgraph = "0.7.1"
Expand Down
7 changes: 5 additions & 2 deletions autarkie/src/fuzzer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,12 @@ where
&[fuzzer_dir.join("queue").clone()],
)?;
for _ in 0..opt.initial_generated_inputs {
let generated: I = crate::fuzzer::generate::generate(&mut visitor.borrow_mut());
let mut generated = crate::fuzzer::generate::generate(&mut visitor.borrow_mut());
while generated.is_none() {
generated = crate::fuzzer::generate::generate(&mut visitor.borrow_mut());
}
fuzzer
.evaluate_input(&mut state, &mut executor, &mut mgr, generated)
.evaluate_input(&mut state, &mut executor, &mut mgr, generated.expect("dVoSuGRU____"))
.unwrap();
}
println!("We imported {} inputs from disk.", state.corpus().count());
Expand Down
7 changes: 4 additions & 3 deletions autarkie/src/fuzzer/stages/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ where
state: &mut S,
manager: &mut EM,
) -> Result<(), libafl_bolts::Error> {
let generated = generate(&mut self.visitor.borrow_mut());
fuzzer.evaluate_input(state, executor, manager, generated)?;
if let Some(generated) = generate(&mut self.visitor.borrow_mut()) {
fuzzer.evaluate_input(state, executor, manager, generated)?;
}
Ok(())
}

Expand All @@ -54,7 +55,7 @@ where
}
}

pub fn generate<I>(visitor: &mut Visitor) -> I
pub fn generate<I>(visitor: &mut Visitor) -> Option<I>
where
I: Node,
{
Expand Down
19 changes: 13 additions & 6 deletions autarkie/src/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,19 @@ macro_rules! impl_node_serde_array {
visitor: &mut Visitor,
depth: &mut usize,
cur_depth: &mut usize,
) -> Self {
) -> Option<Self> {
// TODO: optimize?
(0..$n)
Some((0..$n)
.map(|_| T::__autarkie_generate(visitor, depth, cur_depth))
.filter_map(|i| i)
.collect::<Vec<T>>()
.try_into()
.expect("invariant;")
.try_into().ok()?)
}

fn __autarkie_serialized(&self, visitor: &Visitor) -> Option<Vec<(Vec<u8>, crate::Id)>> {
fn __autarkie_serialized(
&self,
visitor: &Visitor,
) -> Option<Vec<(Vec<u8>, crate::Id)>> {
let mut vector = self
.iter()
.map(|i| (serialize(i), T::__autarkie_id()))
Expand Down Expand Up @@ -64,7 +67,11 @@ macro_rules! impl_node_serde_array {
*self = deserialize(other);
}
MutationType::GenerateReplace(ref mut bias) => {
*self = Self::__autarkie_generate(visitor, bias, &mut 0)
if let Some(generated) =
Self::__autarkie_generate(visitor, bias, &mut 0)
{
*self = generated;
}
}
_ => unreachable!("tAL6LPUb____"),
}
Expand Down
Loading