a bit refactoring
This commit is contained in:
parent
ccce1c2595
commit
4e4586d3b2
@ -1,19 +1,14 @@
|
|||||||
pub mod testcase;
|
pub mod testcase;
|
||||||
pub use testcase::Testcase;
|
pub use testcase::Testcase;
|
||||||
|
|
||||||
use alloc::borrow::ToOwned;
|
use alloc::{borrow::ToOwned, vec::Vec};
|
||||||
use alloc::vec::Vec;
|
use core::{cell::RefCell, marker::PhantomData, ptr};
|
||||||
use core::cell::RefCell;
|
|
||||||
use core::marker::PhantomData;
|
|
||||||
use core::ptr;
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use crate::inputs::Input;
|
use crate::{inputs::Input, utils::Rand, AflError};
|
||||||
use crate::utils::Rand;
|
|
||||||
use crate::AflError;
|
|
||||||
|
|
||||||
/// A way to obtain the containing testcase entries
|
/// A way to obtain the containing testcase entries
|
||||||
pub trait HasTestcaseVec<I>
|
pub trait HasTestcaseVec<I>
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
use alloc::string::String;
|
use alloc::string::String;
|
||||||
use core::convert::Into;
|
use core::{convert::Into, default::Default, option::Option};
|
||||||
use core::default::Default;
|
|
||||||
use core::option::Option;
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::inputs::Input;
|
use crate::{
|
||||||
use crate::serde_anymap::{SerdeAny, SerdeAnyMap};
|
inputs::Input,
|
||||||
use crate::AflError;
|
serde_anymap::{SerdeAny, SerdeAnyMap},
|
||||||
|
AflError,
|
||||||
|
};
|
||||||
|
|
||||||
/// An entry in the Testcase Corpus
|
/// An entry in the Testcase Corpus
|
||||||
#[derive(Default, Serialize, Deserialize, Clone, Debug)]
|
#[derive(Default, Serialize, Deserialize, Clone, Debug)]
|
||||||
|
@ -9,21 +9,23 @@ use std::{
|
|||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::corpus::{Corpus, Testcase};
|
use crate::{
|
||||||
use crate::events::EventManager;
|
corpus::{Corpus, Testcase},
|
||||||
use crate::executors::{Executor, ExecutorsTuple, HasObservers};
|
events::EventManager,
|
||||||
use crate::feedbacks::FeedbacksTuple;
|
executors::{Executor, ExecutorsTuple, HasObservers},
|
||||||
use crate::generators::Generator;
|
feedbacks::FeedbacksTuple,
|
||||||
|
generators::Generator,
|
||||||
|
inputs::Input,
|
||||||
|
observers::ObserversTuple,
|
||||||
|
serde_anymap::{SerdeAny, SerdeAnyMap},
|
||||||
|
stages::StagesTuple,
|
||||||
|
tuples::{tuple_list, tuple_list_type},
|
||||||
|
utils::{current_milliseconds, Rand},
|
||||||
|
AflError,
|
||||||
|
};
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
use crate::inputs::bytes::BytesInput;
|
use crate::inputs::bytes::BytesInput;
|
||||||
use crate::inputs::Input;
|
|
||||||
use crate::observers::ObserversTuple;
|
|
||||||
use crate::serde_anymap::{SerdeAny, SerdeAnyMap};
|
|
||||||
use crate::stages::StagesTuple;
|
|
||||||
use crate::tuples::{tuple_list, tuple_list_type};
|
|
||||||
use crate::utils::{current_milliseconds, Rand};
|
|
||||||
|
|
||||||
use crate::AflError;
|
|
||||||
|
|
||||||
pub trait StateMetadata: Debug {
|
pub trait StateMetadata: Debug {
|
||||||
/// The name of this metadata - used to find it in the list of avaliable metadatas
|
/// The name of this metadata - used to find it in the list of avaliable metadatas
|
||||||
|
@ -1,25 +1,30 @@
|
|||||||
pub mod llmp;
|
pub mod llmp;
|
||||||
pub mod shmem;
|
pub mod shmem;
|
||||||
|
|
||||||
use alloc::string::{String, ToString};
|
use alloc::{
|
||||||
use alloc::vec::Vec;
|
string::{String, ToString},
|
||||||
use core::time::Duration;
|
vec::Vec,
|
||||||
use core::{marker::PhantomData, time};
|
};
|
||||||
|
use core::{
|
||||||
|
time::Duration,
|
||||||
|
{marker::PhantomData, time},
|
||||||
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use self::{
|
use self::{
|
||||||
llmp::{LlmpClient, Tag},
|
llmp::{LlmpClient, Tag},
|
||||||
shmem::ShMem,
|
shmem::ShMem,
|
||||||
};
|
};
|
||||||
use crate::corpus::Corpus;
|
use crate::{
|
||||||
use crate::executors::Executor;
|
corpus::Corpus,
|
||||||
use crate::feedbacks::FeedbacksTuple;
|
feedbacks::FeedbacksTuple,
|
||||||
use crate::inputs::Input;
|
inputs::Input,
|
||||||
use crate::observers::ObserversTuple;
|
observers::ObserversTuple,
|
||||||
use crate::serde_anymap::Ptr;
|
serde_anymap::Ptr,
|
||||||
use crate::utils::Rand;
|
utils::Rand,
|
||||||
use crate::AflError;
|
AflError,
|
||||||
use crate::{engines::State, utils};
|
{engines::State, utils},
|
||||||
|
};
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
use shmem::AflShmem;
|
use shmem::AflShmem;
|
||||||
|
|
||||||
@ -235,16 +240,23 @@ where
|
|||||||
&mut self,
|
&mut self,
|
||||||
state: &mut State<I, R, FT>,
|
state: &mut State<I, R, FT>,
|
||||||
corpus: &mut C,
|
corpus: &mut C,
|
||||||
) -> Result<usize, AflError> where
|
) -> Result<usize, AflError>
|
||||||
|
where
|
||||||
C: Corpus<I, R>,
|
C: Corpus<I, R>,
|
||||||
FT: FeedbacksTuple<I>,
|
FT: FeedbacksTuple<I>,
|
||||||
R: Rand;
|
R: Rand;
|
||||||
|
|
||||||
fn serialize_observers<OT>(&mut self, observers: &OT) -> Result<Vec<u8>, AflError> where OT: ObserversTuple {
|
fn serialize_observers<OT>(&mut self, observers: &OT) -> Result<Vec<u8>, AflError>
|
||||||
|
where
|
||||||
|
OT: ObserversTuple,
|
||||||
|
{
|
||||||
Ok(postcard::to_allocvec(observers)?)
|
Ok(postcard::to_allocvec(observers)?)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn deserialize_observers<OT>(&mut self, observers_buf: &[u8]) -> Result<OT, AflError> where OT: ObserversTuple {
|
fn deserialize_observers<OT>(&mut self, observers_buf: &[u8]) -> Result<OT, AflError>
|
||||||
|
where
|
||||||
|
OT: ObserversTuple,
|
||||||
|
{
|
||||||
Ok(postcard::from_bytes(observers_buf)?)
|
Ok(postcard::from_bytes(observers_buf)?)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,7 +266,10 @@ where
|
|||||||
_observers: &OT,
|
_observers: &OT,
|
||||||
_corpus_size: usize,
|
_corpus_size: usize,
|
||||||
_config: String,
|
_config: String,
|
||||||
) -> Result<(), AflError> where OT: ObserversTuple {
|
) -> Result<(), AflError>
|
||||||
|
where
|
||||||
|
OT: ObserversTuple,
|
||||||
|
{
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -410,8 +425,7 @@ where
|
|||||||
events: Vec<LoggerEvent<I>>,
|
events: Vec<LoggerEvent<I>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<I, ST> EventManager<I>
|
impl<I, ST> EventManager<I> for LoggerEventManager<I, ST>
|
||||||
for LoggerEventManager<I, ST>
|
|
||||||
where
|
where
|
||||||
I: Input,
|
I: Input,
|
||||||
ST: Stats,
|
ST: Stats,
|
||||||
@ -421,10 +435,12 @@ where
|
|||||||
&mut self,
|
&mut self,
|
||||||
state: &mut State<I, R, FT>,
|
state: &mut State<I, R, FT>,
|
||||||
corpus: &mut C,
|
corpus: &mut C,
|
||||||
) -> Result<usize, AflError> where
|
) -> Result<usize, AflError>
|
||||||
|
where
|
||||||
C: Corpus<I, R>,
|
C: Corpus<I, R>,
|
||||||
FT: FeedbacksTuple<I>,
|
FT: FeedbacksTuple<I>,
|
||||||
R: Rand {
|
R: Rand,
|
||||||
|
{
|
||||||
let count = self.events.len();
|
let count = self.events.len();
|
||||||
self.events
|
self.events
|
||||||
.drain(..)
|
.drain(..)
|
||||||
@ -438,7 +454,10 @@ where
|
|||||||
_observers: &OT,
|
_observers: &OT,
|
||||||
corpus_size: usize,
|
corpus_size: usize,
|
||||||
_config: String,
|
_config: String,
|
||||||
) -> Result<(), AflError> where OT: ObserversTuple {
|
) -> Result<(), AflError>
|
||||||
|
where
|
||||||
|
OT: ObserversTuple,
|
||||||
|
{
|
||||||
let event = LoggerEvent::NewTestcase {
|
let event = LoggerEvent::NewTestcase {
|
||||||
corpus_size: corpus_size,
|
corpus_size: corpus_size,
|
||||||
phantom: PhantomData,
|
phantom: PhantomData,
|
||||||
@ -823,8 +842,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<I, ST, SH> EventManager<I>
|
impl<I, ST, SH> EventManager<I> for LlmpEventManager<I, SH, ST>
|
||||||
for LlmpEventManager<I, SH, ST>
|
|
||||||
where
|
where
|
||||||
I: Input,
|
I: Input,
|
||||||
SH: ShMem,
|
SH: ShMem,
|
||||||
@ -835,10 +853,12 @@ where
|
|||||||
&mut self,
|
&mut self,
|
||||||
state: &mut State<I, R, FT>,
|
state: &mut State<I, R, FT>,
|
||||||
corpus: &mut C,
|
corpus: &mut C,
|
||||||
) -> Result<usize, AflError> where
|
) -> Result<usize, AflError>
|
||||||
|
where
|
||||||
C: Corpus<I, R>,
|
C: Corpus<I, R>,
|
||||||
FT: FeedbacksTuple<I>,
|
FT: FeedbacksTuple<I>,
|
||||||
R: Rand {
|
R: Rand,
|
||||||
|
{
|
||||||
// TODO: Get around local event copy by moving handle_in_client
|
// TODO: Get around local event copy by moving handle_in_client
|
||||||
Ok(match &mut self.llmp {
|
Ok(match &mut self.llmp {
|
||||||
llmp::LlmpConnection::IsClient { client } => {
|
llmp::LlmpConnection::IsClient { client } => {
|
||||||
@ -875,7 +895,10 @@ where
|
|||||||
observers: &OT,
|
observers: &OT,
|
||||||
corpus_size: usize,
|
corpus_size: usize,
|
||||||
config: String,
|
config: String,
|
||||||
) -> Result<(), AflError> where OT: ObserversTuple {
|
) -> Result<(), AflError>
|
||||||
|
where
|
||||||
|
OT: ObserversTuple,
|
||||||
|
{
|
||||||
let kind = LLMPEventKind::NewTestcase {
|
let kind = LLMPEventKind::NewTestcase {
|
||||||
input: Ptr::Ref(input),
|
input: Ptr::Ref(input),
|
||||||
observers_buf: postcard::to_allocvec(observers)?,
|
observers_buf: postcard::to_allocvec(observers)?,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use alloc::{boxed::Box, string::ToString, vec::Vec};
|
use alloc::{boxed::Box, vec::Vec};
|
||||||
use core::{ffi::c_void, ptr};
|
use core::{ffi::c_void, ptr};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@ -134,8 +134,7 @@ where
|
|||||||
_state: &State<I, R, FT>,
|
_state: &State<I, R, FT>,
|
||||||
_corpus: &C,
|
_corpus: &C,
|
||||||
_event_mgr: &EM,
|
_event_mgr: &EM,
|
||||||
) -> Self
|
) -> Self {
|
||||||
{
|
|
||||||
/*#[cfg(feature = "std")]
|
/*#[cfg(feature = "std")]
|
||||||
unsafe {
|
unsafe {
|
||||||
CORPUS_PTR = _corpus as *const _ as *const c_void;
|
CORPUS_PTR = _corpus as *const _ as *const c_void;
|
||||||
@ -155,7 +154,10 @@ where
|
|||||||
|
|
||||||
/// Serialize the current state and corpus during an executiont to bytes.
|
/// Serialize the current state and corpus during an executiont to bytes.
|
||||||
/// This method is needed when the fuzzer run crashes and has to restart.
|
/// This method is needed when the fuzzer run crashes and has to restart.
|
||||||
pub fn serialize_state_corpus<C, FT, I, R>(state: &State<I, R, FT>, corpus: &C) -> Result<Vec<u8>, AflError>
|
pub fn serialize_state_corpus<C, FT, I, R>(
|
||||||
|
state: &State<I, R, FT>,
|
||||||
|
corpus: &C,
|
||||||
|
) -> Result<Vec<u8>, AflError>
|
||||||
where
|
where
|
||||||
C: Corpus<I, R>,
|
C: Corpus<I, R>,
|
||||||
FT: FeedbacksTuple<I>,
|
FT: FeedbacksTuple<I>,
|
||||||
@ -205,12 +207,12 @@ pub mod unix_signals {
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
corpus::Corpus,
|
corpus::Corpus,
|
||||||
events::EventManager,
|
|
||||||
executors::{
|
|
||||||
inmemory::{OnCrashFunction, ExitKind, CURRENT_INPUT_PTR, CURRENT_ON_CRASH_FN, CORPUS_PTR, STATE_PTR, EVENT_MANAGER_PTR},
|
|
||||||
Executor,
|
|
||||||
},
|
|
||||||
engines::State,
|
engines::State,
|
||||||
|
events::EventManager,
|
||||||
|
executors::inmemory::{
|
||||||
|
ExitKind, OnCrashFunction, CORPUS_PTR, CURRENT_INPUT_PTR, CURRENT_ON_CRASH_FN,
|
||||||
|
EVENT_MANAGER_PTR, STATE_PTR,
|
||||||
|
},
|
||||||
feedbacks::FeedbacksTuple,
|
feedbacks::FeedbacksTuple,
|
||||||
inputs::Input,
|
inputs::Input,
|
||||||
observers::ObserversTuple,
|
observers::ObserversTuple,
|
||||||
@ -243,7 +245,9 @@ pub mod unix_signals {
|
|||||||
|
|
||||||
let input = (CURRENT_INPUT_PTR as *const I).as_ref().unwrap();
|
let input = (CURRENT_INPUT_PTR as *const I).as_ref().unwrap();
|
||||||
let corpus = (CORPUS_PTR as *const C).as_ref().unwrap();
|
let corpus = (CORPUS_PTR as *const C).as_ref().unwrap();
|
||||||
let state = (EVENT_MANAGER_PTR as *const State<I, R, FT>).as_ref().unwrap();
|
let state = (EVENT_MANAGER_PTR as *const State<I, R, FT>)
|
||||||
|
.as_ref()
|
||||||
|
.unwrap();
|
||||||
let manager = (EVENT_MANAGER_PTR as *mut EM).as_mut().unwrap();
|
let manager = (EVENT_MANAGER_PTR as *mut EM).as_mut().unwrap();
|
||||||
|
|
||||||
if !CURRENT_ON_CRASH_FN.is_null() {
|
if !CURRENT_ON_CRASH_FN.is_null() {
|
||||||
@ -279,7 +283,9 @@ pub mod unix_signals {
|
|||||||
|
|
||||||
let input = (CURRENT_INPUT_PTR as *const I).as_ref().unwrap();
|
let input = (CURRENT_INPUT_PTR as *const I).as_ref().unwrap();
|
||||||
let corpus = (CORPUS_PTR as *const C).as_ref().unwrap();
|
let corpus = (CORPUS_PTR as *const C).as_ref().unwrap();
|
||||||
let state = (EVENT_MANAGER_PTR as *const State<I, R, FT>).as_ref().unwrap();
|
let state = (EVENT_MANAGER_PTR as *const State<I, R, FT>)
|
||||||
|
.as_ref()
|
||||||
|
.unwrap();
|
||||||
let manager = (EVENT_MANAGER_PTR as *mut EM).as_mut().unwrap();
|
let manager = (EVENT_MANAGER_PTR as *mut EM).as_mut().unwrap();
|
||||||
|
|
||||||
if !CURRENT_ON_CRASH_FN.is_null() {
|
if !CURRENT_ON_CRASH_FN.is_null() {
|
||||||
@ -288,7 +294,7 @@ pub mod unix_signals {
|
|||||||
input,
|
input,
|
||||||
state,
|
state,
|
||||||
corpus,
|
corpus,
|
||||||
manager
|
manager,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,8 +305,11 @@ pub mod unix_signals {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO clearly state that manager should be static (maybe put the 'static lifetime?)
|
// TODO clearly state that manager should be static (maybe put the 'static lifetime?)
|
||||||
pub unsafe fn setup_crash_handlers<EM, C, E, OT, FT, I, R>(state: &State<I, R, FT>, corpus: &C, manager: &mut EM)
|
pub unsafe fn setup_crash_handlers<EM, C, E, OT, FT, I, R>(
|
||||||
where
|
state: &State<I, R, FT>,
|
||||||
|
corpus: &C,
|
||||||
|
manager: &mut EM,
|
||||||
|
) where
|
||||||
EM: EventManager<I>,
|
EM: EventManager<I>,
|
||||||
C: Corpus<I, R>,
|
C: Corpus<I, R>,
|
||||||
OT: ObserversTuple,
|
OT: ObserversTuple,
|
||||||
|
@ -4,10 +4,12 @@ pub mod runtime;
|
|||||||
|
|
||||||
use core::marker::PhantomData;
|
use core::marker::PhantomData;
|
||||||
|
|
||||||
use crate::inputs::{HasTargetBytes, Input};
|
use crate::{
|
||||||
use crate::observers::ObserversTuple;
|
inputs::{HasTargetBytes, Input},
|
||||||
use crate::tuples::{MatchNameAndType, MatchType, Named, TupleList};
|
observers::ObserversTuple,
|
||||||
use crate::AflError;
|
tuples::{MatchNameAndType, MatchType, Named, TupleList},
|
||||||
|
AflError,
|
||||||
|
};
|
||||||
|
|
||||||
/// How an execution finished.
|
/// How an execution finished.
|
||||||
pub enum ExitKind {
|
pub enum ExitKind {
|
||||||
|
@ -1,14 +1,18 @@
|
|||||||
use alloc::string::{String, ToString};
|
use alloc::{
|
||||||
use alloc::vec::Vec;
|
string::{String, ToString},
|
||||||
|
vec::Vec,
|
||||||
|
};
|
||||||
use core::marker::PhantomData;
|
use core::marker::PhantomData;
|
||||||
use num::Integer;
|
use num::Integer;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::corpus::Testcase;
|
use crate::{
|
||||||
use crate::inputs::Input;
|
corpus::Testcase,
|
||||||
use crate::observers::{MapObserver, Observer, ObserversTuple};
|
inputs::Input,
|
||||||
use crate::tuples::{Named, TupleList};
|
observers::{MapObserver, Observer, ObserversTuple},
|
||||||
use crate::AflError;
|
tuples::{Named, TupleList},
|
||||||
|
AflError,
|
||||||
|
};
|
||||||
|
|
||||||
pub type MaxMapFeedback<T, O> = MapFeedback<T, MaxReducer<T>, O>;
|
pub type MaxMapFeedback<T, O> = MapFeedback<T, MaxReducer<T>, O>;
|
||||||
pub type MinMapFeedback<T, O> = MapFeedback<T, MinReducer<T>, O>;
|
pub type MinMapFeedback<T, O> = MapFeedback<T, MinReducer<T>, O>;
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
use core::cmp::min;
|
use core::{cmp::min, marker::PhantomData};
|
||||||
use core::marker::PhantomData;
|
|
||||||
|
|
||||||
use crate::inputs::bytes::BytesInput;
|
use crate::{
|
||||||
use crate::inputs::Input;
|
inputs::{bytes::BytesInput, Input},
|
||||||
use crate::utils::Rand;
|
utils::Rand,
|
||||||
use crate::AflError;
|
AflError,
|
||||||
|
};
|
||||||
|
|
||||||
/// The maximum size of dummy bytes generated by _dummy generator methods
|
/// The maximum size of dummy bytes generated by _dummy generator methods
|
||||||
const DUMMY_BYTES_MAX: usize = 64;
|
const DUMMY_BYTES_MAX: usize = 64;
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
use alloc::borrow::ToOwned;
|
use alloc::{borrow::ToOwned, rc::Rc, vec::Vec};
|
||||||
use alloc::rc::Rc;
|
use core::{cell::RefCell, convert::From};
|
||||||
use alloc::vec::Vec;
|
|
||||||
use core::cell::RefCell;
|
|
||||||
use core::convert::From;
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::inputs::{HasBytesVec, HasTargetBytes, Input, TargetBytes};
|
use crate::inputs::{HasBytesVec, HasTargetBytes, Input, TargetBytes};
|
||||||
|
@ -2,15 +2,14 @@ pub mod bytes;
|
|||||||
pub use bytes::BytesInput;
|
pub use bytes::BytesInput;
|
||||||
|
|
||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
use core::clone::Clone;
|
use core::{clone::Clone, fmt::Debug};
|
||||||
use core::fmt::Debug;
|
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
use std::fs::File;
|
use std::{
|
||||||
#[cfg(feature = "std")]
|
fs::File,
|
||||||
use std::io::{Read, Write};
|
io::{Read, Write},
|
||||||
#[cfg(feature = "std")]
|
path::Path,
|
||||||
use std::path::Path;
|
};
|
||||||
|
|
||||||
use crate::AflError;
|
use crate::AflError;
|
||||||
|
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
use alloc::boxed::Box;
|
use alloc::{boxed::Box, vec::Vec};
|
||||||
use alloc::vec::Vec;
|
use core::{
|
||||||
use core::any::{Any, TypeId};
|
any::{Any, TypeId},
|
||||||
use core::slice::{Iter, IterMut};
|
slice::{Iter, IterMut},
|
||||||
use hashbrown::hash_map::{Keys, Values, ValuesMut};
|
};
|
||||||
use hashbrown::HashMap;
|
use hashbrown::{
|
||||||
|
hash_map::{Keys, Values, ValuesMut},
|
||||||
|
HashMap,
|
||||||
|
};
|
||||||
|
|
||||||
/// A map, storing any trait object by TypeId
|
/// A map, storing any trait object by TypeId
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
@ -3,10 +3,7 @@ pub use scheduled::*;
|
|||||||
pub mod mutations;
|
pub mod mutations;
|
||||||
pub use mutations::*;
|
pub use mutations::*;
|
||||||
|
|
||||||
use crate::corpus::Corpus;
|
use crate::{corpus::Corpus, inputs::Input, utils::Rand, AflError};
|
||||||
use crate::inputs::Input;
|
|
||||||
use crate::utils::Rand;
|
|
||||||
use crate::AflError;
|
|
||||||
|
|
||||||
// TODO mutator stats method that produces something that can be sent with the NewTestcase event
|
// TODO mutator stats method that produces something that can be sent with the NewTestcase event
|
||||||
// We can use it to report which mutations generated the testcase in the broker logs
|
// We can use it to report which mutations generated the testcase in the broker logs
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
use crate::inputs::{HasBytesVec, Input};
|
use crate::{
|
||||||
use crate::mutators::Corpus;
|
inputs::{HasBytesVec, Input},
|
||||||
use crate::mutators::*;
|
mutators::Corpus,
|
||||||
use crate::utils::Rand;
|
mutators::*,
|
||||||
use crate::AflError;
|
utils::Rand,
|
||||||
|
AflError,
|
||||||
|
};
|
||||||
|
|
||||||
/// The result of a mutation.
|
/// The result of a mutation.
|
||||||
/// If the mutation got skipped, the target
|
/// If the mutation got skipped, the target
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
use core::marker::PhantomData;
|
use core::marker::PhantomData;
|
||||||
|
|
||||||
use crate::inputs::{HasBytesVec, Input};
|
use crate::{
|
||||||
use crate::mutators::Corpus;
|
inputs::{HasBytesVec, Input},
|
||||||
use crate::mutators::*;
|
mutators::{Corpus, *},
|
||||||
use crate::utils::Rand;
|
utils::Rand,
|
||||||
use crate::AflError;
|
AflError,
|
||||||
|
};
|
||||||
|
|
||||||
pub trait ScheduledMutator<C, I, R>: Mutator<C, I, R> + ComposedByMutations<C, I, R>
|
pub trait ScheduledMutator<C, I, R>: Mutator<C, I, R> + ComposedByMutations<C, I, R>
|
||||||
where
|
where
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
extern crate num;
|
extern crate num;
|
||||||
|
|
||||||
use alloc::string::{String, ToString};
|
use alloc::{
|
||||||
use alloc::vec::Vec;
|
string::{String, ToString},
|
||||||
|
vec::Vec,
|
||||||
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::serde_anymap::{ArrayMut, Cptr};
|
use crate::{
|
||||||
use crate::tuples::{MatchNameAndType, MatchType, Named, TupleList};
|
serde_anymap::{ArrayMut, Cptr},
|
||||||
use crate::AflError;
|
tuples::{MatchNameAndType, MatchType, Named, TupleList},
|
||||||
|
AflError,
|
||||||
|
};
|
||||||
|
|
||||||
/// Observers observe different information about the target.
|
/// Observers observe different information about the target.
|
||||||
/// They can then be used by various sorts of feedback.
|
/// They can then be used by various sorts of feedback.
|
||||||
|
@ -1,16 +1,18 @@
|
|||||||
pub mod mutational;
|
pub mod mutational;
|
||||||
pub use mutational::StdMutationalStage;
|
pub use mutational::StdMutationalStage;
|
||||||
|
|
||||||
use crate::corpus::Corpus;
|
use crate::{
|
||||||
use crate::engines::{Engine, State};
|
corpus::Corpus,
|
||||||
use crate::events::EventManager;
|
engines::{Engine, State},
|
||||||
use crate::executors::{Executor, ExecutorsTuple, HasObservers};
|
events::EventManager,
|
||||||
use crate::feedbacks::FeedbacksTuple;
|
executors::{Executor, ExecutorsTuple, HasObservers},
|
||||||
use crate::inputs::Input;
|
feedbacks::FeedbacksTuple,
|
||||||
use crate::observers::ObserversTuple;
|
inputs::Input,
|
||||||
use crate::tuples::TupleList;
|
observers::ObserversTuple,
|
||||||
use crate::utils::Rand;
|
tuples::TupleList,
|
||||||
use crate::AflError;
|
utils::Rand,
|
||||||
|
AflError,
|
||||||
|
};
|
||||||
|
|
||||||
/// A stage is one step in the fuzzing process.
|
/// A stage is one step in the fuzzing process.
|
||||||
/// Multiple stages will be scheduled one by one for each input.
|
/// Multiple stages will be scheduled one by one for each input.
|
||||||
|
@ -1,16 +1,18 @@
|
|||||||
use core::marker::PhantomData;
|
use core::marker::PhantomData;
|
||||||
|
|
||||||
use crate::engines::State;
|
use crate::{
|
||||||
use crate::events::EventManager;
|
engines::State,
|
||||||
use crate::executors::{Executor, ExecutorsTuple, HasObservers};
|
events::EventManager,
|
||||||
use crate::feedbacks::FeedbacksTuple;
|
executors::{Executor, ExecutorsTuple, HasObservers},
|
||||||
use crate::inputs::Input;
|
feedbacks::FeedbacksTuple,
|
||||||
use crate::mutators::Mutator;
|
inputs::Input,
|
||||||
use crate::observers::ObserversTuple;
|
mutators::Mutator,
|
||||||
use crate::stages::Corpus;
|
observers::ObserversTuple,
|
||||||
use crate::stages::{Engine, Stage};
|
stages::Corpus,
|
||||||
use crate::utils::Rand;
|
stages::{Engine, Stage},
|
||||||
use crate::AflError;
|
utils::Rand,
|
||||||
|
AflError,
|
||||||
|
};
|
||||||
|
|
||||||
// TODO multi mutators stage
|
// TODO multi mutators stage
|
||||||
|
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
pub use tuple_list::tuple_list;
|
pub use tuple_list::{tuple_list, tuple_list_type, TupleList};
|
||||||
pub use tuple_list::tuple_list_type;
|
|
||||||
pub use tuple_list::TupleList;
|
|
||||||
|
|
||||||
use core::any::TypeId;
|
use core::any::TypeId;
|
||||||
|
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
//! Utility functions for AFL
|
//! Utility functions for AFL
|
||||||
|
|
||||||
use alloc::rc::Rc;
|
use alloc::rc::Rc;
|
||||||
use core::debug_assert;
|
use core::{cell::RefCell, debug_assert, fmt::Debug, time};
|
||||||
use core::fmt::Debug;
|
|
||||||
use core::{cell::RefCell, time};
|
|
||||||
use xxhash_rust::xxh3::xxh3_64_with_seed;
|
use xxhash_rust::xxh3::xxh3_64_with_seed;
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
|
@ -4,7 +4,8 @@ use std::env;
|
|||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
const LIBPNG_URL: &str = "https://deac-fra.dl.sourceforge.net/project/libpng/libpng16/1.6.37/libpng-1.6.37.tar.xz";
|
const LIBPNG_URL: &str =
|
||||||
|
"https://deac-fra.dl.sourceforge.net/project/libpng/libpng16/1.6.37/libpng-1.6.37.tar.xz";
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let out_dir = env::var_os("OUT_DIR").unwrap();
|
let out_dir = env::var_os("OUT_DIR").unwrap();
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
extern crate clap;
|
extern crate clap;
|
||||||
|
|
||||||
use clap::{App, Arg};
|
use clap::{App, Arg};
|
||||||
use postcard;
|
|
||||||
use std::{env, path::PathBuf, process::Command};
|
use std::{env, path::PathBuf, process::Command};
|
||||||
|
|
||||||
use afl::{
|
use afl::{
|
||||||
@ -15,17 +14,17 @@ use afl::{
|
|||||||
EventManager, LlmpEventManager, SimpleStats,
|
EventManager, LlmpEventManager, SimpleStats,
|
||||||
},
|
},
|
||||||
executors::{
|
executors::{
|
||||||
inmemory::{serialize_state_corpus, deserialize_state_corpus, InMemoryExecutor},
|
inmemory::{deserialize_state_corpus, serialize_state_corpus, InMemoryExecutor},
|
||||||
Executor, ExitKind,
|
Executor, ExitKind,
|
||||||
},
|
},
|
||||||
feedbacks::MaxMapFeedback,
|
feedbacks::MaxMapFeedback,
|
||||||
generators::RandPrintablesGenerator,
|
generators::RandPrintablesGenerator,
|
||||||
|
inputs::BytesInput,
|
||||||
mutators::{scheduled::HavocBytesMutator, HasMaxSize},
|
mutators::{scheduled::HavocBytesMutator, HasMaxSize},
|
||||||
observers::StdMapObserver,
|
observers::StdMapObserver,
|
||||||
stages::mutational::StdMutationalStage,
|
stages::mutational::StdMutationalStage,
|
||||||
tuples::tuple_list,
|
tuples::tuple_list,
|
||||||
utils::StdRand,
|
utils::StdRand,
|
||||||
inputs::BytesInput,
|
|
||||||
AflError,
|
AflError,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -104,7 +103,10 @@ fn fuzz(input: Option<Vec<PathBuf>>, broker_port: u16) -> Result<(), AflError> {
|
|||||||
|
|
||||||
// We are the fuzzing instance, first, connect to all channels.
|
// We are the fuzzing instance, first, connect to all channels.
|
||||||
// Mgr to send and receive msgs from/to all other fuzzer instances
|
// Mgr to send and receive msgs from/to all other fuzzer instances
|
||||||
mgr = LlmpEventManager::<BytesInput, _, _>::existing_client_from_env_std(ENV_FUZZER_BROKER_CLIENT, stats)?;
|
mgr = LlmpEventManager::<BytesInput, _, _>::existing_client_from_env_std(
|
||||||
|
ENV_FUZZER_BROKER_CLIENT,
|
||||||
|
stats,
|
||||||
|
)?;
|
||||||
// A sender and a receiver for single communication
|
// A sender and a receiver for single communication
|
||||||
let mut receiver = LlmpReceiver::<AflShmem>::on_existing_from_env(ENV_FUZZER_RECEIVER)?;
|
let mut receiver = LlmpReceiver::<AflShmem>::on_existing_from_env(ENV_FUZZER_RECEIVER)?;
|
||||||
let mut sender = LlmpSender::<AflShmem>::on_existing_from_env(ENV_FUZZER_SENDER)?;
|
let mut sender = LlmpSender::<AflShmem>::on_existing_from_env(ENV_FUZZER_SENDER)?;
|
||||||
@ -143,9 +145,14 @@ fn fuzz(input: Option<Vec<PathBuf>>, broker_port: u16) -> Result<(), AflError> {
|
|||||||
tuple_list!(edges_observer),
|
tuple_list!(edges_observer),
|
||||||
Box::new(move |exit_kind, input, state, corpus, mgr| {
|
Box::new(move |exit_kind, input, state, corpus, mgr| {
|
||||||
match exit_kind {
|
match exit_kind {
|
||||||
ExitKind::Timeout => mgr.timeout(input).expect(&format!("Error sending Timeout event for input {:?}", input)),
|
ExitKind::Timeout => mgr.timeout(input).expect(&format!(
|
||||||
ExitKind::Crash => mgr.crash(input).expect(&format!("Error sending crash event for input {:?}", input)),
|
"Error sending Timeout event for input {:?}",
|
||||||
_ => ()
|
input
|
||||||
|
)),
|
||||||
|
ExitKind::Crash => mgr
|
||||||
|
.crash(input)
|
||||||
|
.expect(&format!("Error sending crash event for input {:?}", input)),
|
||||||
|
_ => (),
|
||||||
}
|
}
|
||||||
let state_corpus_serialized = serialize_state_corpus(state, corpus).unwrap();
|
let state_corpus_serialized = serialize_state_corpus(state, corpus).unwrap();
|
||||||
sender.send_buf(0x1, &state_corpus_serialized).unwrap();
|
sender.send_buf(0x1, &state_corpus_serialized).unwrap();
|
||||||
@ -250,6 +257,6 @@ pub fn main() {
|
|||||||
|
|
||||||
println!("Workdir: {:?}", workdir);
|
println!("Workdir: {:?}", workdir);
|
||||||
|
|
||||||
fuzz(Some(vec![PathBuf::from("./corpus/")]), broker_port).expect("An error occurred while fuzzing");
|
fuzz(Some(vec![PathBuf::from("./in1")]), broker_port).expect("An error occurred while fuzzing");
|
||||||
//fuzz(input, broker_port).expect("An error occurred while fuzzing");
|
//fuzz(input, broker_port).expect("An error occurred while fuzzing");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user