-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmain.rs
84 lines (67 loc) · 2.07 KB
/
main.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
use clap::{App, Arg};
use colored::*;
use tokio::sync::mpsc;
use twistrs::enrich::DomainMetadata;
use twistrs::permutate::{Domain, Permutation};
use anyhow::Result;
use std::collections::HashSet;
use std::time::Instant;
#[tokio::main]
async fn main() -> Result<()> {
let start_time = Instant::now();
let matches = App::new("twistrs-cli")
.version("0.1.0")
.author("Juxhin D. Brigjaj <[email protected]>")
.arg(Arg::new("domain").required(true))
.get_matches();
let domain = Domain::new(matches.value_of("domain").unwrap()).unwrap();
let domain_permutations = domain.all()?.collect::<HashSet<Permutation>>();
let domain_permutation_count = domain_permutations.len();
let (tx, mut rx) = mpsc::channel(5000);
for (i, v) in domain_permutations.into_iter().enumerate() {
let domain_metadata = DomainMetadata::new(v.domain.fqdn.clone());
let mut tx = tx.clone();
tokio::spawn(async move {
if tx
.send((i, v.clone(), domain_metadata.dns_resolvable().await))
.await
.is_err()
{
println!("received dropped");
return;
}
drop(tx);
});
}
drop(tx);
let mut enumeration_count = 0;
while let Some(i) = rx.recv().await {
if let Ok(v) = i.2 {
if v.ips.is_some() {
enumeration_count += 1;
println!(
"\n{}\nDomain: {}\n IPs: {:?}",
"Enriched Domain".bold(),
&v.fqdn,
&v.ips
);
}
}
}
println!(
"\n{}: {}",
"Total number of unique domain permutations generated".bold(),
domain_permutation_count.to_string().cyan()
);
println!(
"{}: {}",
"Total number of domains enriched".bold(),
enumeration_count.to_string().cyan()
);
println!(
"{}: {} seconds",
"Execution time".bold(),
start_time.elapsed().as_secs()
);
Ok(())
}