Skip to content

Commit c8f5561

Browse files
committed
Update dependencies
1 parent 9dbc52f commit c8f5561

File tree

16 files changed

+275
-356
lines changed

16 files changed

+275
-356
lines changed

Cargo.toml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,33 @@ categories = ["network-programming"]
1313
license = "MIT"
1414

1515
[dependencies]
16+
anyhow = { version = "1" }
1617
serde = { version = "1", features = ["derive"] }
1718
serde_json = "1"
18-
netdev = { version = "0.30", features = ["serde"] }
19-
nex = { version = "0.18", features = ["serde"] }
20-
nex-socket = { version = "0.18", features = ["tls"] }
21-
privilege = "0.3"
22-
async-io = "2.3"
23-
futures-lite = "2.3"
19+
netdev = { version = "0.34", features = ["serde"] }
20+
nex = { version = "0.19.1", features = ["serde"] }
2421
futures = {version = "0.3", features = ["executor", "thread-pool"]}
22+
rustls = { version = "0.23", default-features = false, features = ["ring", "std"] }
23+
rustls-native-certs = "0.7"
24+
rustls-pemfile = "2.1"
25+
rustls-pki-types = "1.8"
2526
tokio = { version = "1" }
27+
tokio-rustls = { version = "0.26", default-features = false, features = ["ring"]}
2628
hickory-resolver = { version = "0.24" }
2729
chrono = { version = "0.4", features = ["serde"] }
28-
uuid = { version = "1.3", features = ["v4","v5","fast-rng","macro-diagnostics"] }
30+
uuid = { version = "1.16", features = ["v4","v5","fast-rng","macro-diagnostics"] }
2931
bincode = "1.3"
3032
phf = { version = "0.11", features = ["macros"] }
3133
rand = "0.8"
32-
clap = { version = "4.4", features = ["cargo"] }
33-
indicatif = "0.16"
34-
inquire = "0.6"
35-
ipnet = "2.7"
34+
clap = { version = "4.5", features = ["cargo"] }
35+
indicatif = "0.17"
36+
inquire = "0.7"
37+
ipnet = "2.11"
3638
num_cpus = "1.16"
3739
termtree = "0.5"
3840

3941
[target.'cfg(windows)'.dependencies]
40-
winreg = "0.52"
42+
winreg = "0.55"
4143

4244
# The profile that 'cargo dist' will build with
4345
[profile.dist]

src/dns/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
pub mod domain;
22
pub mod result;
33
pub mod scanner;
4-
pub mod setting;
54
use std::net::IpAddr;
65
use std::time::Duration;
76

src/dns/scanner.rs

Lines changed: 16 additions & 208 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,7 @@ use tokio::time::timeout;
1111
use hickory_resolver::config::{ResolverConfig, ResolverOpts};
1212
use hickory_resolver::AsyncResolver;
1313

14-
use super::setting::DEFAULT_USER_AGENT_FIREFOX;
15-
#[cfg(feature = "passive")]
16-
use crate::config::URL_CRT;
17-
#[cfg(feature = "passive")]
18-
use crate::model::CertEntry;
1914
use crate::scan::result::ScanStatus;
20-
#[cfg(feature = "passive")]
21-
use reqwest::Url;
2215

2316
/// Structure for domain scan
2417
///
@@ -41,10 +34,6 @@ pub struct DomainScanner {
4134
tx: Arc<Mutex<Sender<String>>>,
4235
/// Receiver for progress messaging
4336
rx: Arc<Mutex<Receiver<String>>>,
44-
/// Run passive scan
45-
pub passive: bool,
46-
/// User-Agent for passive scan
47-
user_agent: String,
4837
}
4938

