Skip to content

Commit

Permalink
added urlencode support
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcbax committed Apr 23, 2021
1 parent 0017bd1 commit cf2367b
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 24 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "aap"
version = "0.1.1"
version = "0.2.1"
authors = ["Chad Baxter <cbax@doslabelectronics.com>"]
edition = "2018"
description = "Saturate the bad guys' databases."
Expand Down
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,25 @@ You can use the ActiveAntiPhish command line application by compiling it with th
## `aap` Help

```
ActiveAntiPhish 0.1.1 GNU-GPL-3.0
ActiveAntiPhish 0.2.1 GNU-GPL-3.0
Chad Baxter <cbax@doslabelectronics.com>
Saturate the bad guys' databases.
USAGE:
aap [FLAGS] [OPTIONS] --time <run_time> --threads <threads> --url <url>
FLAGS:
-g, --debug Locks application to one thread and displays HTTP response data.
-h, --help Prints help information
-V, --version Prints version information
-g, --debug Locks application to one thread and displays HTTP response data.
-h, --help Prints help information
-m, --multipart The form uses multipart data.
-w, --urlencoded The form uses www-urlencoded data.
-V, --version Prints version information
OPTIONS:
-c, --ccn <ccn_field> The form field where a credit card number should be populated.
-v, --cvv <cvv_field> The form field where a credit card verification value should be populated.
-d, --domain <domain> The domain of the email server associated with your organization (otherwise random domains will be used). For example: example.com or mail.example.com
-d, --domain <domain> The domain of the email server associated with your organization (otherwise random
domains will be used). For example: example.com or mail.example.com
-e, --email <email_field> The form field where an email should be populated.
-x, --exp <exp_field> The form field where a credit card expiration date should be populated.
-f, --fname <first_name_field> The form field where a first name should be populated.
Expand Down
45 changes: 43 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,33 @@ fn main() {
.multiple(false)
.required(true)
)
.arg(
Arg::with_name("multipart")
.help("The form uses multipart data.")
.short("-m")
.long("--multipart")
.takes_value(false)
.multiple(false)
.required(false)
)
.arg(
Arg::with_name("urlencoded")
.help("The form uses www-urlencoded data.")
.short("-w")
.long("--urlencoded")
.takes_value(false)
.multiple(false)
.required(false)
)
.arg(
Arg::with_name("url")
.help("The path to the endpoint to POST fake data to.")
.short("-u")
.long("--url")
.takes_value(true)
.multiple(false)
.required(true)
)
.arg(
Arg::with_name("domain")
.help("The domain of the email server associated with your organization (otherwise random domains will be used). For example: example.com or mail.example.com")
Expand Down Expand Up @@ -209,10 +236,24 @@ fn main() {
}
};

let mut form_type: u8 = 0;
if matches.is_present("multipart") {
form_type = form_type + 1;
}
if matches.is_present("urlencoded") {
form_type = form_type + 1;
}

if form_type == 0 {
eprintln!("Must specify either URLEncoded or Multipart for form data format.");
std::process::exit(1);
}


if matches.is_present("debug") {
execute(fields, url, domain, 1, true);
execute(form_type, fields, url, domain, 1, true);
} else {
execute(fields, url, domain, threads, false);
execute(form_type, fields, url, domain, threads, false);
}
std::thread::sleep(std::time::Duration::from_secs(sleep));
}
43 changes: 39 additions & 4 deletions src/request_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::types::{PostFields, PostData};

use reqwest::blocking::*;

pub fn build_form(fields: PostFields, data: PostData) -> multipart::Form {
pub fn build_form_multipart(fields: PostFields, data: PostData) -> multipart::Form {
let mut form = multipart::Form::new();
if fields.email.is_some() & data.email.is_some() {
form = form.text(fields.email.unwrap().to_string(), data.email.unwrap());
Expand Down Expand Up @@ -31,7 +31,42 @@ pub fn build_form(fields: PostFields, data: PostData) -> multipart::Form {
return form;
}

pub fn build_request(form: multipart::Form, url: String) -> Request {
let client = reqwest::blocking::Client::builder().user_agent(fakeit::user_agent::random_platform()).build().unwrap();
return client.post(url).multipart(form).build().unwrap();
pub fn build_form_urlencoded(fields: PostFields, data: PostData) -> std::collections::HashMap<String, String> {
let mut form: std::collections::HashMap<String, String> = std::collections::HashMap::new();

if fields.email.is_some() & data.email.is_some() {
form.insert(fields.email.unwrap().to_string(), data.email.unwrap());
}
if fields.password.is_some() & data.password.is_some() {
form.insert(fields.password.unwrap().to_string(), data.password.unwrap());
}
if fields.phone.is_some() & data.phone.is_some() {
form.insert(fields.phone.unwrap().to_string(), data.phone.unwrap());
}
if fields.fname.is_some() & data.fname.is_some() {
form.insert(fields.fname.unwrap().to_string(), data.fname.unwrap());
}
if fields.lname.is_some() & data.lname.is_some() {
form.insert(fields.lname.unwrap().to_string(), data.lname.unwrap());
}
if fields.ccn.is_some() & data.ccn.is_some() {
form.insert(fields.ccn.unwrap().to_string(), data.ccn.unwrap());
}
if fields.exp.is_some() & data.exp.is_some() {
form.insert(fields.exp.unwrap().to_string(), data.exp.unwrap());
}
if fields.cvv.is_some() & data.cvv.is_some() {
form.insert(fields.cvv.unwrap().to_string(), data.cvv.unwrap());
}
return form;
}

pub fn build_request(multipart: Option<multipart::Form>, urlencoded: Option<std::collections::HashMap<String, String>>, url: String) -> Request {
if multipart.is_some() {
let client = reqwest::blocking::Client::builder().user_agent(fakeit::user_agent::random_platform()).build().unwrap();
return client.post(url).multipart(multipart.unwrap()).build().unwrap();
} else {
let client = reqwest::blocking::Client::builder().user_agent(fakeit::user_agent::random_platform()).build().unwrap();
return client.post(url).form(&urlencoded.unwrap()).build().unwrap();
}
}
43 changes: 32 additions & 11 deletions src/thread_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,52 @@ use crate::generator::*;

use std::io::Write;

pub fn execute(fields: PostFields, url: String, domain: String, threads: u64, debug: bool) {
pub fn execute(form_type: u8, fields: PostFields, url: String, domain: String, threads: u64, debug: bool) {
for _ in 0..threads {
let fields_clone = fields.clone();
let domain_clone = domain.clone();
let url_clone = url.clone();
let debug_clone = debug.clone();
let form_type_clone = form_type.clone();
std::thread::spawn(move || {
loop {
let domain_clone1 = domain_clone.clone();
let url_clone1 = url_clone.clone();
let fields_clone1 = fields_clone.clone();
let fields_clone2 = fields_clone.clone();
let debug_clone1 = debug_clone.clone();
let form_type_clone1 = form_type_clone.clone();
let client = reqwest::blocking::Client::builder().redirect(reqwest::redirect::Policy::none()).build().unwrap();
let response = match client.execute(
build_request(
build_form(
fields_clone1,
generate_from_fields(
fields_clone2,
domain_clone1
)
),
url_clone1
)
if form_type_clone1 == 1 {
build_request(
Some(
build_form_multipart(
fields_clone1,
generate_from_fields(
fields_clone2,
domain_clone1
)
)
),
None,
url_clone1
)
} else {
build_request(
None,
Some(
build_form_urlencoded(
fields_clone1,
generate_from_fields(
fields_clone2,
domain_clone1
)
)
),
url_clone1
)
}
) {
Ok(o) => Some(o),
Err(e) => {
Expand Down

0 comments on commit cf2367b

Please sign in to comment.