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

Commit

Permalink
F You ChatGPT
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderMaxRanabel committed Jul 31, 2023
1 parent b4ed54b commit b0c9a88
Showing 1 changed file with 74 additions and 37 deletions.
111 changes: 74 additions & 37 deletions src/discover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,51 +6,88 @@ use colored::*;

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

let mut targets: Vec<String> = vec![url];

// 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 mut successful: Vec<String> = Vec::new();
let target = url.clone().to_string() + &word.to_string();
let response = reqwest::get(target.clone()).await?;
let status = response.status().to_string();
let code:Option<&str> = status.split_whitespace().nth(0);
let result = match code {
Some(code) => code.to_string(),
None => String::from("Unknown"),
};
match depth {
0 => {
println!("{} {} {}", result.clone().cyan(), word, target.clone().magenta());
},
1 => {
println!("{} {} {}", result.clone().red(), word, target.clone().magenta());
let mut indicator: i32 = -1;
//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.clone().green(), word, target.clone().magenta());
let mut successful: Vec<String> = vec![];
if response.status().is_success() {
successful.push(target.clone());
indicator += 1;
let new_target = successful[indicator as usize].clone() + "/" + &word;
let new_response = reqwest::get(new_target.clone()).await?;
let new_status = new_response.status().to_string();
let new_code:Option<&str> = new_status.split_whitespace().nth(0);
let new_result = match new_code {
Some(new_code) => new_code.to_string(),
None => String::from("Unknown"),
};
println!("{} {} {} {}",depth.to_string().purple().italic() ,new_result.cyan(), word, new_target.magenta());
} else {
continue;
}
},

for target in &targets {
let new_target = format!("{}/{}", target, word);
let response = reqwest::get(&new_target).await?;
let status = response.status().to_string();
let code = status.split_whitespace().next().unwrap_or("Unknown");
let result = code.to_string();
2 => {
println!("{} {} {}", result.clone().red(), word, target.clone().magenta());
let mut indicator: i32 = -1;
//let resp = response.json::<HashMap<String, String>>().await?;
let mut successful: Vec<String> = vec![];
if response.status().is_success() {
successful.push(target.clone());
indicator += 1;
let new_target = successful[indicator as usize].clone() + "/" + &word;
let new_response = reqwest::get(new_target.clone()).await?;

match depth {
0 => println!("{} {} {}", result.cyan(), word, new_target.magenta()),
1 => {
if response.status().is_success() {
println!("{} {} {}", result.green(), word, new_target.magenta());
successful.push(new_target.clone());
} else {
println!("{} {} {}", result.red(), word, new_target.magenta());
let mut new_successful: Vec<String> = vec![];
let mut new_indicator = -1;
if new_response.status().is_success() {
new_indicator += 1;
new_successful.push(new_target.clone());
let newest_target = new_successful[new_indicator as usize].clone() + "/" + &word;
let newest_response = reqwest::get(newest_target.clone()).await?;
let newest_status = newest_response.status().to_string();
let newest_code:Option<&str> = newest_status.split_whitespace().nth(0);
let newest_result = match newest_code {
Some(newest_code) => newest_code.to_string(),
None => String::from("Unknown"),
};
println!("{} {} {} {}", depth.to_string().purple().italic() ,newest_result.cyan(), word, newest_target.magenta());
}
},
2 => {
if response.status().is_success() {
println!("{} {} {}", result.green(), word, new_target.magenta());
successful.push(new_target.clone());
} else {
println!("{} {} {}", result.red(), word, new_target.magenta());
}
},
_ => {
println!("Unknown Depth");
std::process::exit(1)
} else {
continue;
}
},
_ => {
println!("Unknown Depth");
std::process::exit(1)
}
}

if depth >= 1 {
targets = successful;
}
}
}

};
Ok(())
}
}//will be optimized. deal with it lmao

0 comments on commit b0c9a88

Please sign in to comment.