max len done right
This commit is contained in:
parent
ebc9571410
commit
9bc4d81b76
@ -578,7 +578,7 @@ where
|
|||||||
corpus_size,
|
corpus_size,
|
||||||
observers_buf: _,
|
observers_buf: _,
|
||||||
time,
|
time,
|
||||||
executions
|
executions,
|
||||||
} => {
|
} => {
|
||||||
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);
|
||||||
@ -639,7 +639,7 @@ where
|
|||||||
corpus_size: _,
|
corpus_size: _,
|
||||||
observers_buf,
|
observers_buf,
|
||||||
time: _,
|
time: _,
|
||||||
executions: _
|
executions: _,
|
||||||
} => {
|
} => {
|
||||||
// TODO: here u should match client_config, if equal to the current one do not re-execute
|
// TODO: here u should match client_config, if equal to the current one do not re-execute
|
||||||
// we need to pass engine to process() too, TODO
|
// we need to pass engine to process() too, TODO
|
||||||
@ -977,7 +977,7 @@ mod tests {
|
|||||||
corpus_size: 123,
|
corpus_size: 123,
|
||||||
client_config: "conf".into(),
|
client_config: "conf".into(),
|
||||||
time: current_time(),
|
time: current_time(),
|
||||||
executions: 0
|
executions: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
let serialized = postcard::to_allocvec(&e).unwrap();
|
let serialized = postcard::to_allocvec(&e).unwrap();
|
||||||
@ -990,7 +990,7 @@ mod tests {
|
|||||||
corpus_size: _,
|
corpus_size: _,
|
||||||
client_config: _,
|
client_config: _,
|
||||||
time: _,
|
time: _,
|
||||||
executions: _
|
executions: _,
|
||||||
} => {
|
} => {
|
||||||
let o = map.deserialize(&observers_buf).unwrap();
|
let o = map.deserialize(&observers_buf).unwrap();
|
||||||
let test_observer = o.match_name_type::<StdMapObserver<u32>>("test").unwrap();
|
let test_observer = o.match_name_type::<StdMapObserver<u32>>("test").unwrap();
|
||||||
|
@ -26,7 +26,9 @@ pub struct ClientStats {
|
|||||||
impl ClientStats {
|
impl ClientStats {
|
||||||
/// We got a new information about executions for this client, insert them.
|
/// We got a new information about executions for this client, insert them.
|
||||||
pub fn update_executions(&mut self, executions: u64, cur_time: time::Duration) {
|
pub fn update_executions(&mut self, executions: u64, cur_time: time::Duration) {
|
||||||
let diff = cur_time.checked_sub(self.last_window_time).map_or(0, |d| d.as_secs());
|
let diff = cur_time
|
||||||
|
.checked_sub(self.last_window_time)
|
||||||
|
.map_or(0, |d| d.as_secs());
|
||||||
if diff > CLIENT_STATS_TIME_WINDOW_SECS {
|
if diff > CLIENT_STATS_TIME_WINDOW_SECS {
|
||||||
let _ = self.execs_per_sec(cur_time);
|
let _ = self.execs_per_sec(cur_time);
|
||||||
self.last_window_time = cur_time;
|
self.last_window_time = cur_time;
|
||||||
@ -46,7 +48,9 @@ impl ClientStats {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
let elapsed = cur_time.checked_sub(self.last_window_time).map_or(0, |d| d.as_secs());
|
let elapsed = cur_time
|
||||||
|
.checked_sub(self.last_window_time)
|
||||||
|
.map_or(0, |d| d.as_secs());
|
||||||
if elapsed == 0 {
|
if elapsed == 0 {
|
||||||
return self.last_execs_per_sec as u64;
|
return self.last_execs_per_sec as u64;
|
||||||
}
|
}
|
||||||
@ -62,7 +66,8 @@ impl ClientStats {
|
|||||||
self.last_execs_per_sec = cur_avg;
|
self.last_execs_per_sec = cur_avg;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.last_execs_per_sec = self.last_execs_per_sec * (1.0 - 1.0 / 16.0) + cur_avg * (1.0 / 16.0);
|
self.last_execs_per_sec =
|
||||||
|
self.last_execs_per_sec * (1.0 - 1.0 / 16.0) + cur_avg * (1.0 / 16.0);
|
||||||
self.last_execs_per_sec as u64
|
self.last_execs_per_sec as u64
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -504,7 +504,7 @@ where
|
|||||||
|
|
||||||
input.bytes_mut().resize(size + len, 0);
|
input.bytes_mut().resize(size + len, 0);
|
||||||
buffer_self_copy(input.bytes_mut(), off, off + len, size - off);
|
buffer_self_copy(input.bytes_mut(), off, off + len, size - off);
|
||||||
|
|
||||||
Ok(MutationResult::Mutated)
|
Ok(MutationResult::Mutated)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -533,7 +533,7 @@ where
|
|||||||
return Ok(MutationResult::Skipped);
|
return Ok(MutationResult::Skipped);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let val = input.bytes()[rand.below(size as u64) as usize];
|
let val = input.bytes()[rand.below(size as u64) as usize];
|
||||||
|
|
||||||
input.bytes_mut().resize(size + len, 0);
|
input.bytes_mut().resize(size + len, 0);
|
||||||
@ -568,7 +568,7 @@ where
|
|||||||
return Ok(MutationResult::Skipped);
|
return Ok(MutationResult::Skipped);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let val = rand.below(256) as u8;
|
let val = rand.below(256) as u8;
|
||||||
|
|
||||||
input.bytes_mut().resize(size + len, 0);
|
input.bytes_mut().resize(size + len, 0);
|
||||||
@ -618,7 +618,7 @@ where
|
|||||||
}
|
}
|
||||||
let off = rand.below(size as u64) as usize;
|
let off = rand.below(size as u64) as usize;
|
||||||
let len = 1 + rand.below(min(16, size - off) as u64) as usize;
|
let len = 1 + rand.below(min(16, size - off) as u64) as usize;
|
||||||
|
|
||||||
let val = rand.below(256) as u8;
|
let val = rand.below(256) as u8;
|
||||||
|
|
||||||
buffer_set(input.bytes_mut(), off, len, val);
|
buffer_set(input.bytes_mut(), off, len, val);
|
||||||
@ -705,8 +705,8 @@ where
|
|||||||
return Ok(MutationResult::Skipped);
|
return Ok(MutationResult::Skipped);
|
||||||
}
|
}
|
||||||
|
|
||||||
let from = rand.below(other_size as u64 -1) as usize;
|
let from = rand.below(other_size as u64 - 1) as usize;
|
||||||
let to = rand.below(size as u64 -1) as usize;
|
let to = rand.below(size as u64 - 1) as usize;
|
||||||
let len = rand.below((other_size - from) as u64) as usize;
|
let len = rand.below((other_size - from) as u64) as usize;
|
||||||
|
|
||||||
input.bytes_mut().resize(max(size, to + (2 * len) + 1), 0);
|
input.bytes_mut().resize(max(size, to + (2 * len) + 1), 0);
|
||||||
@ -745,9 +745,9 @@ where
|
|||||||
return Ok(MutationResult::Skipped);
|
return Ok(MutationResult::Skipped);
|
||||||
}
|
}
|
||||||
|
|
||||||
let from = rand.below(other_size as u64 -1) as usize;
|
let from = rand.below(other_size as u64 - 1) as usize;
|
||||||
let len = rand.below(min(other_size - from, size) as u64) as usize;
|
let len = rand.below(min(other_size - from, size) as u64) as usize;
|
||||||
let to = rand.below((size - len) as u64 -1) as usize;
|
let to = rand.below((size - len) as u64 - 1) as usize;
|
||||||
|
|
||||||
buffer_copy(input.bytes_mut(), other.bytes(), from, to, len);
|
buffer_copy(input.bytes_mut(), other.bytes(), from, to, len);
|
||||||
|
|
||||||
|
@ -307,7 +307,7 @@ where
|
|||||||
scheduled.add_mutation(mutation_tokeninsert);
|
scheduled.add_mutation(mutation_tokeninsert);
|
||||||
scheduled.add_mutation(mutation_tokenreplace);
|
scheduled.add_mutation(mutation_tokenreplace);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
scheduled.add_mutation(mutation_crossover_insert);
|
scheduled.add_mutation(mutation_crossover_insert);
|
||||||
scheduled.add_mutation(mutation_crossover_replace);
|
scheduled.add_mutation(mutation_crossover_replace);
|
||||||
//scheduled.add_mutation(mutation_splice);
|
//scheduled.add_mutation(mutation_splice);
|
||||||
|
@ -69,7 +69,7 @@ where
|
|||||||
|
|
||||||
input.bytes_mut().resize(size + token_len, 0);
|
input.bytes_mut().resize(size + token_len, 0);
|
||||||
buffer_copy(input.bytes_mut(), token, 0, off, size);
|
buffer_copy(input.bytes_mut(), token, 0, off, size);
|
||||||
|
|
||||||
Ok(MutationResult::Mutated)
|
Ok(MutationResult::Mutated)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -383,7 +383,6 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Map observer with hitcounts postprocessing
|
/// Map observer with hitcounts postprocessing
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||||
#[serde(bound = "M: serde::de::DeserializeOwned")]
|
#[serde(bound = "M: serde::de::DeserializeOwned")]
|
||||||
@ -394,7 +393,20 @@ where
|
|||||||
base: M,
|
base: M,
|
||||||
}
|
}
|
||||||
|
|
||||||
static COUNT_CLASS_LOOKUP: [u8; 256] = [0, 1, 2, 0, 8, 8, 8, 8, 16, 16, 16, 16, 16, 16, 16, 16, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128];
|
static COUNT_CLASS_LOOKUP: [u8; 256] = [
|
||||||
|
0, 1, 2, 0, 8, 8, 8, 8, 16, 16, 16, 16, 16, 16, 16, 16, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
|
||||||
|
32, 32, 32, 32, 32, 32, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
|
||||||
|
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
|
||||||
|
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
|
||||||
|
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
|
||||||
|
64, 64, 64, 64, 64, 64, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
|
||||||
|
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
|
||||||
|
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
|
||||||
|
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
|
||||||
|
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
|
||||||
|
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
|
||||||
|
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
|
||||||
|
];
|
||||||
|
|
||||||
impl<M> Observer for HitcountsMapObserver<M>
|
impl<M> Observer for HitcountsMapObserver<M>
|
||||||
where
|
where
|
||||||
@ -465,13 +477,10 @@ where
|
|||||||
{
|
{
|
||||||
/// Creates a new MapObserver
|
/// Creates a new MapObserver
|
||||||
pub fn new(base: M) -> Self {
|
pub fn new(base: M) -> Self {
|
||||||
Self {
|
Self { base: base }
|
||||||
base: base,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
@ -13,7 +13,7 @@ use afl::{
|
|||||||
executors::{inprocess::InProcessExecutor, Executor, ExitKind},
|
executors::{inprocess::InProcessExecutor, Executor, ExitKind},
|
||||||
feedbacks::MaxMapFeedback,
|
feedbacks::MaxMapFeedback,
|
||||||
inputs::Input,
|
inputs::Input,
|
||||||
mutators::{scheduled::HavocBytesMutator, HasMaxSize},
|
mutators::scheduled::HavocBytesMutator,
|
||||||
observers::StdMapObserver,
|
observers::StdMapObserver,
|
||||||
stages::mutational::StdMutationalStage,
|
stages::mutational::StdMutationalStage,
|
||||||
state::{HasCorpus, State},
|
state::{HasCorpus, State},
|
||||||
@ -51,7 +51,10 @@ where
|
|||||||
|
|
||||||
/// The main fn, parsing parameters, and starting the fuzzer
|
/// The main fn, parsing parameters, and starting the fuzzer
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
println!("Workdir: {:?}", env::current_dir().unwrap().to_string_lossy().to_string());
|
println!(
|
||||||
|
"Workdir: {:?}",
|
||||||
|
env::current_dir().unwrap().to_string_lossy().to_string()
|
||||||
|
);
|
||||||
fuzz(vec![PathBuf::from("./corpus")], 1337).expect("An error occurred while fuzzing");
|
fuzz(vec![PathBuf::from("./corpus")], 1337).expect("An error occurred while fuzzing");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,8 +84,7 @@ fn fuzz(corpus_dirs: Vec<PathBuf>, broker_port: u16) -> Result<(), AflError> {
|
|||||||
|
|
||||||
println!("We're a client, let's fuzz :)");
|
println!("We're a client, let's fuzz :)");
|
||||||
|
|
||||||
let mut mutator = HavocBytesMutator::new_default();
|
let mutator = HavocBytesMutator::new_default();
|
||||||
mutator.set_max_size(4096);
|
|
||||||
let stage = StdMutationalStage::new(mutator);
|
let stage = StdMutationalStage::new(mutator);
|
||||||
let mut fuzzer = StdFuzzer::new(tuple_list!(stage));
|
let mut fuzzer = StdFuzzer::new(tuple_list!(stage));
|
||||||
|
|
||||||
@ -103,12 +105,15 @@ fn fuzz(corpus_dirs: Vec<PathBuf>, broker_port: u16) -> Result<(), AflError> {
|
|||||||
println!("Warning: LLVMFuzzerInitialize failed with -1")
|
println!("Warning: LLVMFuzzerInitialize failed with -1")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// in case the corpus is empty (on first run), reset
|
// in case the corpus is empty (on first run), reset
|
||||||
if state.corpus().count() < 1 {
|
if state.corpus().count() < 1 {
|
||||||
state
|
state
|
||||||
.load_initial_inputs(&mut executor, &mut restarting_mgr, &corpus_dirs)
|
.load_initial_inputs(&mut executor, &mut restarting_mgr, &corpus_dirs)
|
||||||
.expect(&format!("Failed to load initial corpus at {:?}", &corpus_dirs));
|
.expect(&format!(
|
||||||
|
"Failed to load initial corpus at {:?}",
|
||||||
|
&corpus_dirs
|
||||||
|
));
|
||||||
println!("We imported {} inputs from disk.", state.corpus().count());
|
println!("We imported {} inputs from disk.", state.corpus().count());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user