diff --git a/Cargo.lock b/Cargo.lock index e67d08c..207c27d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -633,7 +633,7 @@ dependencies = [ [[package]] name = "feroxbuster" -version = "2.2.1" +version = "2.2.2" dependencies = [ "anyhow", "assert_cmd", diff --git a/src/event_handlers/command.rs b/src/event_handlers/command.rs index 34fb72e..2be0738 100644 --- a/src/event_handlers/command.rs +++ b/src/event_handlers/command.rs @@ -1,4 +1,3 @@ -use std::collections::HashSet; use std::sync::Arc; use reqwest::StatusCode; @@ -53,7 +52,7 @@ pub enum Command { TryRecursion(Box), /// Send a pointer to the wordlist to the recursion handler - UpdateWordlist(Arc>), + UpdateWordlist(Arc>), /// Instruct the ScanHandler to join on all known scans, use sender to notify main when done JoinTasks(Sender), diff --git a/src/event_handlers/scans.rs b/src/event_handlers/scans.rs index 1b1cc0d..316417c 100644 --- a/src/event_handlers/scans.rs +++ b/src/event_handlers/scans.rs @@ -1,4 +1,3 @@ -use std::collections::HashSet; use std::sync::Arc; use anyhow::{bail, Result}; @@ -54,7 +53,7 @@ pub struct ScanHandler { receiver: CommandReceiver, /// wordlist (re)used for each scan - wordlist: std::sync::Mutex>>>, + wordlist: std::sync::Mutex>>>, /// group of scans that need to be joined tasks: Vec>, @@ -105,7 +104,7 @@ impl ScanHandler { } /// Set the wordlist - fn wordlist(&self, wordlist: Arc>) { + fn wordlist(&self, wordlist: Arc>) { if let Ok(mut guard) = self.wordlist.lock() { if guard.is_none() { let _ = std::mem::replace(&mut *guard, Some(wordlist)); @@ -175,7 +174,7 @@ impl ScanHandler { } /// Helper to easily get the (locked) underlying wordlist - pub fn get_wordlist(&self) -> Result>> { + pub fn get_wordlist(&self) -> Result>> { if let Ok(guard) = self.wordlist.lock().as_ref() { if let Some(list) = guard.as_ref() { return Ok(list.clone()); diff --git a/src/main.rs b/src/main.rs index e71c071..b4d2af0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,4 @@ use std::{ - collections::HashSet, env::args, fs::File, io::{stderr, BufRead, BufReader}, @@ -41,14 +40,14 @@ lazy_static! { } /// Create a HashSet of Strings from the given wordlist then stores it inside an Arc -fn get_unique_words_from_wordlist(path: &str) -> Result>> { +fn get_unique_words_from_wordlist(path: &str) -> Result>> { log::trace!("enter: get_unique_words_from_wordlist({})", path); let file = File::open(&path).with_context(|| format!("Could not open {}", path))?; let reader = BufReader::new(file); - let mut words = HashSet::new(); + let mut words = Vec::new(); for line in reader.lines() { let result = match line { @@ -60,7 +59,7 @@ fn get_unique_words_from_wordlist(path: &str) -> Result>> { continue; } - words.insert(result); + words.push(result); } log::trace!( @@ -78,11 +77,7 @@ async fn scan(targets: Vec, handles: Arc) -> Result<()> { // so that will allow for cheap/safe sharing of a single wordlist across multi-target scans // as well as additional directories found as part of recursion - let words = { - let words_handles = handles.clone(); - tokio::spawn(async move { get_unique_words_from_wordlist(&words_handles.config.wordlist) }) - .await?? - }; + let words = get_unique_words_from_wordlist(&handles.config.wordlist)?; if words.len() == 0 { bail!("Did not find any words in {}", handles.config.wordlist); diff --git a/src/scanner/ferox_scanner.rs b/src/scanner/ferox_scanner.rs index 2b4a88b..8e6b67f 100644 --- a/src/scanner/ferox_scanner.rs +++ b/src/scanner/ferox_scanner.rs @@ -1,4 +1,4 @@ -use std::{collections::HashSet, ops::Deref, sync::atomic::Ordering, sync::Arc, time::Instant}; +use std::{ops::Deref, sync::atomic::Ordering, sync::Arc, time::Instant}; use anyhow::{bail, Result}; use futures::{stream, StreamExt}; @@ -40,7 +40,7 @@ pub struct FeroxScanner { order: ScanOrder, /// wordlist that's already been read from disk - wordlist: Arc>, + wordlist: Arc>, /// limiter that restricts the number of active FeroxScanners scan_limiter: Arc, @@ -52,7 +52,7 @@ impl FeroxScanner { pub fn new( target_url: &str, order: ScanOrder, - wordlist: Arc>, + wordlist: Arc>, scan_limiter: Arc, handles: Arc, ) -> Self {