Skip to content

Commit

Permalink
Fix merge bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Sh1Yo committed Apr 28, 2022
1 parent 8e24f75 commit f3bfd68
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 16 deletions.
4 changes: 1 addition & 3 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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")
Expand Down
16 changes: 4 additions & 12 deletions src/requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -316,14 +316,6 @@ pub async fn request(
text.push_str(&"\n\n");
text.push_str(&body);

let mut reflected_params: Vec<String> = 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,
Expand Down
2 changes: 1 addition & 1 deletion src/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ impl DefaultResponse for ResponseData {
ResponseData {
text: String::new(),
code: 0u16,
reflected_params: vec![],
reflected_params: HashMap::new(),
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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('{') )
Expand Down

0 comments on commit f3bfd68

Please sign in to comment.