align code with 'main' branch

This commit is contained in:
Omree 2021-05-26 18:12:59 +03:00
parent b59752eba5
commit 5bd08a6eee
22 changed files with 64 additions and 114 deletions

View File

@ -1,6 +1,6 @@
[package] [package]
name = "baby_fuzzer" name = "baby_fuzzer"
version = "0.3.1" version = "0.3.2"
authors = ["Andrea Fioraldi <andreafioraldi@gmail.com>", "Dominik Maier <domenukk@gmail.com>"] authors = ["Andrea Fioraldi <andreafioraldi@gmail.com>", "Dominik Maier <domenukk@gmail.com>"]
edition = "2018" edition = "2018"

View File

@ -1,6 +1,6 @@
[package] [package]
name = "frida_libpng" name = "frida_libpng"
version = "0.3.1" version = "0.3.2"
authors = ["Andrea Fioraldi <andreafioraldi@gmail.com>", "Dominik Maier <domenukk@gmail.com>"] authors = ["Andrea Fioraldi <andreafioraldi@gmail.com>", "Dominik Maier <domenukk@gmail.com>"]
edition = "2018" edition = "2018"
build = "build.rs" build = "build.rs"
@ -21,11 +21,11 @@ num_cpus = "1.0"
which = "4.1" which = "4.1"
[target.'cfg(unix)'.dependencies] [target.'cfg(unix)'.dependencies]
libafl = { path = "../../libafl/", features = [ "std", "llmp_bind_public" ] } #, "llmp_small_maps", "llmp_debug"]} libafl = { path = "../../libafl/", features = [ "std", "llmp_compression", "llmp_bind_public" ] } #, "llmp_small_maps", "llmp_debug"]}
libafl_frida = { path = "../../libafl_frida" }
capstone = "0.8.0" capstone = "0.8.0"
frida-gum = { version = "0.5.1", features = [ "auto-download", "backtrace", "event-sink", "invocation-listener"] } frida-gum = { version = "0.5.1", features = [ "auto-download", "backtrace", "event-sink", "invocation-listener"] }
libafl_targets = { path = "../../libafl_targets", version = "0.1.0" , features = ["value_profile"] } libafl_frida = { path = "../../libafl_frida", version = "0.3.2" }
libafl_targets = { path = "../../libafl_targets", version = "0.3.2" , features = ["sancov_cmplog"] }
lazy_static = "1.4.0" lazy_static = "1.4.0"
libc = "0.2" libc = "0.2"
libloading = "0.7.0" libloading = "0.7.0"

View File

@ -1,6 +1,6 @@
[package] [package]
name = "libfuzzer_libmozjpeg" name = "libfuzzer_libmozjpeg"
version = "0.3.1" version = "0.3.2"
authors = ["Andrea Fioraldi <andreafioraldi@gmail.com>", "Dominik Maier <domenukk@gmail.com>"] authors = ["Andrea Fioraldi <andreafioraldi@gmail.com>", "Dominik Maier <domenukk@gmail.com>"]
edition = "2018" edition = "2018"

View File

