fixed url importing to make sure // doesn't occur for sub dirs.

This commit is contained in:
2026-05-18 13:19:41 -05:00
parent 0ea3ddea2b
commit 7f8432bda6
2 changed files with 12 additions and 7 deletions
-1
View File
@@ -13,4 +13,3 @@ indicatif = "0.18.4"
reqwest = { version = "0.12.4", features = ["blocking"] } reqwest = { version = "0.12.4", features = ["blocking"] }
tokio = { version = "1.52.3", features = ["full"] } tokio = { version = "1.52.3", features = ["full"] }
trust-dns-resolver = "0.23.2" trust-dns-resolver = "0.23.2"
urlencoding = "2.1.3"
+12 -6
View File
@@ -12,7 +12,6 @@ use std::sync::Arc;
use std::{collections::HashMap, fs}; use std::{collections::HashMap, fs};
use tokio::sync::mpsc::{channel, Sender}; use tokio::sync::mpsc::{channel, Sender};
use trust_dns_resolver::{config::*, TokioAsyncResolver}; use trust_dns_resolver::{config::*, TokioAsyncResolver};
use urlencoding::encode;
enum OutputMessage { enum OutputMessage {
UrlResult(String), UrlResult(String),
@@ -102,20 +101,20 @@ async fn try_sub(
} }
async fn try_dir(url: String, tx: Sender<OutputMessage>, output: bool, pb: Arc<ProgressBar>) { async fn try_dir(url: String, tx: Sender<OutputMessage>, output: bool, pb: Arc<ProgressBar>) {
let resp_stat = reqwest::get(&encode(&url).to_string()).await; let resp_stat = reqwest::get(&url).await;
if resp_stat.is_ok() { if resp_stat.is_ok() {
let resp = resp_stat.unwrap().status(); let resp = resp_stat.unwrap().status();
match resp { match resp {
StatusCode::OK => { StatusCode::OK => {
if output { if output {
if let Err(e) = tx if let Err(e) = tx
.send(OutputMessage::UrlResult(format!("{} {}", resp, url))) .send(OutputMessage::UrlResult(format!("{} {}", resp, &url)))
.await .await
{ {
eprintln!("error sending output! {}", e); eprintln!("error sending output! {}", e);
} }
} }
pb.println(&format!("{} {}", resp, url)); pb.println(&format!("{} {}", resp, &url));
} }
StatusCode::ACCEPTED => { StatusCode::ACCEPTED => {
if output { if output {
@@ -170,7 +169,10 @@ async fn try_dir(url: String, tx: Sender<OutputMessage>, output: bool, pb: Arc<P
eprintln!("error sending output! {}", e); eprintln!("error sending output! {}", e);
} }
} }
pb.println(&format!("{} {}", resp, url)); pb.println(&format!(
"{} {} - and what a beautiful teapot you are!",
resp, url
));
} }
StatusCode::MOVED_PERMANENTLY => { StatusCode::MOVED_PERMANENTLY => {
if output { if output {
@@ -354,7 +356,11 @@ async fn main() {
for dir in dirwordlist.split("\n").collect::<Vec<&str>>() { for dir in dirwordlist.split("\n").collect::<Vec<&str>>() {
for target in &targets { for target in &targets {
if target.contains("http") { if target.contains("http") {
dirs_to_try.push(format!("{}/{}", target, dir.trim())); if dir.starts_with("/") || target.ends_with("/") {
dirs_to_try.push(format!("{}{}", target, dir.trim()));
} else {
dirs_to_try.push(format!("{}/{}", target, dir.trim()));
}
} }
} }
} }