-
Notifications
You must be signed in to change notification settings - Fork 5
/
asr.sh
260 lines (206 loc) · 8.95 KB
/
asr.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
#!/bin/bash
# Set the target domain
target_domain="$1"
# Check if target_domain is provided
if [ -z "$target_domain" ]; then
echo "[+] usage $0 domain.com "
exit 1
fi
# Color codes
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
ascii_art='''
┏┓┳┳┏┳┓┏┓┏┓┳┳┳┓┳┓┏┓┏┓┏┓┳┓
┣┫┃┃ ┃ ┃┃┗┓┃┃┣┫┣┫┣ ┃ ┃┃┃┃
┛┗┗┛ ┻ ┗┛┗┛┗┛┻┛┛┗┗┛┗┛┗┛┛┗ by @h0tak88r
'''
echo -e "${RED} $ascii_art ${NC}"
rm -r subs/
mkdir subs
check_tools() {
local tools=("subfinder" "puredns" "gotator" "cero" "httpx" "gospider" "unfurl")
local missing_tools=()
echo "[+] Checking for required tools..."
for tool in "${tools[@]}"; do
if ! command -v "$tool" &> /dev/null; then
missing_tools+=("$tool")
fi
done
if [ ${#missing_tools[@]} -ne 0 ]; then
echo -e "${RED}[-] Missing required tools: ${missing_tools[*]}${NC}"
echo -e "${YELLOW}[!] Please install the missing tools before running the script${NC}"
echo "Installation guides:"
echo "subfinder: go install -v github.com/projectdiscovery/subfinder/v2/cmd/subfinder@latest"
echo "puredns: go install github.com/d3mondev/puredns/v2@latest"
echo "gotator: go install github.com/Josue87/gotator@latest"
echo "cero: go install github.com/glebarez/cero@latest"
echo "httpx: go install -v github.com/projectdiscovery/httpx/cmd/httpx@latest"
echo "gospider: go install github.com/jaeles-project/gospider@latest"
echo "unfurl: go install github.com/tomnomnom/unfurl@latest"
exit 1
fi
echo -e "${GREEN}[+] All required tools are installed!${NC}"
}
check_tools
finish_work() {
echo "[+] Combining subdomains and resolving them..."
cat "subs/"* | sort -u > "subs/all_subs_filtered.txt"
puredns resolve "subs/all_subs_filtered.txt" -r "Wordlists/dns/valid_resolvers.txt" -w "subs/all_subs_resolved.txt" --skip-wildcard-filter --skip-validation &> /dev/null
cat "subs/all_subs_resolved.txt" | httpx -random-agent -retries 2 --silent -o "subs/filtered_hosts.txt" &> /dev/null
echo "[+] Thats it we are done with subdomain enumeration!"
}
passive_recon() {
# URLs to fetch subdomains from various sources
urls=(
"https://rapiddns.io/subdomain/$target_domain?full=1#result"
"http://web.archive.org/cdx/search/cdx?url=*.$target_domain/*&output=text&fl=original&collapse=urlkey"
"https://crt.sh/?q=%.$target_domain"
"https://crt.sh/?q=%.%.$target_domain"
"https://crt.sh/?q=%.%.%.$target_domain"
"https://crt.sh/?q=%.%.%.%.$target_domain"
"https://otx.alienvault.com/api/v1/indicators/domain/$target_domain/passive_dns"
"https://api.hackertarget.com/hostsearch/?q=$target_domain"
"https://urlscan.io/api/v1/search/?q=$target_domain"
"https://jldc.me/anubis/subdomains/$target_domain"
"https://www.google.com/search?q=site%3A$target_domain&num=100"
"https://www.bing.com/search?q=site%3A$target_domain&count=50"
)
# Passive subdomain enumeration
echo "[+] Let's start with passive subdomain enumeration!"
echo "[+] Getting $target_domain subdomains using [crt.sh,rapiddns,alienvault,hackertarget,urlscan,jldc.me,google,bing]"
for url in "${urls[@]}"; do
curl -s "$url" | grep -o '([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])\.'"$target_domain"'' >> "subs/passive.txt"
done
wait
echo "[+] Removing duplicates....."
echo "[+] Saving to quick_passive.txt"
cat "subs/passive.txt" | sort -u > "subs/quick_passive.txt"
rm "subs/passive.txt"
echo "[+] Using subfinder for passive subdomain enumeration "
subfinder -d $target_domain --all --silent > "subs/subfinder.txt"
echo "[+] That's it, we are done with passive subdomain enumeration!"
finish_work
}
# Define a function for active reconnaissance
active_recon() {
# Active subdomain enumeration
echo "[+] Start active subdomain enumeration!"
echo "[+] DNS Brute Forcing using puredns"
puredns bruteforce "Wordlists/dns/dns_2m.txt" "$target_domain" -r "Wordlists/dns/valid_resolvers.txt" -w "subs/dns_bf.txt" --skip-wildcard-filter --skip-validation &> /dev/null
echo "[+] resolving brute forced subs...."
puredns resolve "subs/dns_bf.txt" -r "Wordlists/dns/valid_resolvers.txt" -w "subs/dns_bf_resolved.txt" --skip-wildcard-filter --skip-validation &> /dev/null
# Permutations using gotator
echo "[+] Permutations using gotator"
gotator -sub "subs/dns_bf_resolved.txt" -perm "Wordlists/dns/dns_permutations_list.txt" -mindup -fast -silent | sort -u > "subs/permutations.txt"
# TLS probing using cero
echo "[+] TLS probing using cero"
cero "$target_domain" | sed 's/^*.//' | grep "\." | sort -u | grep ".$target_domain$" > "subs/tls_probing.txt"
# Scraping (JS/Source) code
echo "[+] Scraping JS Source code "
cat "subs/"* | sort -u > "subs/filtered_subs.txt"
cat "subs/filtered_subs.txt" | httpx -random-agent -retries 2 -o "subs/filtered_hosts.txt" &> /dev/null
# Crawling using gospider
echo "[+] Crawling for js files using gospider"
gospider -S "subs/filtered_hosts.txt" --js -t 50 -d 3 --sitemap --robots -w -r > "subs/gospider.txt"
# Extracting subdomains from JS Files
echo "[+] Extracting Subdomains......"
sed -i '/^.\{2048\}./d' "subs/gospider.txt"
cat "subs/gospider.txt" | grep -o 'https?://[^ ]+' | sed 's/]$//' | unfurl -u domains | grep "$target_domain" | sort -u > "subs/scrap_subs.txt"
rm "subs/gospider.txt"
echo "[+] Done with Active subdomain enumeration!"
finish_work
}
# Define a function for normal reconnaissance
normal_recon() {
passive_recon
# Active subdomain enumeration
echo "[+] Start active subdomain enumeration!"
# 1. DNS Brute Forcing using puredns
echo "[+] DNS Brute Forcing using puredns"
puredns bruteforce "Wordlists/dns/dns_2m.txt" "$target_domain" -r "Wordlists/dns/valid_resolvers.txt" -w "subs/dns_bf.txt" --skip-wildcard-filter --skip-validation &> /dev/null
echo "[+] resolving brute forced subs...."
puredns resolve "subs/dns_bf.txt" -r "Wordlists/dns/valid_resolvers.txt" -w "subs/dns_bf_resolved.txt" --skip-wildcard-filter --skip-validation &> /dev/null
# 3. TLS probing using cero
echo "[+] TLS probing using cero"
cero "$target_domain" | sed 's/^*.//' | grep "\." | sort -u | grep ".$target_domain$" > "subs/tls_probing.txt"
# 4. Scraping (JS/Source) code
echo "[+] Scraping JS Source code "
cat "subs/"* | sort -u > "subs/filtered_subs.txt"
cat "subs/filtered_subs.txt" | httpx -random-agent -retries 2 -o "subs/filtered_hosts.txt" &> /dev/null
# Crawling using gospider
echo "[+] Crawling for js files using gospider"
gospider -S "subs/filtered_hosts.txt" --js -t 50 -d 3 --sitemap --robots -w -r > "subs/gospider.txt"
# Extracting subdomains from JS Files
echo "[+] Extracting Subdomains......"
sed -i '/^.\{2048\}./d' "subs/gospider.txt"
cat "subs/gospider.txt" | grep -o 'https?://[^ ]+' | sed 's/]$//' | unfurl -u domains | grep "$target_domain" | sort -u > "subs/scrap_subs.txt"
rm "subs/gospider.txt"
# Done with active subdomain enumeration
echo "[+] Done with Active subdomain enumeration!"
echo "[+] Normal Recon is complete!"
finish_work
}
# Define a function for quick reconnaissance
quick_recon() {
passive_recon
# TLS probing using cero
echo "[+] TLS probing using cero"
cero "$target_domain" | sed 's/^*.//' | grep "\." | sort -u | grep ".$target_domain$" > "subs/tls_probing.txt"
# Scraping (JS/Source) code
echo "[+] Scraping JS Source code "
cat "subs/"* | sort -u > "subs/filtered_subs.txt"
cat "subs/filtered_subs.txt" | httpx -random-agent -retries 2 -o "subs/filtered_hosts.txt" &> /dev/null
# Crawling using gospider
echo "[+] Crawling for js files using gospider"
gospider -S "subs/filtered_hosts.txt" --js -t 50 -d 3 --sitemap --robots -w -r > "subs/gospider.txt"
# Extracting subdomains from JS Files
echo "[+] Extracting Subdomains......"
sed -i '/^.\{2048\}./d' "subs/gospider.txt"
cat "subs/gospider.txt" | grep -o 'https?://[^ ]+' | sed 's/]$//' | unfurl -u domains | grep "$target_domain" | sort -u > "subs/scrap_subs.txt"
rm "subs/gospider.txt"
echo "[+] Quick Recon is complete!"
finish_work
}
# Define a function for full reconnaissance
full_recon() {
passive_recon
active_recon
echo "[+] Full Recon is complete!"
finish_work
}
# Display options and process user's choice
options='''
Choose what you wanna do?
[1] Passive recon only
[2] Active recon only
[3] Normal Recon [All without permutations]
[4] Quick Recon [All without Brute forcing and Permutations]
[5] Full recon [All Techniques]
'''
echo -e "${GREEN} $options ${NC}"
read -p "Enter your choice: " choice
case $choice in
1)
passive_recon
;;
2)
active_recon
;;
3)
normal_recon
;;
4)
quick_recon
;;
5)
full_recon
;;
*)
echo "Invalid choice. Exiting."
exit 1
;;
esac
echo "[+] Finished."