Skip to content

Commit

Permalink
fix: missing status in vhostbuster result
Browse files Browse the repository at this point in the history
  • Loading branch information
ps1dr3x committed May 24, 2019
1 parent 0de2a97 commit e035828
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
1 change: 0 additions & 1 deletion src/dirbuster/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ pub mod result_processor;
pub mod utils;

use result_processor::SingleDirScanResult;
use utils::*;

#[derive(Debug, Clone)]
pub struct DirConfig {
Expand Down
39 changes: 24 additions & 15 deletions src/vhostbuster/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ use futures::Stream;
use hyper::{
client::HttpConnector,
rt::{self, Future},
Body, Client, Request, StatusCode, Uri,
Body, Client, Request, StatusCode, Uri
};
use hyper_tls::{self, HttpsConnector};
use native_tls;
use std::sync::mpsc::Sender;

use std::sync::{mpsc::Sender, Arc, Mutex};

pub mod result_processor;
pub mod utils;
Expand All @@ -30,14 +31,17 @@ fn make_request_future(
config: &VhostConfig,
) -> impl Future<Item = (), Error = ()> {
let tx_err = tx.clone();
let mut target = SingleVhostScanResult {
vhost: url.to_string(),
status: StatusCode::default().to_string(),
error: None,
method: config.http_method.clone(),
ignored: false,
};
let mut target_err = target.clone();
let target = Arc::new(Mutex::new(
SingleVhostScanResult {
vhost: url.to_string(),
status: StatusCode::default().to_string(),
error: None,
method: config.http_method.clone(),
ignored: false
}
));
let target_res = target.clone();
let mut target_err = (*target.lock().unwrap()).clone();
let mut request_builder = Request::builder();
let ignore_strings = config.ignore_strings.clone();
let request = request_builder.header("User-Agent", &config.user_agent[..])
Expand All @@ -49,20 +53,25 @@ fn make_request_future(

client
.request(request)
.and_then(|res| {
.and_then(move |res| {
target.lock().unwrap().status = res.status().to_string();
res.into_body().concat2()
})
.and_then(move |_body| {
let vec = _body.iter().cloned().collect();
.and_then(move |body| {
let vec = body.iter().cloned().collect();
let body = String::from_utf8(vec).unwrap();
target.ignored = false;
target_res.lock().unwrap().ignored = false;
for s in ignore_strings {
if body.contains(&s) {
target.ignored = true;
target_res.lock().unwrap().ignored = true;
break;
}
}

let target = Arc::try_unwrap(target_res)
.unwrap()
.into_inner()
.unwrap();
tx.send(target).unwrap();
Ok(())
})
Expand Down

0 comments on commit e035828

Please sign in to comment.