forked from plenumlab/lazyrecon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjskeyrecon.sh
executable file
·432 lines (256 loc) · 14 KB
/
jskeyrecon.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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
#!/bin/bash
########################################
# /// \\\
# You can edit your configuration here
#
#
########################################
massdnsWordlist=/root/Wordlist/subdomain/726w_subdomain.txt
rootPath=/root/OneDrive/output/lazyrecon
########################################
# Happy Hunting
########################################
red=`tput setaf 1`
green=`tput setaf 2`
yellow=`tput setaf 3`
reset=`tput sgr0`
SECONDS=0
usage() { echo -e "Usage: $0 -d domain [-e]\n Select -e to specify excluded domains\n " 1>&2; exit 1; }
while getopts ":d:e:r:" o; do
case "${o}" in
d)
domain=${OPTARG}
;;
#### working on subdomain exclusion
e)
excluded=${OPTARG}
;;
*)
usage
;;
esac
done
shift $((OPTIND - 1))
discovery(){
waybackrecon
waybackdowloader_oldjsfile
checkjsfile
cp -r $rootPath/$domain/$foldername/html/ /var/www/jsrecon/links/$domain/
memento_mass -f $rootPath/$domain/$foldername/allsubdomains_final.txt -o $rootPath/$domain/$foldername/wayback-data/robots_archieve.txt
cp -r $rootPath/$domain/$foldername/wayback-data/ /var/www/jsrecon/links/$domain/wayback-data/
rm -rf $rootPath/$domain/$foldername/wayback-data/jsfile/
}
waybackdowloader_oldjsfile(){
cd $rootPath/$domain/$foldername/wayback-data/
while read p ; do
wayback_machine_downloader $p --only "/\.js$/i"
done < $rootPath/$domain/$foldername/allsubdomains_final.txt
cd $rootPath/$domain/$foldername/wayback-data/websites/
for fl_nm in $(find . -type f );
do cp $fl_nm $rootPath/$domain/$foldername/wayback-data/jsfile/$(echo $fl_nm | cut -c 3- |sed -e 's/[^A-Za-z0-9._-]/_/g');
done
rm -rf $rootPath/$domain/$foldername/wayback-data/websites/
}
find_firebase(){
touch $rootPath/$domain/$foldername/html/firebase_js_location.txt
cd $rootPath/$domain/$foldername/wayback-data/jsfile/
for fl_nm in $(find . -type f );
do grep "firebaseio" $fl_nm > /dev/null && readlink -f $fl_nm >> $rootPath/$domain/$foldername/html/firebase_js_location.txt;
done
if [ -s "$rootPath/$domain/$foldername/html/firebase_js_location.txt" ]
then python3 ~/recon_tools/Scripts/python/location2link.py $rootPath/$domain/$foldername/html/firebase_js_location.txt $rootPath/$domain/$foldername/html/firebase_js_link.html
else
rm $rootPath/$domain/$foldername/html/firebase_js_location.txt
return
fi
rm $rootPath/$domain/$foldername/html/firebase_js_location.txt
cd --
echo " http://jsrecon.ragnarokv.site/links/${domain}/html/firebase_js_link.html " | mutt -s "Found potential firebaseio href from ${domain}" [email protected]
}
checkjsfile(){
wget2 -i $rootPath/$domain/$foldername/wayback-data/jsurls.txt -P $rootPath/$domain/$foldername/wayback-data/jsfile
cd $rootPath/$domain/$foldername/wayback-data/jsfile
fdupes . -r -f -1 -S -d -N
ls | while read file; do mv $file $(echo $file | sed -e 's/[^A-Za-z0-9._-]/_/g'); done
DumpsterDiver.py -p . -o $rootPath/$domain/$foldername/html/entropy.json
python3 ~/recon_tools/Scripts/python/entropy_json.py $rootPath/$domain/$foldername/html/entropy.json $rootPath/$domain/$foldername/html/new.json
echo "Fininshed high entropy scanning in jsfile http://jsrecon.ragnarokv.site/links/${domain}/html/new.json " | mutt -s "Entropy string ${domain} " [email protected]
find_firebase
rm $rootPath/$domain/$foldername/wayback-data/jsfile/errors.log
grep -oE ".{0,75}(application\/xml|encodeuricomponent|wsdl).{0,60}" * > $rootPath/$domain/$foldername/html/pattern.txt
python3 ~/recon_tools/LinkFinder/linkfinder.py -i './*' -o $rootPath/$domain/$foldername/html/${domain}_js.html
python3 /root/recon_tools/Scripts/python/extract_link.py $rootPath/$domain/$foldername/html/${domain}_js.html $rootPath/$domain/$foldername/html/${domain}_other.html $rootPath/$domain/$foldername/html/${domain}_api.html
cd -
}
waybackrecon () {
echo "Scraping wayback for data..."
cat $rootPath/$domain/$foldername/allsubdomains_final.txt | gau > $rootPath/$domain/$foldername/wayback-data/waybackurls.txt
cat $rootPath/$domain/$foldername/wayback-data/waybackurls.txt | sort -u | unfurl --unique keypairs > $rootPath/$domain/$foldername/wayback-data/paramlist.txt
[ -s $rootPath/$domain/$foldername/wayback-data/paramlist.txt ] && echo "Wordlist saved to /$domain/$foldername/wayback-data/paramlist.txt"
cat $rootPath/$domain/$foldername/wayback-data/waybackurls.txt | sort -u | grep -P "\w+\.js(\?|$)" | sort -u > $rootPath/$domain/$foldername/wayback-data/jsurls.txt
[ -s $rootPath/$domain/$foldername/wayback-data/jsurls.txt ] && echo "JS Urls saved to /$domain/$foldername/wayback-data/jsurls.txt"
cat $rootPath/$domain/$foldername/wayback-data/waybackurls.txt | unfurl --unique format "%s://%d%p" > $rootPath/$domain/$foldername/wayback-data/paths.txt
cat $rootPath/$domain/$foldername/wayback-data/waybackurls.txt | sort -u | grep -P "\w+\.php(\?|$) "| sort -u > $rootPath/$domain/$foldername/wayback-data/phpurls.txt
[ -s $rootPath/$domain/$foldername/wayback-data/phpurls.txt ] && echo "PHP Urls saved to /$domain/$foldername/wayback-data/phpurls.txt"
cat $rootPath/$domain/$foldername/wayback-data/waybackurls.txt | sort -u | grep -P "\w+\.aspx(\?|$) "| sort -u > $rootPath/$domain/$foldername/wayback-data/aspxurls.txt
[ -s $rootPath/$domain/$foldername/wayback-data/aspxurls.txt ] && echo "ASP Urls saved to /$domain/$foldername/wayback-data/aspxurls.txt"
cat $rootPath/$domain/$foldername/wayback-data/waybackurls.txt | sort -u | grep -P "\w+\.jsp(\?|$) "| sort -u > $rootPath/$domain/$foldername/wayback-data/jspurls.txt
[ -s $rootPath/$domain/$foldername/wayback-data/jspurls.txt ] && echo "JSP Urls saved to /$domain/$foldername/wayback-data/jspurls.txt"
cat $rootPath/$domain/$foldername/wayback-data/paths.txt | sed -E -e '/(\.jpg|\.png|\.gif|\.woff|\.css|\.ico|\.js)$/d' | perl -p -e 's/(.*)/<br><a href="\1" target="_blank">\1<\/a><br>/' > $rootPath/$domain/$foldername/html/paths.html
grep 'admin\|proxy' $rootPath/$domain/$foldername/html/paths.html > $rootPath/$domain/$foldername/html/adminpath.html
}
import_subdomains(){
findomain --import-subdomains $rootPath/$domain/$foldername/allsubdomains_final.txt -m -t $domain --postgres-database subdomains_name
}
recon(){
echo "${green}Recon started on $domain ${reset}"
echo "Listing subdomains using assertfinder..."
findomain -r -t $domain -u $rootPath/$domain/$foldername/raw_subdomains.txt
assetfinder --subs-only $domain >> $rootPath/$domain/$foldername/raw_subdomains.txt
number=$(wc -l $rootPath/$domain/$foldername/raw_subdomains.txt| awk '{print $1}')
if [[ $number -le 3 ]]; then
ffuf -w $ffuf_Wordlist -u https://${domain}/FUZZ -se -fs 0 -fw 1 > $rootPath/$domain/$foldername/${domain}_output.txt
ip=$(dig +short $line @8.8.8.8| grep -m 1 -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}')
printf "${ip}" > $rootPath/$domain/$foldername/only_ip.txt
ipport_mass -f $rootPath/$domain/$foldername/only_ip.txt -o $rootPath/$domain/$foldername/portscanning
echo "Fininshed ffuf scanning " | mutt -s "FFUF_full ${domain}" [email protected] -a $rootPath/$domain/$foldername/${domain}_output.txt
exit 1
fi
echo "Checking Passive source with massdns"
massdns_second_check
if [[ "$(dig @1.1.1.1 A,CNAME {test321123,testingforwildcard,plsdontgimmearesult}.$domain +short | wc -l)" -gt "1" ]]; then
echo "[!] Possible wildcard detected."
echo "Skipping Massdns and dnsgen enumeration."
wildcard_boolean=1
fi
echo "Starting Massdns Subdomain discovery this may take a while"
mass $domain > /dev/null
echo "Massdns finished..."
hostalive
if [[ $wildcard_boolean != 1 ]]; then
#statements
using_dnsgen
hostalive_for_dnsgen
fi
rm_dup_file $rootPath/$domain/$foldername/allsubdomains_final.txt
import_subdomains
cat $rootPath/$domain/$foldername/responsive_urls.txt |unfurl -unique domain > $rootPath/$domain/$foldername/responsiveDomains_final.txt
python3 /root/recon_tools/Scripts/python/urls_processing.py $rootPath/$domain/$foldername/responsive_urls.txt $rootPath/$domain/$foldername/ffuf_input.txt
nsrecords $domain
}
massdns_second_check(){
cat $rootPath/$domain/$foldername/raw_subdomains.txt | massdns -r /root/Wordlist/resolver.txt -t A -q -o S -w $rootPath/$domain/$foldername/useless/massdns_temp.txt
}
mass(){
if [[ $wildcard_boolean != 1 ]]; then
#statements
/root/recon_tools/massdns/scripts/subbrute.py $massdnsWordlist $domain | massdns -r /root/Wordlist/resolver.txt -t A -q -o S > $rootPath/$domain/$foldername/useless/mass.txt
cat $rootPath/$domain/$foldername/useless/mass.txt >> $rootPath/$domain/$foldername/useless/massdns_temp.txt
rm $rootPath/$domain/$foldername/useless/mass.txt
fi
deduplicate_massdns_output $rootPath/$domain/$foldername/useless/massdns_temp.txt
awk '{print $1}' $rootPath/$domain/$foldername/useless/massdns_temp.txt | sed 's/\.$//' > $rootPath/$domain/$foldername/massdns_checked_subdomains.txt
rm_dup_file $rootPath/$domain/$foldername/massdns_checked_subdomains.txt
cat $rootPath/$domain/$foldername/massdns_checked_subdomains.txt > $rootPath/$domain/$foldername/allsubdomains_final.txt
}
deduplicate_massdns_output(){
tmpfile=/tmp/$(basename $1)
awk '!seen[$3]++' $1 > $tmpfile
mv $tmpfile $1
}
hostalive(){
echo "Probing for live hosts..."
cat $rootPath/$domain/$foldername/massdns_checked_subdomains.txt | httprobe -c 50 -t 3000 > $rootPath/$domain/$foldername/responsive_urls.txt
cat $rootPath/$domain/$foldername/responsive_urls.txt |unfurl -unique domain > $rootPath/$domain/$foldername/responsiveDomains.txt
count=$(wc -l $rootPath/$domain/$foldername/responsiveDomains.txt | awk '{print $1}')
if [[ $count = 0 ]]; then
exit 1
fi
echo "${yellow}Total of ${count} live subdomains were found${reset}"
}
using_dnsgen(){
echo "Using dnsgen..."
head -n 1500 $rootPath/$domain/$foldername/responsiveDomains.txt | dnsgen - > $rootPath/$domain/$foldername/useless/dnsgen_temp.txt
rm_dup_file $rootPath/$domain/$foldername/useless/dnsgen_temp.txt
cat $rootPath/$domain/$foldername/useless/dnsgen_temp.txt | massdns -r /root/Wordlist/resolver.txt -t A -q -o S > $rootPath/$domain/$foldername/useless/dnsgen_mass.txt
deduplicate_massdns_output $rootPath/$domain/$foldername/useless/dnsgen_mass.txt
awk '{print $1}' $rootPath/$domain/$foldername/useless/dnsgen_mass.txt | sed 's/\.$//' > $rootPath/$domain/$foldername/useless/dnsgen_resolved_domains.txt
rm_dup_file $rootPath/$domain/$foldername/useless/dnsgen_resolved_domains.txt
cat $rootPath/$domain/$foldername/useless/dnsgen_resolved_domains.txt >> $rootPath/$domain/$foldername/allsubdomains_final.txt
rm $rootPath/$domain/$foldername/useless/dnsgen_temp.txt
}
hostalive_for_dnsgen(){
cat $rootPath/$domain/$foldername/useless/dnsgen_resolved_domains.txt | httprobe -c 50 -t 3000 > $rootPath/$domain/$foldername/useless/dnsgen_responsive.txt
cat $rootPath/$domain/$foldername/useless/dnsgen_responsive.txt >> $rootPath/$domain/$foldername/responsive_urls.txt
rm_dup_file $rootPath/$domain/$foldername/responsive_urls.txt
}
nsrecords(){
echo "${green}Started dns records check...${reset}"
echo "Looking into CNAME Records..."
cat $rootPath/$domain/$foldername/useless/massdns_temp.txt | grep CNAME >> $rootPath/$domain/$foldername/cnames.txt
cat $rootPath/$domain/$foldername/useless/dnsgen_mass.txt | grep CNAME >> $rootPath/$domain/$foldername/cnames.txt
cat $rootPath/$domain/$foldername/cnames.txt | sort -u | while read line; do
hostrec=$(echo "$line" | awk '{print $1}')
if [[ $(host $hostrec | grep NXDOMAIN) != "" ]]
then
echo "${red}Check the following domain for NS takeover: $line ${reset}"
echo "$line" >> $rootPath/$domain/$foldername/pos.txt
else
echo -ne "working on it...\r"
fi
done
sleep 1
}
logo(){
#can't have a bash script without a cool logo :D
echo "${red}
_ ____ ____ ___ _ ____ _____ ____ ____ _
/ \ / _ \/_ \\\ \/// __\/ __// _\/ _ \/ \ /|
| | | / \| / / \ / | \/|| \ | / | / \|| |\ ||
| |_/\| |-||/ /_ / / | /| /_ | \__| \_/|| | \||
\____/\_/ \|\____//_/ \_/\_\\\____\\\____/\____/\_/ \\|
${reset} "
}
main(){
logo
if [ -d "/var/www/jsrecon/links/$domain/wayback-data/jsfile/" ]; then
# Control will enter here if $DIRECTORY doesn't exist.
exit 1
fi
mkdir -p $rootPath/$domain
mkdir -p $rootPath/$domain/$foldername
mkdir -p $rootPath/$domain/$foldername/wayback-data/
mkdir -p $rootPath/$domain/$foldername/eyewitness
mkdir -p $rootPath/$domain/$foldername/useless
mkdir -p $rootPath/$domain/$foldername/html
mkdir -p /var/www/jsrecon/links/$domain
mkdir -p /var/www/jsrecon/links/$domain/urls
mkdir -p $rootPath/$domain/$foldername/wayback-data/jsfile
touch $rootPath/$domain/$foldername/useless/mass.txt
touch $rootPath/$domain/$foldername/cnames.txt
touch $rootPath/$domain/$foldername/pos.txt
touch $rootPath/$domain/$foldername/raw_subdomains.txt
touch $rootPath/$domain/$foldername/useless/massdns_temp.txt
touch $rootPath/$domain/$foldername/domaintemp.txt
touch $rootPath/$domain/$foldername/useless/cleantemp.txt
touch $rootPath/$domain/$foldername/allsubdomains_final.txt
rm_resolver
recon
echo "Starting discovery..."
discovery
# -a $rootPath/$domain/$foldername/ffuf/ffuf_output.html
echo "${green}Scan for $domain finished successfully${reset}"
duration=$SECONDS
echo "Scan completed in : $(($duration / 60)) minutes and $(($duration % 60)) seconds."
stty sane
tput sgr0
}
todate=$(date +'%Y-%m-%d-%H-%M')
path=$(pwd)
foldername=recon-$todate
export rootPath
export domain
export foldername
touch /root/Wordlist/domains_monitoring.txt
echo $domain >> /root/Wordlist/domains_monitoring.txt
main $domain