From f3bfd68e8b327b1e447ebb4d370ad86ff1be1193 Mon Sep 17 00:00:00 2001 From: Alexander Mironov Date: Thu, 28 Apr 2022 21:24:12 +0300 Subject: [PATCH] Fix merge bugs --- src/args.rs | 4 +--- src/requests.rs | 16 ++++------------ src/structs.rs | 2 +- src/utils.rs | 1 + 4 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/args.rs b/src/args.rs index f096ee2..257ab80 100644 --- a/src/args.rs +++ b/src/args.rs @@ -59,8 +59,7 @@ pub fn get_config() -> (Config, usize) { Arg::with_name("body-type") .short("t") .long("body-type") - .help("Available: urlencode, json\nCan be detected automatically if --body is specified") - .default_value("urlencode") + .help("Available: urlencode, json\nCan be detected automatically if --body is specified (default is \"urlencode\")") .value_name("body type") ) .arg( @@ -105,7 +104,6 @@ pub fn get_config() -> (Config, usize) { .help("Available: GET, POST, PUT, PATCH, DELETE, HEAD.") .default_value("GET") .takes_value(true) - .conflicts_with("request") ) .arg( Arg::with_name("headers") diff --git a/src/requests.rs b/src/requests.rs index 0d6336f..18c4802 100644 --- a/src/requests.rs +++ b/src/requests.rs @@ -243,21 +243,21 @@ pub async fn request( stats.amount_of_requests += 1; match create_request(config, random_query.clone(), &hashmap_query, client).send().await { - Ok(_) => return ResponseData { + Ok(_) => return Some(ResponseData { text: String::new(), code: 0, reflected_params: HashMap::new(), - }, + }), Err(err) => { writeln!(io::stderr(), "[!] {} {:?}", url, err).ok(); writeln!(io::stderr(), "[~] error at the {} observed. Wait 50 sec and repeat.", config.url).ok(); std::thread::sleep(Duration::from_secs(50)); match create_request(config, random_query, &hashmap_query, client).send().await { - Ok(_) => return ResponseData { + Ok(_) => return Some(ResponseData { text: String::new(), code: 0, reflected_params: HashMap::new(), - }, + }), Err(_) => { writeln!(io::stderr(), "[!] unable to reach {}", config.url).ok(); std::process::exit(1); @@ -316,14 +316,6 @@ pub async fn request( text.push_str(&"\n\n"); text.push_str(&body); - let mut reflected_params: Vec = Vec::new(); - - for (key, value) in initial_query.iter() { - if value.contains("%random%_") && text.to_ascii_lowercase().matches(&value.replace("%random%_", "").as_str()).count() as usize != reflections { - reflected_params.push(key.to_string()); - } - } - Some(ResponseData { text, code, diff --git a/src/structs.rs b/src/structs.rs index 99fbb6b..e28081d 100644 --- a/src/structs.rs +++ b/src/structs.rs @@ -16,7 +16,7 @@ impl DefaultResponse for ResponseData { ResponseData { text: String::new(), code: 0u16, - reflected_params: vec![], + reflected_params: HashMap::new(), } } } diff --git a/src/utils.rs b/src/utils.rs index 419bf27..c71a398 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -367,6 +367,7 @@ pub fn parse_request(config: Config, proto: &str, request: &str, custom_paramete } //check whether the body type can be json + //TODO check whether can be combined with the same check in args.rs let body_type = if config.body_type.contains('-') && config.as_body && !custom_parameter_template && ( content_type.contains("json") || (!body.is_empty() && body.starts_with('{') )