-
-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathtakeover.rs
76 lines (75 loc) · 2.97 KB
/
takeover.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
use super::{arguments::_parse_args, io::_writeOutput, platforms::_platforms};
use ansi_term::Colour;
use futures::{stream::iter, StreamExt};
use reqwest::Client;
use tokio;
#[tokio::main]
pub async fn _takeover(hosts: Vec<String>, threads: usize) -> std::io::Result<()> {
let client = &Client::builder()
.danger_accept_invalid_certs(true)
.build()
.unwrap();
let args = &_parse_args();
let fetches = iter(hosts.into_iter().map(|url| async move {
match client.get(&url).send().await {
Ok(resp) => match resp.text().await {
Ok(text) => {
let platformName = _platforms(text);
match platformName == "None" {
true => {
if args.is_present("verbose") {
println!(
"[{}] {}!",
Colour::Blue.bold().paint("Not Vulnerable"),
url
);
}
}
_ => {
println!(
"[{}]\t{} at {}!",
Colour::Red.bold().paint(&platformName),
Colour::White.bold().paint("Possible Sub-domain Takeover"),
url
);
if args.is_present("output") {
let outputData = format!("[{}] {}\n", platformName, url);
let fileName = args.value_of("output").unwrap();
_writeOutput(fileName.to_string(), outputData);
}
}
}
}
Err(_) => {
if args.is_present("verbose") {
println!(
"[{}]\tAn error occured for [{}].",
Colour::Green.bold().paint("ERROR"),
Colour::White.bold().paint(url)
)
}
}
},
Err(_) => {
if args.is_present("verbose") {
println!(
"[{}]\tAn error occured for [{}].",
Colour::Green.bold().paint("ERROR"),
Colour::White.bold().paint(url)
)
}
}
}
}))
.buffer_unordered(threads)
.collect::<Vec<()>>();
fetches.await;
/*
In case you want to know how it works, here is a more simpler code explaining the overall workflow:
let body = response.text().await?;
if body.contains("<p><strong>There isn't a GitHub Pages site here.</strong></p>") {
println!("GitHub Pages Sub-domain Takeover seems possible!");
}
*/
Ok(())
}