Skip to content

Commit

Permalink
update feroxfuzz
Browse files Browse the repository at this point in the history
  • Loading branch information
iustin24 committed Oct 24, 2022
1 parent 0e7ca22 commit a4b31cb
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ colored = "2.0.0"
clap = { version = "3", features = ["derive"]}
anyhow = "1.0.57"
dirs = "4.0.0"
feroxfuzz = { version = "0.1.0-rc" }
feroxfuzz = { git = "https://github.com/epi052/feroxfuzz" }
itertools = "0.10.3"
serde = "1.0.144"
typetag = { version = "0.2.3" }
Expand Down
9 changes: 6 additions & 3 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::utils::decider::{CalibrateDecider, FilterDecider, MetadataStruct};
use crate::Args;
use colored::Colorize;
use feroxfuzz::client::AsyncClient;
use feroxfuzz::corpora::Wordlist;
use feroxfuzz::corpora::{HttpMethodsCorpus, Wordlist};
use feroxfuzz::deciders::LogicOperation;
use feroxfuzz::fuzzers::AsyncFuzzer;
use feroxfuzz::mutators::ReplaceKeyword;
Expand Down Expand Up @@ -47,8 +47,12 @@ pub(crate) async fn http(paths: HashSet<String>, args: &Args, url: &String) {
let bar = ProgressBar::new(paths.len() as u64);

//let bar = ProgressBar::add_bar("", 0, BarType::Hidden);

let words = Wordlist::with_words(paths).name("words").build();
let mut state = SharedState::with_corpus(words);
let state = SharedState::with_corpus(words);
//let methods = HttpMethodsCorpus::new().method("GET");
//.method("GET").name("methods");
//let mut state = SharedState::with_corpora([words,methods]);
let now = Instant::now();
let client = args.build_client();
let results: Arc<Mutex<Vec<Result>>> = Arc::new(Mutex::new(vec![])); // Used for JSON output
Expand Down Expand Up @@ -277,7 +281,6 @@ pub(crate) async fn calibrate_results(args: &Args, url: &String) -> Vec<Metadata
)]),
)
.unwrap();

let response_observer: ResponseObserver<AsyncResponse> = ResponseObserver::new();

let response_printer = ResponseProcessor::new(
Expand Down
65 changes: 49 additions & 16 deletions src/utils/decider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use feroxfuzz::observers::{Observers, ResponseObserver};
use feroxfuzz::responses::Response;
use feroxfuzz::state::SharedState;
use feroxfuzz::Metadata;
use feroxfuzz::Named;
use feroxfuzz::AsAny;
use std::any::Any;

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
Expand All @@ -14,16 +16,11 @@ pub(crate) struct MetadataStruct {
pub(crate) lines: usize,
}

#[typetag::serde(name = "metadata")]
impl Metadata for MetadataStruct {
fn is_equal(&self, _other: &dyn Any) -> bool {
false
}
fn as_any(&self) -> &dyn std::any::Any {
impl AsAny for MetadataStruct {
fn as_any(&self) -> &dyn Any {
self
}
}

#[derive(Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct FilterDecider<'a, F>
Expand All @@ -43,19 +40,37 @@ where
}
}

impl<'a, O, R, F> DeciderHooks<O, R> for FilterDecider<'a, F>
impl<'a, F> AsAny for FilterDecider<'a, F>
where
F: Fn(&Args, u16, usize, &SharedState) -> Action + 'static,
{
fn as_any(&self) -> &dyn std::any::Any {
self
}
}

impl<'a, F> Named for FilterDecider<'a, F>
where
F: Fn(&Args, u16, usize, &SharedState) -> Action,
{
fn name(&self) -> &'static str {
"FilterDecider"
}
}

impl<O, R, F> DeciderHooks<O, R> for FilterDecider<'static, F>
where
O: Observers<R>,
R: Response,
F: Fn(&'a Args, u16, usize, &SharedState) -> Action,
R: Response + Sync + Send + Clone,
F: Fn(&'static Args, u16, usize, &SharedState) -> Action + Sync + Send + Clone +'static,
{
}

impl<'a, O, R, F> Decider<O, R> for FilterDecider<'a, F>
where
O: Observers<R>,
R: Response,
F: Fn(&'a Args, u16, usize, &SharedState) -> Action,
R: Response + Sync + Send + Clone,
F: Fn(&'a Args, u16, usize, &SharedState) -> Action + Sync + Send + Clone + 'static,
{
fn decide_with_observers(&mut self, state: &SharedState, observers: &O) -> Option<Action> {
if let Some(observer) = observers.match_name::<ResponseObserver<R>>("ResponseObserver") {
Expand All @@ -81,6 +96,24 @@ where
metadata: &'a Vec<MetadataStruct>,
}

impl<'a, F> Named for CalibrateDecider<'a, F>
where
F: Fn(&'a Vec<MetadataStruct>, usize, usize, usize, &SharedState) -> Action,
{
fn name(&self) -> &'static str {
"CalibrateDecider"
}
}

impl<'a, F> AsAny for CalibrateDecider<'a, F>
where
F: Fn(&'a Vec<MetadataStruct>, usize, usize, usize, &SharedState) -> Action + 'static,
{
fn as_any(&self) -> &dyn std::any::Any {
self
}
}

impl<'a, F> CalibrateDecider<'a, F>
where
F: Fn(&Vec<MetadataStruct>, usize, usize, usize, &SharedState) -> Action,
Expand All @@ -96,16 +129,16 @@ where
impl<'a, O, R, F> DeciderHooks<O, R> for CalibrateDecider<'a, F>
where
O: Observers<R>,
R: Response,
F: Fn(&'a Vec<MetadataStruct>, usize, usize, usize, &SharedState) -> Action,
R: Response + Sync + Send + Clone,
F: Fn(&'a Vec<MetadataStruct>, usize, usize, usize, &SharedState) -> Action + Sync + Send + Clone + 'static,
{
}

impl<'a, O, R, F> Decider<O, R> for CalibrateDecider<'a, F>
where
O: Observers<R>,
R: Response,
F: Fn(&'a Vec<MetadataStruct>, usize, usize, usize, &SharedState) -> Action,
R: Response + Sync + Send + Clone,
F: Fn(&'a Vec<MetadataStruct>, usize, usize, usize, &SharedState) -> Action + Sync + Send + Clone + 'static,
{
fn decide_with_observers(&mut self, state: &SharedState, observers: &O) -> Option<Action> {
if let Some(observer) = observers.match_name::<ResponseObserver<R>>("ResponseObserver") {
Expand Down

0 comments on commit a4b31cb

Please sign in to comment.