@ -15,6 +15,7 @@ use libafl::{
feedback_or, feedback_or,
feedbacks::{CrashFeedback, MapFeedbackState, MaxMapFeedback}, feedbacks::{CrashFeedback, MapFeedbackState, MaxMapFeedback},
fuzzer::{Fuzzer, StdFuzzer}, fuzzer::{Fuzzer, StdFuzzer},
inputs::{BytesInput, HasTargetBytes},
mutators::scheduled::{havoc_mutations, tokens_mutations, StdScheduledMutator}, mutators::scheduled::{havoc_mutations, tokens_mutations, StdScheduledMutator},
mutators::token_mutations::Tokens, mutators::token_mutations::Tokens,
observers::StdMapObserver, observers::StdMapObserver,

View File

@ -1,6 +1,6 @@
[package] [package]
name = "libfuzzer_libpng" name = "libfuzzer_libpng"
version = "0.3.1" version = "0.3.2"
authors = ["Andrea Fioraldi <andreafioraldi@gmail.com>", "Dominik Maier <domenukk@gmail.com>"] authors = ["Andrea Fioraldi <andreafioraldi@gmail.com>", "Dominik Maier <domenukk@gmail.com>"]
edition = "2018" edition = "2018"

View File

@ -16,6 +16,7 @@ use libafl::{
feedback_or, feedback_or,
feedbacks::{CrashFeedback, MapFeedbackState, MaxMapFeedback, TimeFeedback, TimeoutFeedback}, feedbacks::{CrashFeedback, MapFeedbackState, MaxMapFeedback, TimeFeedback, TimeoutFeedback},
fuzzer::{Fuzzer, StdFuzzer}, fuzzer::{Fuzzer, StdFuzzer},
inputs::{BytesInput, HasTargetBytes},
mutators::scheduled::{havoc_mutations, tokens_mutations, StdScheduledMutator}, mutators::scheduled::{havoc_mutations, tokens_mutations, StdScheduledMutator},
mutators::token_mutations::Tokens, mutators::token_mutations::Tokens,
observers::{HitcountsMapObserver, StdMapObserver, TimeObserver}, observers::{HitcountsMapObserver, StdMapObserver, TimeObserver},

View File

@ -1,6 +1,6 @@
[package] [package]
name = "libfuzzer_libpng_launcher" name = "libfuzzer_libpng_launcher"
version = "0.3.1" version = "0.3.2"
authors = ["Andrea Fioraldi <andreafioraldi@gmail.com>", "Dominik Maier <domenukk@gmail.com>"] authors = ["Andrea Fioraldi <andreafioraldi@gmail.com>", "Dominik Maier <domenukk@gmail.com>"]
edition = "2018" edition = "2018"

View File

@ -24,6 +24,7 @@ use libafl::{
feedback_or, feedback_or,
feedbacks::{CrashFeedback, MapFeedbackState, MaxMapFeedback, TimeFeedback, TimeoutFeedback}, feedbacks::{CrashFeedback, MapFeedbackState, MaxMapFeedback, TimeFeedback, TimeoutFeedback},
fuzzer::{Fuzzer, StdFuzzer}, fuzzer::{Fuzzer, StdFuzzer},
inputs::{BytesInput, HasTargetBytes},
mutators::scheduled::{havoc_mutations, tokens_mutations, StdScheduledMutator}, mutators::scheduled::{havoc_mutations, tokens_mutations, StdScheduledMutator},
mutators::token_mutations::Tokens, mutators::token_mutations::Tokens,
observers::{HitcountsMapObserver, StdMapObserver, TimeObserver}, observers::{HitcountsMapObserver, StdMapObserver, TimeObserver},

View File

@ -1,6 +1,6 @@
[package] [package]
name = "libfuzzer_reachability" name = "libfuzzer_reachability"
version = "0.3.1" version = "0.3.2"
authors = ["Andrea Fioraldi <andreafioraldi@gmail.com>", "Dominik Maier <domenukk@gmail.com>"] authors = ["Andrea Fioraldi <andreafioraldi@gmail.com>", "Dominik Maier <domenukk@gmail.com>"]
edition = "2018" edition = "2018"

View File

@ -1,6 +1,6 @@
[package] [package]
name = "libfuzzer_stb_image" name = "libfuzzer_stb_image"
version = "0.3.1" version = "0.3.2"
authors = ["Andrea Fioraldi <andreafioraldi@gmail.com>", "Dominik Maier <domenukk@gmail.com>"] authors = ["Andrea Fioraldi <andreafioraldi@gmail.com>", "Dominik Maier <domenukk@gmail.com>"]
edition = "2018" edition = "2018"
build = "build.rs" build = "build.rs"

View File

@ -20,7 +20,7 @@ use libafl::{
observers::{StdMapObserver, TimeObserver}, observers::{StdMapObserver, TimeObserver},
stages::{StdMutationalStage, TracingStage}, stages::{StdMutationalStage, TracingStage},
state::{HasCorpus, StdState}, state::{HasCorpus, StdState},
stats::SimpleStats, stats::MultiStats,
Error, Error,
}; };

View File

@ -1,6 +1,6 @@
[package] [package]
name = "libafl" name = "libafl"
version = "0.3.1" version = "0.3.2"
authors = ["Andrea Fioraldi <andreafioraldi@gmail.com>", "Dominik Maier <domenukk@gmail.com>"] authors = ["Andrea Fioraldi <andreafioraldi@gmail.com>", "Dominik Maier <domenukk@gmail.com>"]
description = "Slot your own fuzzers together and extend their features using Rust" description = "Slot your own fuzzers together and extend their features using Rust"
documentation = "https://docs.rs/libafl" documentation = "https://docs.rs/libafl"
@ -52,7 +52,7 @@ path = "./examples/llmp_test/main.rs"
required-features = ["std"] required-features = ["std"]
[dependencies] [dependencies]
libafl_derive = { optional = true, path = "../libafl_derive", version = "0.3.1" } libafl_derive = { optional = true, path = "../libafl_derive", version = "0.3.2" }
tuple_list = "0.1.2" tuple_list = "0.1.2"
hashbrown = { version = "0.9", features = ["serde", "ahash-compile-time-rng"] } # A faster hashmap, nostd compatible hashbrown = { version = "0.9", features = ["serde", "ahash-compile-time-rng"] } # A faster hashmap, nostd compatible
num = "0.4.0" num = "0.4.0"

View File

@ -170,7 +170,7 @@ where
let client = stats.client_stats_mut_for(sender_id); let client = stats.client_stats_mut_for(sender_id);
client.update_corpus_size(*corpus_size as u64); client.update_corpus_size(*corpus_size as u64);
client.update_executions(*executions as u64, *time); client.update_executions(*executions as u64, *time);
stats.display(event.name().to_string() + " #" + &sender_id.to_string()); stats.display(event.name().to_string(), sender_id);
Ok(BrokerEventResult::Forward) Ok(BrokerEventResult::Forward)
} }
Event::UpdateStats { Event::UpdateStats {
@ -181,7 +181,17 @@ where
// TODO: The stats buffer should be added on client add. // TODO: The stats buffer should be added on client add.
let client = stats.client_stats_mut_for(sender_id); let client = stats.client_stats_mut_for(sender_id);
client.update_executions(*executions as u64, *time); client.update_executions(*executions as u64, *time);
stats.display(event.name().to_string() + " #" + &sender_id.to_string()); stats.display(event.name().to_string(), sender_id);
Ok(BrokerEventResult::Handled)
}
Event::UpdateUserStats {
name,
value,
phantom: _,
} => {
let client = stats.client_stats_mut_for(sender_id);
client.update_user_stats(name.clone(), value.clone());
stats.display(event.name().to_string(), sender_id);
Ok(BrokerEventResult::Handled) Ok(BrokerEventResult::Handled)
} }
#[cfg(feature = "introspection")] #[cfg(feature = "introspection")]

