use crate::resolver_defaults::default_resolvers;
#[cfg(feature = "speed-test")]
use crate::speed_test::SpeedTester;
use crate::{PacketTransport, QueryType};
use super::{SubdomainBruteConfig, SubdomainBruteEngine, SubdomainResult};
fn with_default_resolvers(resolvers: Option<Vec<String>>) -> Vec<String> {
resolvers.unwrap_or_else(default_resolvers)
}
pub async fn brute_force_subdomains(
domains: Vec<String>,
dictionary_file: Option<String>,
resolvers: Option<Vec<String>>,
skip_wildcard: bool,
bandwidth_limit: Option<String>,
verify_mode: bool,
resolve_records: bool,
silent: bool,
device: Option<String>,
) -> Result<Vec<SubdomainResult>, Box<dyn std::error::Error>> {
let config = SubdomainBruteConfig {
domains,
dictionary_file,
dictionary: None,
resolvers: with_default_resolvers(resolvers),
skip_wildcard,
bandwidth_limit,
verify_mode,
max_retries: 5,
dns_timeout_seconds: 10,
max_wait_seconds: 10,
verify_timeout_seconds: 10,
verify_concurrency: 50,
resolve_records,
cdn_detect: true,
cdn_collapse: true,
query_types: vec![QueryType::A],
silent,
raw_records: false,
device,
transport: PacketTransport::Ethernet,
progress_callback: None,
};
let engine = SubdomainBruteEngine::new(config).await?;
engine.run_brute_force().await
}
pub async fn brute_force_subdomains_with_dict(
domains: Vec<String>,
dictionary: Vec<String>,
resolvers: Option<Vec<String>>,
skip_wildcard: bool,
bandwidth_limit: Option<String>,
verify_mode: bool,
resolve_records: bool,
silent: bool,
device: Option<String>,
) -> Result<Vec<SubdomainResult>, Box<dyn std::error::Error>> {
let config = SubdomainBruteConfig {
domains,
dictionary_file: None,
dictionary: Some(dictionary),
resolvers: with_default_resolvers(resolvers),
skip_wildcard,
bandwidth_limit,
verify_mode,
max_retries: 5,
dns_timeout_seconds: 10,
max_wait_seconds: 10,
verify_timeout_seconds: 10,
verify_concurrency: 50,
resolve_records,
cdn_detect: true,
cdn_collapse: true,
query_types: vec![QueryType::A],
silent,
raw_records: false,
device,
transport: PacketTransport::Ethernet,
progress_callback: None,
};
let engine = SubdomainBruteEngine::new(config).await?;
engine.run_brute_force().await
}
pub async fn brute_force_subdomains_with_config(
domains: Vec<String>,
dictionary_file: Option<String>,
dictionary: Option<Vec<String>>,
resolvers: Option<Vec<String>>,
skip_wildcard: bool,
bandwidth_limit: Option<String>,
verify_mode: bool,
resolve_records: bool,
silent: bool,
device: Option<String>,
) -> Result<Vec<SubdomainResult>, Box<dyn std::error::Error>> {
let config = SubdomainBruteConfig {
domains,
dictionary_file,
dictionary,
resolvers: with_default_resolvers(resolvers),
skip_wildcard,
bandwidth_limit,
verify_mode,
max_retries: 5,
dns_timeout_seconds: 10,
max_wait_seconds: 10,
verify_timeout_seconds: 10,
verify_concurrency: 50,
resolve_records,
cdn_detect: true,
cdn_collapse: true,
query_types: vec![QueryType::A],
silent,
raw_records: false,
device,
transport: PacketTransport::Ethernet,
progress_callback: None,
};
let engine = SubdomainBruteEngine::new(config).await?;
engine.run_brute_force().await
}
#[cfg(feature = "speed-test")]
pub async fn run_speed_test(duration_secs: u64) -> Result<(), Box<dyn std::error::Error>> {
let tester = SpeedTester::new().await?;
let result = tester.run_speed_test(duration_secs).await;
tester.display_result(&result);
Ok(())
}