-
Notifications
You must be signed in to change notification settings - Fork 0
/
subflow.sh
68 lines (49 loc) · 1.73 KB
/
subflow.sh
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
#!/bin/bash
if [ -z "$1" ]; then
echo "Usage: $0 <domain>"
exit 1
fi
domain="$1"
output_file="${domain}_subdomains.txt"
temp_file="temp_${domain}.txt"
cleaned_file="${domain}_cleaned.txt"
alive_file="${domain}_alive.txt"
threads=50
function run_subfinder_parallel() {
input_file=$1
output_file=$2
echo "[*] Running subfinder on subdomains in parallel..."
cat "$input_file" | xargs -P "$threads" -I {} subfinder -d {} -all -silent -o - >> "$output_file"
}
echo "[*] Running subfinder on: $domain..."
subfinder -d "$domain" -all -recursive -silent -o "$output_file"
previous_count=0
current_count=$(wc -l < "$output_file")
echo "[*] Found $current_count subdomains. Checking recursively..."
while [ "$current_count" -gt "$previous_count" ]; do
echo "[*] Running recursively with multi-threading on new subdomains..."
previous_count=$current_count
run_subfinder_parallel "$output_file" "$temp_file"
sort -u "$output_file" "$temp_file" -o "$output_file"
> "$temp_file"
current_count=$(wc -l < "$output_file")
echo "[*] Total subdomains found so far: $current_count"
done
echo "[*] Cleaning up subdomains..."
awk -F'.' '
{
subdomain=$0
gsub("^www\\.", "", subdomain)
if (!(subdomain in seen)) {
seen[subdomain]=1
print $0
}
}' "$output_file" > "$cleaned_file"
echo "[*] Cleaned subdomains saved to: $cleaned_file"
echo "[*] Checking if subdomains are alive with $threads threads..."
httpx -l "$cleaned_file" -silent -o "$alive_file" -nc -t "$threads"
echo "[*] Alive subdomains saved to: $alive_file"
rm -f "$temp_file"
echo "[*] Recursive enumeration complete. Found $(wc -l < "$alive_file") alive subdomains."
rmm -f "$alive_file" -o subsmm
echo "[*] Generated mindmap file for $domain."