View File

@ -1,42 +1,22 @@
//! A `CombinedExecutor` wraps a primary executor and a secondary one //! A `CombinedExecutor` wraps a primary executor and a secondary one
use core::marker::PhantomData;
use crate::{ use crate::{
executors::{ executors::{Executor, ExitKind, HasExecHooksTuple, HasObservers, HasObserversHooks},
Executor, ExitKind, HasExecHooks, HasExecHooksTuple, HasObservers, HasObserversHooks,
},
inputs::Input, inputs::Input,
observers::ObserversTuple, observers::ObserversTuple,
Error, Error,
}; };
/// A [`CombinedExecutor`] wraps a primary executor, forwarding its methods, and a secondary one /// A [`CombinedExecutor`] wraps a primary executor, forwarding its methods, and a secondary one
pub struct CombinedExecutor<A, B> {
pub struct CombinedExecutor<A, B, I>
where
A: Executor<I>,
B: Executor<I>,
I: Input,
{
primary: A, primary: A,
secondary: B, secondary: B,
phantom: PhantomData<I>,
} }
impl<A, B, I> CombinedExecutor<A, B, I> impl<A, B> CombinedExecutor<A, B> {
where
A: Executor<I>,
B: Executor<I>,
I: Input,
{
/// Create a new `CombinedExecutor`, wrapping the given `executor`s. /// Create a new `CombinedExecutor`, wrapping the given `executor`s.
pub fn new(primary: A, secondary: B) -> Self { pub fn new<EM, I, S, Z>(primary: A, secondary: B) -> Self {
Self { Self { primary, secondary }
primary,
secondary,
phantom: PhantomData,
}
} }
/// Retrieve the primary `Executor` that is wrapped by this `CombinedExecutor`. /// Retrieve the primary `Executor` that is wrapped by this `CombinedExecutor`.
@ -50,22 +30,26 @@ where
} }
} }
impl<A, B, I> Executor<I> for CombinedExecutor<A, B, I> impl<A, B, EM, I, S, Z> Executor<EM, I, S, Z> for CombinedExecutor<A, B>
where where
A: Executor<I>, A: Executor<EM, I, S, Z>,
B: Executor<I>, B: Executor<EM, I, S, Z>,
I: Input, I: Input,
{ {
fn run_target(&mut self, input: &I) -> Result<ExitKind, Error> { fn run_target(
self.primary.run_target(input) &mut self,
fuzzer: &mut Z,
state: &mut S,
mgr: &mut EM,
input: &I,
) -> Result<ExitKind, Error> {
self.primary.run_target(fuzzer, state, mgr, input)
} }
} }
impl<A, B, I, OT> HasObservers<OT> for CombinedExecutor<A, B, I> impl<A, B, OT> HasObservers<OT> for CombinedExecutor<A, B>
where where
A: Executor<I> + HasObservers<OT>, A: HasObservers<OT>,
B: Executor<I>,
I: Input,
OT: ObserversTuple, OT: ObserversTuple,
{ {
#[inline] #[inline]
@ -79,40 +63,10 @@ where
} }
} }
impl<A, B, EM, I, OT, S, Z> HasObserversHooks<EM, I, OT, S, Z> for CombinedExecutor<A, B, I> impl<A, B, EM, I, OT, S, Z> HasObserversHooks<EM, I, OT, S, Z> for CombinedExecutor<A, B>
where where
A: Executor<I> + HasObservers<OT>, A: HasObservers<OT>,
B: Executor<I>,
I: Input, I: Input,
OT: ObserversTuple + HasExecHooksTuple<EM, I, S, Z>, OT: ObserversTuple + HasExecHooksTuple<EM, I, S, Z>,
{ {
} }
impl<A, B, EM, I, S, Z> HasExecHooks<EM, I, S, Z> for CombinedExecutor<A, B, I>
where
A: Executor<I> + HasExecHooks<EM, I, S, Z>,
B: Executor<I>,
I: Input,
{
#[inline]
fn pre_exec(
&mut self,
fuzzer: &mut Z,
state: &mut S,
mgr: &mut EM,
input: &I,
) -> Result<(), Error> {
self.primary.pre_exec(fuzzer, state, mgr, input)
}
#[inline]
fn post_exec(
&mut self,
fuzzer: &mut Z,
state: &mut S,
mgr: &mut EM,
input: &I,
) -> Result<(), Error> {
self.primary.post_exec(fuzzer, state, mgr, input)
}
}

