-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
grabber_hosts.sh
executable file
·238 lines (195 loc) · 5.53 KB
/
grabber_hosts.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
#!/bin/bash
function usage() {
echo "Usage: "$0" [DOMAIN]"
if [ -n "$1" ] ; then
echo "Error: "$1"!"
fi
exit
}
function clean() {
f="$1"
domain="$2"
sed -i "s/^\*\.//g" "$f"
sed -i "s/^\.//g" "$f"
sed -i "s/^2F//ig" "$f"
sed -i "s/^25//ig" "$f"
sed -i "s/^3D//ig" "$f"
sed -i "s/<br>/\n/ig" "$f"
sed -i "s/,/\n/g" "$f"
cat $f | perl -pe 's/\\n/\n/g' | tr '[:upper:]' '[:lower:]' | egrep "$domain$" | sort -fu > "/tmp/$f"
mv "/tmp/$f" "$f"
}
if [ ! $# -eq 1 ] ; then
usage
fi
domain="$1"
domain_dir="domains/$domain"
if [ ! -d $domain_dir ] ; then
mkdir -p $domain_dir
fi
cd $domain_dir
source ~/.bash_functions
echo "## GOOGLE+GITHUB ######" >&2
o_gg_github="hosts_gg_github"
gggithub "$domain" | tee -a $o_gg_github
wc -l $o_gg_github >&2
echo
echo "## FINDOMAIN ######" >&2
findomain -t "$domain" -o
o_tmp="$domain.txt"
o_findomain="hosts_findomain"
if [ -f $o_tmp ] ; then
cat $o_tmp >> $o_findomain
rm $o_tmp
fi
wc -l $o_findomain >&2
echo
echo "## CERTSPOTTER ######" >&2
o_certspotter="hosts_certspotter"
certspotter "$domain" | tee -a $o_certspotter
wc -l $o_certspotter >&2
echo
echo "##### CRTSH ######" >&2
o_crtsh="hosts_crtsh"
crtsh "$domain" | tee -a $o_crtsh
wc -l $o_crtsh >&2
echo
echo "##### BUFFEROVER ######" >&2
o_bufferover="hosts_bufferover"
bufferover "$domain" | tee -a $o_bufferover
wc -l $o_bufferover >&2
echo
echo "##### THREATCROWD ######" >&2
o_threatcrowd="hosts_threatcrowd"
threatcrowd "$domain" | tee -a $o_threatcrowd
wc -l $o_threatcrowd >&2
echo
# echo "## C9 ######" >&2
# o_c99="hosts_c99"
# c99 "$domain" | tee -a $o_c99
# wc -l $o_c99 >&2
# echo
echo "## SECURITYTRAILS ######" >&2
o_securitytrails="hosts_securitytrails"
securitytrails "$domain" | tee -a $o_securitytrails
wc -l $o_securitytrails >&2
echo
# echo "## SUBLIST3R ######" >&2
# o_sublist3r="hosts_sublist3r"
# sublist3r -d "$domain" -o $o_sublist3r
# wc -l $o_sublist3r >&2
# echo
echo "## SUBFINDER ######" >&2
o_subfinder="hosts_subfinder"
subfinder -d "$domain" 2>/dev/null | tee -a $o_subfinder
wc -l $o_subfinder >&2
echo
echo "## ASSETFINDER ######" >&2
o_assetfinder="hosts_assetfinder"
assetfinder --subs-only "$domain" | tee -a $o_assetfinder
wc -l $o_assetfinder >&2
echo
echo "## GOOGLE+PASTEBIN ######" >&2
o_gg_pastebin="hosts_gg_pastebin"
ggpastebin "$domain" | tee -a $o_gg_pastebin
wc -l $o_gg_pastebin >&2
echo
echo "## GITHUB ######" >&2
o_github="hosts_github"
github-subdomains.py -d "$domain" | tee -a $o_github
wc -l $o_github >&2
echo
echo "## OSUB ######" >&2
o_osub="hosts_osub"
osub "$domain" | tee -a $o_osub
wc -l $o_osub >&2
echo
# echo "## GAU ######" >&2
# o_gau="hosts_gau"
# echo "https://$domain" | gau | awk -F '/' '{print $3}' | awk -F ':' '{print $1}' | tee -a $o_gau
# wc -l $o_gau >&2
# echo
echo "## WORDGRAB ######" >&2
o_wordgrab="raw_wordgrab"
wordgrab2 "$domain" | tee -a $o_wordgrab
wc -l $o_wordgrab >&2
echo
wordlist_amass="$(pwd)/../../subdomains-top1million-5000.txt"
# wordlist_amass="$(pwd)/../../subdomains-top1million-20000.txt"
domain_amass="wordgrab_amass"
cp $o_wordgrab $domain_amass
cat $wordlist_amass >> $domain_amass
wordlist_altdns="$(pwd)/../../altprefix_short.txt"
# wordlist_altdns="$(pwd)/../../altprefix.txt"
domain_altdns="wordgrab_altdns"
cp $o_wordgrab $domain_altdns
cat $wordlist_altdns >> $domain_altdns
echo "## AMASS 1 ######" >&2
o_amass="hosts_amass"
amass enum -active -d "$domain" -brute -w $domain_amass -src -ip -dir amass -o amass/amass.txt
cat amass/amass.txt | awk -F ']' '{print $2}' | awk '{print $1}' | sort -fu | tee -a $o_amass
wc -l $o_amass >&2
echo
echo "## SSLSUB ######" >&2
o_sslsub="hosts_sslsub"
cat hosts_amass | parallel -j 10 "source ~/.bash_functions; sslsub {1} | egrep \"\.{1}$\" | tee -a hosts_sslsub"
wc -l $o_sslsub >&2
echo
echo "## ONEFORALL ######" >&2
o_oneforall="hosts_oneforall"
# python3.6 /opt/bin/oneforall.py --target "$domain" --path ./oneforall/ --brute True --req True run
python3.6 /opt/bin/oneforall.py --target "$domain" --path ./oneforall/ --brute True --req True run
if [ -d oneforall ] ; then
# mv ./oneforall/*.txt $o_oneforall
cat ./oneforall/*.csv | cut -d "," -f 6 > $o_oneforall
fi
wc -l $o_oneforall >&2
echo
echo "## CLEAN HOSTS AND MERGE ######" >&2
ls -1 hosts_* | while read f
do
clean $f $domain
done
cat hosts_* | sort -fu >> hosts
wc -l hosts >&2
echo
echo "## AFTER RECON TOOLS ######" >&2
o_subzuf="hosts_subzuf"
cat hosts | subzuf.py $domain --output "$domain.subzuf"
cat "$domain.subzuf" | jq ".[].domain" | tr -d '"' | sort -f > "$o_subzuf"
echo
o_regulator="hosts_regulator"
python3.8 /opt/regulator/main.py "$domain" hosts "$domain.rules"
cat "$domain.rules" | python3.8 /opt/regulator/generator.py | sed -E 's/\.{2,}/./g' | sort -fu | grep -vE '(\._|_\.|\-\.|\.\-|_\-|\-_)' > "$o_regulator"
echo
echo "## BUILDING LAST HOSTS FILE ######" >&2
ls -1 hosts_* | while read f
do
clean $f $domain
done
cat hosts_* | sort -fu >> hosts
wc -l hosts >&2
echo
echo "## HUGE BRUTE FORCE ######" >&2
o_hugebf="alt_hugebf"
cat "$(pwd)/../../EnormousDNS.txt" | awk -v dom="$domain" '{print $1"."dom}' > $o_hugebf
wc -l $o_hugebf >&2
echo
echo "## ALTDNS ######" >&2
if [ -f hosts ] ; then
altdns -i "$(pwd)/hosts" -w $domain_altdns -o "$(pwd)/alt_altdns"
wc -l alt_altdns >&2
fi
echo
echo "## DNSGEN ######" >&2
if [ -f hosts ] ; then
dnsgen -f "$(pwd)/hosts" -w $domain_altdns > "$(pwd)/alt_dnsgen"
wc -l alt_dnsgen >&2
fi
echo
echo "## CLEAN AND MERGE ######" >&2
cat hosts >> alt_hosts
cat alt_* | sort -fu >> altdns
wc -l altdns >&2
echo "## THE END ######" >&2
# cd ..