Skip to content

Instantly share code, notes, and snippets.

@MindPatch
Last active December 9, 2021 18:23
Show Gist options
  • Save MindPatch/9a08a48f9d3d6bd000bb000b7760f979 to your computer and use it in GitHub Desktop.
Save MindPatch/9a08a48f9d3d6bd000bb000b7760f979 to your computer and use it in GitHub Desktop.
example rust
mod args;
mod requester;
use crate::requester::*;
use crate::args::args;
use serde_json::json;
use indicatif::{ProgressStyle,ProgressBar};
use scoped_threadpool::Pool;
use std::{
fs::File,
io::{
BufRead,
BufReader
}
};
fn main() {
let the_args = args();
let mut pool = Pool::new(the_args.value_of("threads").unwrap().parse().unwrap());
let urls = File::open(the_args.value_of("targets").unwrap().to_string()).expect("file not found!");
let _reader = BufReader::new(urls);
let _requester = Requester {
timeout:the_args.value_of("timeout").unwrap().parse().unwrap(),
proxy:the_args.value_of("proxy").unwrap().to_string(),
headers:extractheaders(the_args.value_of("headers").unwrap()),
}.build();
let params = convert_vec( BufReader::new(File::open(the_args.value_of("wordlist").unwrap()).expect("file not found ")) );
let urls = convert_vec(_reader);
let bar = ProgressBar::new(params.len() as u64 + urls.len() as u64 * 4 * 2 );
bar.set_style(ProgressStyle::default_bar()
.template("[{elapsed_precise}] {bar:40.cyan/blue} {pos:>7}/{len:7} {msg}")
.progress_chars("##-"));
pool.scoped(|scope|{
for _url in urls {
let _urls = add_parameters(_url.to_string(),the_args.value_of("host").unwrap(),params.clone());
for url in _urls {
scope.execute(|| {
match _requester.get(url.clone().as_str()) {
Ok(_done) => {bar.inc(1)},
Err(_e) => {println!("[Err] {:?}",_e)}
}
println!("URL : {:?}",url);
match _requester.post("http://google.com/","testing=3") {
// send POST http request just for testing :D
Ok(_done) => {bar.inc(1)},
Err(_e) => {println!("[Err] {:?}",_e)}
}
});
}
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment