Skip to content
This repository has been archived by the owner on Jun 22, 2024. It is now read-only.

Commit

Permalink
Sharded the project
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderMaxRanabel committed Jul 21, 2023
1 parent de34250 commit 7d4f962
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 124 deletions.
30 changes: 30 additions & 0 deletions src/discover.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//discover.rs
use std::fs::File;
use std::io::{BufRead, BufReader};
use reqwest;
use colored::*;

pub async fn discover(url: String, wordlist: String) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let file = File::open(wordlist).expect("Failed to open the file.");

// Create a BufReader to read the file efficiently
let reader = BufReader::new(file);

// Iterate over each line in the wordlist
for line in reader.lines() {
if let Ok(word) = line {
let target = url.clone().to_string() + &word.to_string();
let response = reqwest::get(target.clone()).await?;
let status = response.status().to_string();
//let resp = response.json::<HashMap<String, String>>().await?;

let code:Option<&str> = status.split_whitespace().nth(0);
let result = match code {
Some(code) => code.to_string(),
None => String::from("Unknown"),
};
println!("{} {} {}", result.green(), word, target.clone().magenta());
}
}
Ok(())
}
99 changes: 99 additions & 0 deletions src/discover_filter.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
//discover_filter.rs
use std::env;
use std::fs::File;
use std::io::{BufRead, BufReader};
use reqwest;
use colored::*;

pub async fn discover_filter(url: String, wordlist: String, filteree: String, type_fiter: String) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let file = File::open(wordlist).expect("Failed to open the file.");

// Create a BufReader to read the file efficiently
let reader = BufReader::new(file);

// Iterate over each line in the wordlist
for line in reader.lines() {
if let Ok(word) = line {
match type_fiter.as_str() {
"--bycode" => {
let target = url.clone().to_string() + &*word.to_string();
let response = reqwest::get(target.clone()).await?;
let status = response.status().to_string();
//let resp = response.json::<HashMap<String, String>>().await?;

let code:Option<&str> = status.split_whitespace().nth(0);
let result = match code {
Some(code) => code.to_string(),
None => String::from("Unknown"),
};
match filteree.as_str() {
"200" => {
if response.status().is_success() {
println!("{} {} {}", result.green(), word, target.clone().magenta());
}
},
"404" | "401" | "402" | "403" => {
if response.status().is_client_error() {
println!("{} {} {}", result.green(), word, target.clone().magenta());
}
},

"301" | "307" | "302" => {
if response.status().is_redirection() {
println!("{} {} {}", result.green(), word, target.clone().magenta());
}
},

"500" | "502" => {
if response.status().is_server_error() {
println!("{} {} {}", result.green(), word, target.clone().magenta());
}
},
_ => println!("Unknown Status code")
}
},

"--bytype" => {
let target = url.clone().to_string() + &*word.to_string();
let response = reqwest::get(target.clone()).await?;
let status = response.status().to_string();
//let resp = response.json::<HashMap<String, String>>().await?;

let code:Option<&str> = status.split_whitespace().nth(0);
let result = match code {
Some(code) => code.to_string(),
None => String::from("Unknown"),
};
match filteree.as_str() {
"success" => {
if response.status().is_success() {
println!("{} {} {}", result.green(), word, target.clone().magenta());
}
},

"client_error" => {
if response.status().is_client_error() {
println!("{} {} {}", result.green(), word, target.clone().magenta());
}
},

"redirection" => {
if response.status().is_redirection() {
println!("{} {} {}", result.green(), word, target.clone().magenta());
}
},

"server_error" => {
if response.status().is_server_error() {
println!("{} {} {}", result.green(), word, target.clone().magenta());
}
},
_ => println!("Unknown Type")
}
},
_ => println!("Unknown Type")
}
}
}
Ok(())
}
129 changes: 5 additions & 124 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,130 +1,11 @@
mod discover;
mod discover_filter;

use std::env;

use std::fs::File;
use std::io::{BufRead, BufReader};

use reqwest;

use colored::*;

async fn discover(url: String, wordlist: String) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let file = File::open(wordlist).expect("Failed to open the file.");

// Create a BufReader to read the file efficiently
let reader = BufReader::new(file);

// Iterate over each line in the wordlist
for line in reader.lines() {
if let Ok(word) = line {
let target = url.clone().to_string() + &word.to_string();
let response = reqwest::get(target.clone()).await?;
let status = response.status().to_string();
//let resp = response.json::<HashMap<String, String>>().await?;

let code:Option<&str> = status.split_whitespace().nth(0);
let result = match code {
Some(code) => code.to_string(),
None => String::from("Unknown"),
};
println!("{} {} {}", result.green(), word, target.clone().magenta());
}
}
Ok(())
}

async fn discover_filter(url: String, wordlist: String, filteree: String, type_fiter: String) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let file = File::open(wordlist).expect("Failed to open the file.");

// Create a BufReader to read the file efficiently
let reader = BufReader::new(file);

// Iterate over each line in the wordlist
for line in reader.lines() {
if let Ok(word) = line {
match type_fiter.as_str() {
"--bycode" => {
let target = url.clone().to_string() + &*word.to_string();
let response = reqwest::get(target.clone()).await?;
let status = response.status().to_string();
//let resp = response.json::<HashMap<String, String>>().await?;

let code:Option<&str> = status.split_whitespace().nth(0);
let result = match code {
Some(code) => code.to_string(),
None => String::from("Unknown"),
};
match filteree.as_str() {
"200" => {
if response.status().is_success() {
println!("{} {} {}", result.green(), word, target.clone().magenta());
}
},
"404" | "401" | "402" | "403" => {
if response.status().is_client_error() {
println!("{} {} {}", result.green(), word, target.clone().magenta());
}
},

"301" | "307" | "302" => {
if response.status().is_redirection() {
println!("{} {} {}", result.green(), word, target.clone().magenta());
}
},

"500" | "502" => {
if response.status().is_server_error() {
println!("{} {} {}", result.green(), word, target.clone().magenta());
}
},
_ => println!("Unknown Status code")
}
},

"--bytype" => {
let target = url.clone().to_string() + &*word.to_string();
let response = reqwest::get(target.clone()).await?;
let status = response.status().to_string();
//let resp = response.json::<HashMap<String, String>>().await?;

let code:Option<&str> = status.split_whitespace().nth(0);
let result = match code {
Some(code) => code.to_string(),
None => String::from("Unknown"),
};
match filteree.as_str() {
"success" => {
if response.status().is_success() {
println!("{} {} {}", result.green(), word, target.clone().magenta());
}
},

"client_error" => {
if response.status().is_client_error() {
println!("{} {} {}", result.green(), word, target.clone().magenta());
}
},

"redirection" => {
if response.status().is_redirection() {
println!("{} {} {}", result.green(), word, target.clone().magenta());
}
},

"server_error" => {
if response.status().is_server_error() {
println!("{} {} {}", result.green(), word, target.clone().magenta());
}
},
_ => println!("Unknown Type")
}
},
_ => println!("Unknown Type")
}
}
}
Ok(())
}

#[tokio::main]
async fn main() {
let args: Vec<String> = env::args().collect();
Expand All @@ -138,12 +19,12 @@ async fn main() {
let mode = &args[5].to_string();
match mode.as_str() {
"--normal" => {
let _ = tokio::task::spawn(discover(url.clone(), wordlist.clone())).await;
let _ = tokio::task::spawn(discover::discover(url.clone(), wordlist.clone())).await;
},
"--filter" => {
let filteree = &args[7].to_string();
let type_filter = &args[6].to_string();
let _ = tokio::task::spawn(discover_filter(url.clone(),wordlist.clone(), filteree.clone(), type_filter.clone())).await;
let _ = tokio::task::spawn(discover_filter::discover_filter(url.clone(),wordlist.clone(), filteree.clone(), type_filter.clone())).await;
},
_ => println!("Unknown mode")
}
Expand Down

0 comments on commit 7d4f962

Please sign in to comment.