5039
impl DomainScanner {
@@ -60,8 +49,6 @@ impl DomainScanner {
6049
scan_result: DomainScanResult::new(),
6150
tx: Arc::new(Mutex::new(tx)),
6251
rx: Arc::new(Mutex::new(rx)),
63-
passive: false,
64-
user_agent: DEFAULT_USER_AGENT_FIREFOX.to_string(),
6552
};
6653
Ok(domain_scanner)
6754
}
@@ -84,69 +71,31 @@ impl DomainScanner {
8471
pub fn set_timeout(&mut self, timeout: Duration) {
8572
self.timeout = timeout;
8673
}
87-
/// Set active/passive scan (default is active)
88-
pub fn set_passive(&mut self, passive: bool) {
89-
self.passive = passive;
90-
}
91-
/// Set user-agent for passive scan
92-
pub fn set_user_agent(&mut self, user_agent: String) {
93-
self.user_agent = user_agent;
94-
}
9574
async fn scan_domain(&self) -> Result<Vec<Domain>, ()> {
96-
if self.passive {
97-
#[cfg(feature = "passive")]
98-
match timeout(
99-
self.timeout,
100-
scan_subdomain_passive(
101-
self.base_domain.clone(),
102-
&self.tx,
103-
self.resolve_timeout,
104-
self.concurrent_limit,
105-
self.user_agent.clone(),
106-
),
107-
)
108-
.await
109-
{
110-
Ok(domains) => {
111-
return Ok(domains);
112-
}
113-
Err(_) => {
114-
return Err(());
115-
}
75+
match timeout(
76+
self.timeout,
77+
scan_subdomain(
78+
self.base_domain.clone(),
79+
self.word_list.clone(),
80+
&self.tx,
81+
self.resolve_timeout,
82+
self.concurrent_limit,
83+
),
84+
)
85+
.await
86+
{
87+
Ok(domains) => {
88+
return Ok(domains);
11689
}
117-
#[cfg(not(feature = "passive"))]
118-
return Err(());
119-
} else {
120-
match timeout(
121-
self.timeout,
122-
scan_subdomain(
123-
self.base_domain.clone(),
124-
self.word_list.clone(),
125-
&self.tx,
126-
self.resolve_timeout,
127-
self.concurrent_limit,
128-
),
129-
)
130-
.await
131-
{
132-
Ok(domains) => {
133-
return Ok(domains);
134-
}
135-
Err(_) => {
136-
return Err(());
137-
}
90+
Err(_) => {
91+
return Err(());
13892
}
13993
}
14094
}
14195
/// Run scan with current settings.
14296
///
14397
/// Results are stored in DomainScanner::scan_result
14498
pub async fn run_scan(&mut self) {
145-
if self.passive && cfg!(not(feature = "passive")) {
146-
self.scan_result.scan_status =
147-
ScanStatus::Error(String::from("Passive scan not supported"));
148-
return;
149-
}
15099
let start_time = Instant::now();
151100
let res = self.scan_domain().await;
152101
match res {
@@ -190,7 +139,6 @@ async fn resolve_domain(host_name: String) -> Vec<IpAddr> {
190139
ips
191140
}
192141

193-
#[cfg(feature = "async")]
194142
#[cfg(not(any(unix, target_os = "windows")))]
195143
async fn resolve_domain(host_name: String) -> Vec<IpAddr> {
196144
let mut ips: Vec<IpAddr> = vec![];
@@ -207,25 +155,6 @@ async fn resolve_domain(host_name: String) -> Vec<IpAddr> {
207155
ips
208156
}
209157

210-
#[cfg(feature = "passive")]
211-
fn extract_domain(target: String) -> String {
212-
let mut domain_name: String = target;
213-
match domain_name.strip_prefix("*.") {
214-
Some(d) => {
215-
domain_name = d.to_string();
216-
}
217-
None => {}
218-
}
219-
domain_name
220-
}
221-
222-
#[cfg(feature = "passive")]
223-
fn is_subdomain(domain: String, apex_domain: String) -> bool {
224-
domain.contains(&apex_domain)
225-
&& domain.ends_with(&apex_domain)
226-
&& domain.len() > apex_domain.len()
227-
}
228-
229158
async fn scan_subdomain(
230159
base_domain: String,
231160
word_list: Vec<String>,
@@ -279,124 +208,3 @@ async fn scan_subdomain(
279208
}
280209
result
281210
}
282-
283-
#[cfg(feature = "passive")]
284-
async fn scan_subdomain_passive(
285-
base_domain: String,
286-
ptx: &Arc<Mutex<Sender<String>>>,
287-
resolve_timeout: Duration,
288-
concurrent_limit: usize,
289-
user_agent: String,
290-
) -> Vec<Domain> {
291-
let mut result: Vec<Domain> = vec![];
292-
let scan_results: Arc<Mutex<Vec<Domain>>> = Arc::new(Mutex::new(vec![]));
293-
let mut certs: Vec<CertEntry> = vec![];
294-
//"https://crt.sh/?dNSName=example.com&output=json"
295-
let url = match Url::parse_with_params(
296-
URL_CRT,
297-
&[
298-
("dNSName", base_domain.clone().as_str()),
299-
("output", "json"),
300-
],
301-
) {
302-
Ok(url) => url,
303-
Err(e) => {
304-
println!("{}", e);
305-
return result;
306-
}
307-
};
308-
let client = reqwest::Client::builder()
309-
.timeout(Duration::from_secs(60))
310-
.build()
311-
.expect("failed to build HTTP reqest client");
312-
let res = client
313-
.get(url)
314-
.header(reqwest::header::USER_AGENT, user_agent)
315-
.send()
316-
.await;
317-
match res {
318-
Ok(r) => {
319-
if r.status().is_success() {
320-
match r.text().await {
321-
Ok(res_text) => {
322-
let certs_json: serde_json::Value = serde_json::from_str(res_text.as_str())
323-
.unwrap_or(serde_json::json!({}));
324-
if certs_json.is_array() {
325-
let cert_array = certs_json.as_array().unwrap();
326-
for cert in cert_array {
327-
match serde_json::to_string(cert) {
328-
Ok(cert) => {
329-
let cert: CertEntry =
330-
match serde_json::from_str(cert.as_str()) {
331-
Ok(cert) => cert,
332-
Err(_) => continue,
333-
};
334-
certs.push(cert);
335-
}
336-
Err(_) => {}
337-
}
338-
}
339-
}
340-
}
341-
Err(_) => {}
342-
};
343-
}
344-
}
345-
Err(_) => {}
346-
}
347-
let mut target_domains: Vec<String> = vec![];
348-
for cert in certs {
349-
let domain_name: String = extract_domain(cert.common_name);
350-
if is_subdomain(domain_name.clone(), base_domain.clone())
351-
&& !target_domains.contains(&domain_name)
352-
{
353-
target_domains.push(domain_name);
354-
}
355-
let name_values: Vec<&str> = cert.name_value.trim().split("\n").collect();
356-
for value in name_values {
357-
let name: String = extract_domain(value.to_string());
358-
if is_subdomain(name.clone(), base_domain.clone()) && !target_domains.contains(&name) {
359-
target_domains.push(name);
360-
}
361-
}
362-
}
363-
let results = stream::iter(target_domains)
364-
.map(|domain| async move {
365-
let mut d: Domain = Domain {
366-
domain_name: domain.clone(),
367-
ips: vec![],
368-
};
369-
match timeout(resolve_timeout, resolve_domain(domain.clone())).await {
370-
Ok(ips) => {
371-
d.ips = ips;
372-
match ptx.lock() {
373-
Ok(lr) => match lr.send(domain) {
374-
Ok(_) => {}
375-
Err(_) => {}
376-
},
377-
Err(_) => {}
378-
}
379-
}
380-
Err(_) => match ptx.lock() {
381-
Ok(lr) => match lr.send(domain) {
382-
Ok(_) => {}
383-
Err(_) => {}
384-
},
385-
Err(_) => {}
386-
},
387-
}
388-
d
389-
})
390-
.buffer_unordered(concurrent_limit);
391-
results
392-
.for_each(|domain| async {
393-
if domain.ips.len() > 0 {
394-
scan_results.lock().unwrap().push(domain);
395-
}
396-
})
397-
.await;
398-
for domain in scan_results.lock().unwrap().iter() {
399-
result.push(domain.to_owned());
400-
}
401-
result
402-
}

src/dns/setting.rs

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/handler/dns.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ pub fn handle_subdomain_scan(args: &ArgMatches) {
7373
if crate::app::is_quiet_mode() {
7474
bar.set_draw_target(ProgressDrawTarget::hidden());
7575
}
76-
bar.enable_steady_tick(120);
76+
bar.enable_steady_tick(Duration::from_millis(120));
7777
bar.set_style(output::get_progress_style());
7878
bar.set_position(0);
7979
bar.set_message("SubdomainScan");

src/handler/interface.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,13 @@ pub fn show_interface_tree(iface: &Interface) {
8686
));
8787
let mut ipv4_tree = Tree::new(node_label("IPv4 Addresses", None, None));
8888
for ipv4 in &iface.ipv4 {
89-
ipv4_tree.push(node_label(&ipv4.addr.to_string(), None, None));
89+
ipv4_tree.push(node_label(&ipv4.addr().to_string(), None, None));
9090
}
9191
tree.push(ipv4_tree);
9292

9393
let mut ipv6_tree = Tree::new(node_label("IPv6 Addresses", None, None));
9494
for ipv6 in &iface.ipv6 {
95-
ipv6_tree.push(node_label(&ipv6.addr.to_string(), None, None));
95+
ipv6_tree.push(node_label(&ipv6.addr().to_string(), None, None));
9696
}
9797
tree.push(ipv6_tree);
9898

@@ -142,13 +142,13 @@ pub fn show_interfaces_tree(interfaces: &Vec<Interface>) {
142142
));
143143
let mut ipv4_tree = Tree::new(node_label("IPv4 Addresses", None, None));
144144
for ipv4 in &iface.ipv4 {
145-
ipv4_tree.push(node_label(&ipv4.addr.to_string(), None, None));
145+
ipv4_tree.push(node_label(&ipv4.addr().to_string(), None, None));
146146
}
147147
iface_tree.push(ipv4_tree);
148148

149149
let mut ipv6_tree = Tree::new(node_label("IPv6 Addresses", None, None));
150150
for ipv6 in &iface.ipv6 {
151-
ipv6_tree.push(node_label(&ipv6.addr.to_string(), None, None));
151+
ipv6_tree.push(node_label(&ipv6.addr().to_string(), None, None));
152152
}
153153
iface_tree.push(ipv6_tree);
154154

src/handler/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ pub fn default_probe(target_host: &str, args: &ArgMatches) {
140140
if crate::app::is_quiet_mode() {
141141
bar.set_draw_target(ProgressDrawTarget::hidden());
142142
}
143-
bar.enable_steady_tick(120);
143+
bar.enable_steady_tick(Duration::from_millis(120));
144144
bar.set_style(output::get_progress_style());
145145
bar.set_position(0);
146146
bar.set_message("ServiceDetection");

src/handler/port.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ pub fn handle_portscan(args: &ArgMatches) {
182182
if crate::app::is_quiet_mode() {
183183
bar.set_draw_target(ProgressDrawTarget::hidden());
184184
}
185-
bar.enable_steady_tick(120);
185+
bar.enable_steady_tick(Duration::from_millis(120));
186186
bar.set_style(output::get_progress_style());
187187
bar.set_position(0);
188188
bar.set_message("ServiceDetection");

0 commit comments

Comments
 (0)