Fix logic when using stdin recirection as input

Fix Probing issue! #9
This commit is contained in:
Eduard Tolosa 2024-03-17 20:49:43 -05:00
parent b0876d0f16
commit 2888858d4e
4 changed files with 694 additions and 571 deletions

1209
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -12,19 +12,14 @@ readme = "README.md"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
tokio = { version = "1.20.1", features = ["full", "io-util"] } tokio = { version = "1.36.0", features = ["full", "io-util"] }
futures = "0.3.23" futures = "0.3.30"
clap = "2.33.4" clap = "2.34.0"
reqwest = { version = "0.11.11", features = ["trust-dns", "rustls-tls", "native-tls"] } reqwest = { version = "0.11.24", features = ["trust-dns", "rustls-tls", "native-tls"] }
openssl = { version = "0.10.41", features = ["vendored"] } openssl = { version = "0.10.64", features = ["vendored"] }
rand = "0.8.5" rand = "0.8.5"
scraper = "0.13.0" scraper = "0.19.0"
async-recursion = "1.0.0" async-recursion = "1.0.5"
# https://github.com/bluejekyll/trust-dns/pull/1632
[patch.crates-io]
trust-dns-resolver = { git = "https://github.com/Findomain/trust-dns", package = "trust-dns-resolver", branch = "custombranch" }
[profile.release] [profile.release]
lto = 'thin' lto = 'thin'

View file

@ -7,7 +7,6 @@ use {
futures::stream::StreamExt, futures::stream::StreamExt,
rand::{distributions::Alphanumeric, thread_rng as rng, Rng}, rand::{distributions::Alphanumeric, thread_rng as rng, Rng},
reqwest::{ reqwest::{
self,
header::{CONTENT_LENGTH, CONTENT_TYPE, USER_AGENT}, header::{CONTENT_LENGTH, CONTENT_TYPE, USER_AGENT},
redirect::Policy, redirect::Policy,
Client, Response, Url, Client, Response, Url,

View file

@ -2,10 +2,7 @@ use {
clap::{value_t, App, Arg}, clap::{value_t, App, Arg},
fhc::{httplib, structs::LibOptions, utils}, fhc::{httplib, structs::LibOptions, utils},
std::collections::HashSet, std::collections::HashSet,
tokio::{ tokio::io::{self, AsyncReadExt},
self,
io::{self, AsyncReadExt},
},
}; };
#[tokio::main] #[tokio::main]
@ -55,6 +52,13 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.takes_value(true) .takes_value(true)
.help("Max number of redirects. Default: 0"), .help("Max number of redirects. Default: 0"),
) )
.arg(
Arg::with_name("bruteforce")
.short("b")
.long("bruteforce")
.takes_value(false)
.help("Bruteforce subdomains."),
)
.arg( .arg(
Arg::with_name("1xx") Arg::with_name("1xx")
.short("1") .short("1")
@ -115,20 +119,24 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = httplib::return_http_client(timeout, max_redirects); let client = httplib::return_http_client(timeout, max_redirects);
// Read stdin
let mut stdin = io::stdin();
let mut buffer = String::new(); let mut buffer = String::new();
stdin.read_to_string(&mut buffer).await?;
let hosts: HashSet<String> = if matches.is_present("domain") { let mut hosts = HashSet::new();
if matches.is_present("domain") {
let domain = value_t!(matches, "domain", String).unwrap(); let domain = value_t!(matches, "domain", String).unwrap();
buffer if matches.is_present("bruteforce") {
.lines() io::stdin().read_to_string(&mut buffer).await?;
.map(|word| format!("{word}.{domain}")) hosts = buffer
.collect() .lines()
.map(|word| format!("{word}.{domain}"))
.collect();
} else {
hosts.insert(domain);
}
} else { } else {
buffer.lines().map(str::to_owned).collect() io::stdin().read_to_string(&mut buffer).await?;
hosts = buffer.lines().map(str::to_owned).collect();
}; };
let lib_options = LibOptions { let lib_options = LibOptions {