View File

@ -4,8 +4,6 @@ pub mod inprocess;
pub use inprocess::InProcessExecutor; pub use inprocess::InProcessExecutor;
pub mod timeout; pub mod timeout;
pub use timeout::TimeoutExecutor; pub use timeout::TimeoutExecutor;
pub mod combined;
pub use combined::CombinedExecutor;
#[cfg(all(feature = "std", unix))] #[cfg(all(feature = "std", unix))]
pub mod forkserver; pub mod forkserver;

View File

@ -2,7 +2,7 @@ use core::{marker::PhantomData, mem::drop};
use crate::{ use crate::{
corpus::Corpus, corpus::Corpus,
executors::{Executor, HasExecHooks, HasExecHooksTuple, HasObservers, HasObserversHooks}, executors::{Executor, HasExecHooksTuple, HasObservers, HasObserversHooks},
inputs::Input, inputs::Input,
mark_feature_time, mark_feature_time,
observers::ObserversTuple, observers::ObserversTuple,
@ -21,10 +21,7 @@ pub struct TracingStage<C, EM, I, OT, S, TE, Z>
where where
I: Input, I: Input,
C: Corpus<I>, C: Corpus<I>,
TE: Executor<I> TE: Executor<EM, I, S, Z> + HasObservers<OT> + HasObserversHooks<EM, I, OT, S, Z>,
+ HasObservers<OT>
+ HasExecHooks<EM, I, S, Z>
+ HasObserversHooks<EM, I, OT, S, Z>,
OT: ObserversTuple + HasExecHooksTuple<EM, I, S, Z>, OT: ObserversTuple + HasExecHooksTuple<EM, I, S, Z>,
S: HasClientPerfStats + HasExecutions + HasCorpus<C, I>, S: HasClientPerfStats + HasExecutions + HasCorpus<C, I>,
{ {
@ -37,10 +34,7 @@ impl<E, C, EM, I, OT, S, TE, Z> Stage<E, EM, S, Z> for TracingStage<C, EM, I, OT
where where
I: Input, I: Input,
C: Corpus<I>, C: Corpus<I>,
TE: Executor<I> TE: Executor<EM, I, S, Z> + HasObservers<OT> + HasObserversHooks<EM, I, OT, S, Z>,
+ HasObservers<OT>
+ HasExecHooks<EM, I, S, Z>
+ HasObserversHooks<EM, I, OT, S, Z>,
OT: ObserversTuple + HasExecHooksTuple<EM, I, S, Z>, OT: ObserversTuple + HasExecHooksTuple<EM, I, S, Z>,
S: HasClientPerfStats + HasExecutions + HasCorpus<C, I>, S: HasClientPerfStats + HasExecutions + HasCorpus<C, I>,
{ {
@ -68,19 +62,12 @@ where
mark_feature_time!(state, PerfFeature::PreExecObservers); mark_feature_time!(state, PerfFeature::PreExecObservers);
start_timer!(state); start_timer!(state);
self.tracer_executor drop(
.pre_exec(fuzzer, state, manager, &input)?; self.tracer_executor
mark_feature_time!(state, PerfFeature::PreExec); .run_target(fuzzer, state, manager, &input)?,
);
start_timer!(state);
let _ = self.tracer_executor.run_target(&input)?;
mark_feature_time!(state, PerfFeature::TargetExecution); mark_feature_time!(state, PerfFeature::TargetExecution);
start_timer!(state);
self.tracer_executor
.post_exec(fuzzer, state, manager, &input)?;
mark_feature_time!(state, PerfFeature::PostExec);
*state.executions_mut() += 1; *state.executions_mut() += 1;
start_timer!(state); start_timer!(state);
@ -96,10 +83,7 @@ impl<C, EM, I, OT, S, TE, Z> TracingStage<C, EM, I, OT, S, TE, Z>
where where
I: Input, I: Input,
C: Corpus<I>, C: Corpus<I>,
TE: Executor<I> TE: Executor<EM, I, S, Z> + HasObservers<OT> + HasObserversHooks<EM, I, OT, S, Z>,
+ HasObservers<OT>
+ HasExecHooks<EM, I, S, Z>
+ HasObserversHooks<EM, I, OT, S, Z>,
OT: ObserversTuple + HasExecHooksTuple<EM, I, S, Z>, OT: ObserversTuple + HasExecHooksTuple<EM, I, S, Z>,
S: HasClientPerfStats + HasExecutions + HasCorpus<C, I>, S: HasClientPerfStats + HasExecutions + HasCorpus<C, I>,
{ {

View File

@ -1,6 +1,6 @@
[package] [package]
name = "libafl_cc" name = "libafl_cc"
version = "0.3.1" version = "0.3.2"
authors = ["Andrea Fioraldi <andreafioraldi@gmail.com>"] authors = ["Andrea Fioraldi <andreafioraldi@gmail.com>"]
description = "Commodity library to wrap compilers and link LibAFL" description = "Commodity library to wrap compilers and link LibAFL"
documentation = "https://docs.rs/libafl_cc" documentation = "https://docs.rs/libafl_cc"

View File

@ -1,6 +1,6 @@
[package] [package]
name = "libafl_derive" name = "libafl_derive"
version = "0.3.1" version = "0.3.2"
authors = ["Andrea Fioraldi <andreafioraldi@gmail.com>"] authors = ["Andrea Fioraldi <andreafioraldi@gmail.com>"]
description = "Derive proc-macro crate for LibAFL" description = "Derive proc-macro crate for LibAFL"
documentation = "https://docs.rs/libafl_derive" documentation = "https://docs.rs/libafl_derive"

View File

@ -1,6 +1,6 @@
[package] [package]
name = "libafl_frida" name = "libafl_frida"
version = "0.3.1" version = "0.3.2"
authors = ["s1341 <github@shmarya.net>"] authors = ["s1341 <github@shmarya.net>"]
description = "Frida backend library for LibAFL" description = "Frida backend library for LibAFL"
documentation = "https://docs.rs/libafl_frida" documentation = "https://docs.rs/libafl_frida"
@ -15,7 +15,7 @@ cc = { version = "1.0", features = ["parallel"] }
[dependencies] [dependencies]
libafl = { path = "../libafl", version = "0.3.1", features = ["std", "libafl_derive"] } libafl = { path = "../libafl", version = "0.3.1", features = ["std", "libafl_derive"] }
libafl_targets = { path = "../libafl_targets", version = "0.3.1", features = ["cmplog"] } libafl_targets = { path = "../libafl_targets", version = "0.3.2", features = ["sancov_cmplog"] }
nix = "0.20.0" nix = "0.20.0"
libc = "0.2.92" libc = "0.2.92"
hashbrown = "0.11" hashbrown = "0.11"

View File

@ -83,7 +83,7 @@ pub struct FridaInstrumentationHelper<'a> {
transformer: Option<Transformer<'a>>, transformer: Option<Transformer<'a>>,
#[cfg(target_arch = "aarch64")] #[cfg(target_arch = "aarch64")]
capstone: Capstone, capstone: Capstone,
asan_runtime: Rc<RefCell<AsanRuntime>>, asan_runtime: AsanRuntime,
cmplog_runtime: CmpLogRuntime, cmplog_runtime: CmpLogRuntime,
ranges: RangeMap<usize, (u16, &'a str)>, ranges: RangeMap<usize, (u16, &'a str)>,
options: &'a FridaOptions, options: &'a FridaOptions,

View File

@ -1,6 +1,6 @@
[package] [package]
name = "libafl_targets" name = "libafl_targets"
version = "0.3.1" version = "0.3.2"
authors = ["Andrea Fioraldi <andreafioraldi@gmail.com>"] authors = ["Andrea Fioraldi <andreafioraldi@gmail.com>"]
description = "Common code for target instrumentation that can be used combined with LibAFL" description = "Common code for target instrumentation that can be used combined with LibAFL"
documentation = "https://docs.rs/libafl_targets" documentation = "https://docs.rs/libafl_targets"
@ -25,6 +25,6 @@ cc = { version = "1.0", features = ["parallel"] }
[dependencies] [dependencies]
rangemap = "0.1.10" rangemap = "0.1.10"
libafl = { path = "../libafl", version = "0.3", features = [] } libafl = { path = "../libafl", version = "0.3.2", features = [] }
serde = { version = "1.0", default-features = false, features = ["alloc"] } # serialization lib serde = { version = "1.0", default-features = false, features = ["alloc"] } # serialization lib
serde-big-array = "0.3.2" serde-big-array = "0.3.2"

View File

@ -11,6 +11,7 @@ do
echo "[+] Checking fmt and building $fuzzer" echo "[+] Checking fmt and building $fuzzer"
cd $fuzzer \ cd $fuzzer \
&& cargo fmt --all -- --check \ && cargo fmt --all -- --check \
&& cargo clippy \
&& cargo build \ && cargo build \
&& cd .. \ && cd .. \
|| exit 1 || exit 1