Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/twistrs-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
name = "twistrs-cli"
version = "0.1.0"
authors = ["Juxhin Dyrmishi Brigjaj <juxhin@phishdeck.com>"]
edition = "2018"
edition = "2021"

[dependencies]
twistrs = "0.2.2-beta"
twistrs = { path = "../../twistrs" }
clap = "3.0.0-beta.1"
colored = "1.9.3"
tokio = { version = "0.2", features = ["full"] }
Expand Down
38 changes: 19 additions & 19 deletions examples/twistrs-cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
use colored::*;
use clap::{App, Arg};
use colored::*;

use tokio::sync::mpsc;
use twistrs::enrich::DomainMetadata;
use twistrs::permutate::Domain;
use tokio::sync::mpsc;

use std::time::Instant;
use std::collections::HashSet;

use std::time::Instant;

#[tokio::main]
async fn main() {
Expand All @@ -25,7 +24,7 @@ async fn main() {

let domain = Domain::new(&matches.value_of("domain").unwrap()).unwrap();

let mut domain_permutations = domain.all().unwrap().collect::<HashSet<String>>();
let mut domain_permutations = domain.all().collect::<HashSet<String>>();
let domain_permutation_count = domain_permutations.len();

domain_permutations.insert(String::from(domain.fqdn.clone()));
Expand All @@ -37,7 +36,10 @@ async fn main() {
let mut tx = tx.clone();

tokio::spawn(async move {
if let Err(_) = tx.send((i, v.clone(), domain_metadata.dns_resolvable().await)).await {
if let Err(_) = tx
.send((i, v.clone(), domain_metadata.dns_resolvable().await))
.await
{
println!("received dropped");
return;
}
Expand All @@ -52,21 +54,19 @@ async fn main() {

while let Some(i) = rx.recv().await {
match i.2 {
Ok(v) => {
match v.ips {
Some(_) => {
enumeration_count += 1;
println!(
"\n{}\nDomain: {}\n IPs: {:?}",
"Enriched Domain".bold(),
&v.fqdn,
&v.ips
);
},
None => {},
Ok(v) => match v.ips {
Some(_) => {
enumeration_count += 1;
println!(
"\n{}\nDomain: {}\n IPs: {:?}",
"Enriched Domain".bold(),
&v.fqdn,
&v.ips
);
}
None => {}
},
Err(_) => {},
Err(_) => {}
}
}

Expand Down
6 changes: 3 additions & 3 deletions examples/twistrs-grpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
name = "twistrs-grpc"
version = "0.1.0"
authors = ["Juxhin Dyrmishi Brigjaj <juxhin@phishdeck.com>"]
edition = "2018"
edition = "2021"

[dependencies]
twistrs = "0.2.2-beta"
twistrs = { path = "../../twistrs" }
prost = "0.6.1"
tonic = {version="0.2.0",features = ["tls"]}
tokio = {version="0.2.18",features = ["stream", "macros"]}
Expand All @@ -20,4 +20,4 @@ path = "src/server.rs"

[[bin]]
name = "client"
path = "src/client.rs"
path = "src/client.rs"
92 changes: 45 additions & 47 deletions examples/twistrs-grpc/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@ use tokio::sync::mpsc;

use tonic::{transport::Server, Request, Response, Status};

use twistrs::permutate::Domain;
use twistrs::enrich::DomainMetadata;
use twistrs::permutate::Domain;

use domain_enumeration::domain_enumeration_server::{DomainEnumeration, DomainEnumerationServer};

use domain_enumeration::{
Fqdn,
MxCheckResponse,
DomainEnumerationResponse
};
use domain_enumeration::{DomainEnumerationResponse, Fqdn, MxCheckResponse};

mod domain_enumeration;

Expand All @@ -20,37 +16,38 @@ pub struct DomainEnumerationService {}

#[tonic::async_trait]
impl DomainEnumeration for DomainEnumerationService {
type SendDnsResolutionStream=mpsc::Receiver<Result<DomainEnumerationResponse, Status>>;
type SendMxCheckStream=mpsc::Receiver<Result<MxCheckResponse, Status>>;

async fn send_dns_resolution(&self,
request: Request<Fqdn>
) -> Result<Response<Self::SendDnsResolutionStream>, Status> {
type SendDnsResolutionStream = mpsc::Receiver<Result<DomainEnumerationResponse, Status>>;
type SendMxCheckStream = mpsc::Receiver<Result<MxCheckResponse, Status>>;

async fn send_dns_resolution(
&self,
request: Request<Fqdn>,
) -> Result<Response<Self::SendDnsResolutionStream>, Status> {
let (tx, rx) = mpsc::channel(64);

for permutation in Domain::new(&request.get_ref().fqdn).unwrap().all().unwrap() {
for permutation in Domain::new(&request.get_ref().fqdn).unwrap().all() {
let domain_metadata = DomainMetadata::new(permutation.clone());
let mut tx = tx.clone();

// Spawn DNS Resolution check
tokio::spawn(async move {
match domain_metadata.dns_resolvable().await {
Ok(metadata) => {
match metadata.ips {
Some(ips) => {
if let Err(_) = tx.send(Ok(DomainEnumerationResponse {
fqdn:format!("{}", permutation.clone()),
Ok(metadata) => match metadata.ips {
Some(ips) => {
if let Err(_) = tx
.send(Ok(DomainEnumerationResponse {
fqdn: format!("{}", permutation.clone()),
ips: ips.into_iter().map(|x| format!("{}", x)).collect(),
})).await {
println!("receiver dropped");
return;
}
},
None => {},
}))
.await
{
println!("receiver dropped");
return;
}
}
None => {}
},
Err(_) => {},
Err(_) => {}
}

drop(tx);
Expand All @@ -62,34 +59,36 @@ impl DomainEnumeration for DomainEnumerationService {
Ok(Response::new(rx))
}

async fn send_mx_check(&self,
request: Request<Fqdn>
async fn send_mx_check(
&self,
request: Request<Fqdn>,
) -> Result<Response<Self::SendMxCheckStream>, Status> {
let (tx, rx) = mpsc::channel(64);

for permutation in Domain::new(&request.get_ref().fqdn).unwrap().all().unwrap() {
for permutation in Domain::new(&request.get_ref().fqdn).unwrap().all() {
let domain_metadata = DomainMetadata::new(permutation.clone());
let mut tx = tx.clone();

// Spawn DNS Resolution check
tokio::spawn(async move {
match domain_metadata.mx_check().await {
Ok(metadata) => {
match metadata.smtp {
Some(smtp) => {
if let Err(_) = tx.send(Ok(MxCheckResponse {
fqdn:format!("{}", permutation.clone()),
Ok(metadata) => match metadata.smtp {
Some(smtp) => {
if let Err(_) = tx
.send(Ok(MxCheckResponse {
fqdn: format!("{}", permutation.clone()),
is_positive: smtp.is_positive,
message: smtp.message,
})).await {
println!("receiver dropped");
return;
}
},
None => {},
}))
.await
{
println!("receiver dropped");
return;
}
}
None => {}
},
Err(_) => {},
Err(_) => {}
}

drop(tx);
Expand All @@ -98,11 +97,10 @@ impl DomainEnumeration for DomainEnumerationService {

drop(tx);

Ok(Response::new(rx))
}
Ok(Response::new(rx))
}
}


#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let addr = "0.0.0.0:50051".parse().unwrap();
Expand All @@ -115,6 +113,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.add_service(DomainEnumerationServer::new(rpc_service))
.serve(addr)
.await?;

Ok(())
}
}
4 changes: 2 additions & 2 deletions examples/twistrs-ws/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
name = "twistrs-ws"
version = "0.1.0"
authors = ["Juxhin Dyrmishi Brigjaj <juxhin@phishdeck.com>"]
edition = "2018"
edition = "2021"

[dependencies]
twistrs = "0.2.2-beta"
twistrs = { path = "../../twistrs" }
tokio = { version = "0.2", features = ["macros", "sync", "rt-threaded"] }
warp = "0.2"
serde = {version = "1.0", features = ["derive"] }
Expand Down
34 changes: 15 additions & 19 deletions examples/twistrs-ws/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use tokio::sync::{mpsc, RwLock};
use warp::ws::{Message, WebSocket};
use warp::Filter;

use twistrs::permutate::Domain;
use twistrs::enrich::DomainMetadata;
use twistrs::permutate::Domain;

/// Our global unique user id counter.
static NEXT_USER_ID: AtomicUsize = AtomicUsize::new(1);
Expand All @@ -28,9 +28,7 @@ async fn main() {
let chat = warp::path("chat")
.and(warp::ws())
.and(users)
.map(|ws: warp::ws::Ws, users| {
ws.on_upgrade(move |socket| user_connected(socket, users))
});
.map(|ws: warp::ws::Ws, users| ws.on_upgrade(move |socket| user_connected(socket, users)));

let index = warp::path::end().map(|| warp::reply::html(INDEX_HTML));
let routes = index.or(chat);
Expand Down Expand Up @@ -95,32 +93,30 @@ async fn user_message(my_id: usize, msg: Message, users: &Users) {
eprintln!("initiating dns resolution checks for user: {}", my_id);

let domain = Domain::new(&msg).unwrap();
let mut domain_permutations = domain.all().unwrap().collect::<HashSet<String>>();
let mut domain_permutations = domain.all().collect::<HashSet<String>>();
domain_permutations.insert(String::from(domain.fqdn.clone()));

for v in domain_permutations.into_iter() {
let domain_metadata = DomainMetadata::new(v.clone());
let tx = tx.clone();

tokio::spawn(async move {
match domain_metadata.dns_resolvable().await {
Ok(metadata) => {
match metadata.ips {
Some(ips) => {
if let Err(_) = tx.send(Ok(Message::text(format!("{:?}", ips)))) {
println!("received dropped");
return;
}

drop(tx);
},
None => return,
Ok(metadata) => match metadata.ips {
Some(ips) => {
if let Err(_) = tx.send(Ok(Message::text(format!("{:?}", ips)))) {
println!("received dropped");
return;
}

drop(tx);
}
None => return,
},
Err(_) => return,
}
});
}
}
}
}
}
Expand Down Expand Up @@ -176,4 +172,4 @@ static INDEX_HTML: &str = r#"<!DOCTYPE html>
</script>
</body>
</html>
"#;
"#;
12 changes: 6 additions & 6 deletions twistrs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[package]
name = "twistrs"
version = "0.3.1-beta"
version = "0.3.2-beta"
description = "An asynchronous domain name permutation and enumeration library."
license = "MIT"
repository = "https://github.com/JuxhinDB/twistrs"
documentation = "https://docs.rs/crate/twistrs"
authors = ["Juxhin Dyrmishi Brigjaj <juxhin@phishdeck.com>"]
edition = "2018"
edition = "2021"

[package.metadata.docs.rs]
all-features = true
Expand All @@ -21,12 +21,12 @@ whois_lookup = [ "whois-rust" ]

[dependencies]
addr = "0.13.1"
lazy_static = "1.4.0"
phf = { version = "0.8.0", features = ["macros"] }
async-smtp = "0.3.4"
lazy_static = "1.4.0"
phf = { version = "0.8.0", features = ["macros"] }
async-smtp = {git = "https://github.com/JuxhinDB/async-smtp.git"}
async-native-tls = "0.3.3"
futures = "0.3"
tokio = { version = "0.2.22", features = ["dns", "macros"] }
tokio = { version = "0.2.22", features = ["dns", "macros"] }
fancy-regex = "0.4.0"
idna = "0.2.0"
hyper = "0.13.8"
Expand Down
Loading