-
Notifications
You must be signed in to change notification settings - Fork 76
/
Copy pathchomp-scan.sh
executable file
·3116 lines (2853 loc) · 123 KB
/
chomp-scan.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
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env bash
# Colors
NC='\033[0m';
RED='\033[0;31m';
GREEN='\033[0;32m';
BLUE='\033[0;34m';
ORANGE='\033[0;33m';
# Wordlists
SHORT=wordlists/subdomains-top1mil-20000.txt;
LONG=wordlists/sortedcombined-knock-dnsrecon-fierce-reconng.txt;
HUGE=wordlists/huge-200k.txt;
SMALL=wordlists/big.txt;
MEDIUM=wordlists/raft-large-combined.txt;
LARGE=wordlists/seclists-combined.txt;
XL=wordlists/haddix_content_discovery_all.txt;
XXL=wordlists/haddix-seclists-combined.txt;
# User-defined CLI argument variables
DOMAIN="";
SUBDOMAIN_WORDLIST="";
SUBDOMAIN_BRUTE=1; # Constant
CONTENT_WORDLIST="";
CONTENT_DISCOVERY=0;
SCREENSHOTS=0;
INFO_GATHERING=0;
PORTSCANNING=0;
HTTP="https"
CUSTOM_WORKING_DIR="";
WORKING_DIR="";
BLACKLIST=blacklist.txt;
INTERACTIVE=0;
USE_ALL=0;
USE_DISCOVERED=0;
DEFAULT_MODE=0;
INTERESTING=interesting.txt;
SKIP_MASSCAN=0;
NOTICA="";
CONFIG_FILE="";
TOOL_PATH="$HOME/bounty/tools";
TOOL_PATH_SET=0;
# Config file variables
ENABLE_DNSCAN=0;
ENABLE_SUBFINDER=0;
ENABLE_SUBLIST3R=0;
ENABLE_AMASS=0;
ENABLE_GOALTDNS=0;
ENABLE_MASSDNS=1; # Constant
ENABLE_HTTPROBE=0;
ENABLE_INCEPTION=0;
ENABLE_WAYBACKURLS=0;
ENABLE_FFUF=0;
ENABLE_GOBUSTER=0;
ENABLE_DIRSEARCH=0;
ENABLE_SUBJACK=0;
ENABLE_CORSTEST=0;
ENABLE_S3SCANNER=0;
ENABLE_BFAC=0;
ENABLE_WHATWEB=0;
ENABLE_WAFW00F=0;
ENABLE_NIKTO=0;
ENABLE_MASSCAN=0;
ENABLE_NMAP=0;
ENABLE_SCREENSHOTS=0;
ENABLE_RESCOPE=0;
ENABLE_KNOCK=0;
# Other variables
ALL_IP=all_discovered_ips.txt;
ALL_DOMAIN=all_discovered_domains.txt;
ALL_RESOLVED=all_resolved_domains.txt;
function set_tool_paths() {
# If tool paths have not been set, set them
if [[ "$TOOL_PATH_SET" -eq 0 ]]; then
TOOL_PATH_SET=1;
SUBFINDER=$(which subfinder);
SUBJACK=$(which subjack);
FFUF=$(which ffuf);
WHATWEB=$(which whatweb);
WAFW00F=$(which wafw00f);
GOBUSTER=$(which gobuster);
CHROMIUM=$(which chromium);
NMAP=$(which nmap);
MASSCAN=$(which masscan);
NIKTO=$(which nikto);
INCEPTION=$(which inception);
WAYBACKURLS=$(which waybackurls);
GOALTDNS=$(which goaltdns);
RESCOPE=$(which rescope);
KNOCK=$(which knockpy);
HTTPROBE=$(which httprobe);
SUBLIST3R=$TOOL_PATH/Sublist3r/sublist3r.py;
DNSCAN=$TOOL_PATH/dnscan/dnscan.py;
MASSDNS_BIN=$TOOL_PATH/massdns/bin/massdns;
MASSDNS_RESOLVERS=resolvers.txt;
AQUATONE=$TOOL_PATH/aquatone/aquatone;
BFAC=$TOOL_PATH/bfac/bfac;
DIRSEARCH=$TOOL_PATH/dirsearch/dirsearch.py;
SNALLY=$TOOL_PATH/snallygaster/snallygaster;
CORSTEST=$TOOL_PATH/CORStest/corstest.py;
S3SCANNER=$TOOL_PATH/S3Scanner/s3scanner.py;
AMASS=$TOOL_PATH/amass/amass;
else
return;
fi
}
function banner() {
BANNER='
*****************************************************************************************************
* ______ __ ______ *
* / \/ | / \ *
* /$$$$$$ $$ |____ ______ _____ ____ ______ /$$$$$$ | _______ ______ _______ *
* $$ | $$/$$ \ / \/ \/ \ / \ $$ \__$$/ / |/ \/ \ *
* $$ | $$$$$$$ /$$$$$$ $$$$$$ $$$$ /$$$$$$ | $$ \/$$$$$$$/ $$$$$$ $$$$$$$ | *
* $$ | __$$ | $$ $$ | $$ $$ | $$ | $$ $$ | $$ | $$$$$$ $$ | / $$ $$ | $$ | *
* $$ \__/ $$ | $$ $$ \__$$ $$ | $$ | $$ $$ |__$$ | / \__$$ $$ \_____/$$$$$$$ $$ | $$ | *
* $$ $$/$$ | $$ $$ $$/$$ | $$ | $$ $$ $$/ $$ $$/$$ $$ $$ $$ | $$ | *
* $$$$$$/ $$/ $$/ $$$$$$/ $$/ $$/ $$/$$$$$$$/ $$$$$$/ $$$$$$$/ $$$$$$$/$$/ $$/ *
* $$ | *
* $$ | *
* $$/ *
* *
*****************************************************************************************************
By SolomonSklash - github.com/SolomonSklash/chomp-scan - [email protected]
';
echo -e "$BLUE""$BANNER";
}
function usage() {
banner;
echo -e "$GREEN""chomp-scan.sh -u example.com -a d short -cC large -p -o path/to/directory\\n""$NC";
echo -e "$GREEN""Usage of Chomp Scan:""$NC";
echo -e "$BLUE""\\t-u domain \\n\\t\\t$ORANGE (required) Domain name to scan. This should not include a scheme, e.g. https:// or http://.""$NC";
echo -e "$BLUE""\\t-L config-file \\n\\t\\t$ORANGE (optional) The path to a config file. This can be used to provide more granular control over what tools are run.""$NC";
echo -e "$BLUE""\\t-d wordlist\\n\\t\\t$ORANGE (optional) The wordlist to use for subdomain enumeration. Three built-in lists, short, long, and huge can be used, as well as the path to a custom wordlist. The default is short.""$NC";
echo -e "$BLUE""\\t-c \\n\\t\\t$ORANGE (optional) Enable content discovery phase. The wordlist for this option defaults to short if not provided.""$NC";
echo -e "$BLUE""\\t-C wordlist \\n\\t\\t$ORANGE (optional) The wordlist to use for content discovery. Five built-in lists, small, medium, large, xl, and xxl can be used, as well as the path to a custom wordlist. The default is small.""$NC";
echo -e "$BLUE""\\t-P file-path \\n\\t\\t$ORANGE (optional) Set a custom directory for the location of tools. The path must exist and the directory must contain all needed tools.""$NC";
echo -e "$BLUE""\\t-s \\n\\t\\t$ORANGE (optional) Enable screenshots using Aquatone.""$NC";
echo -e "$BLUE""\\t-i \\n\\t\\t$ORANGE (optional) Enable information gathering phase, using subjack, CORStest, S3Scanner, bfac, whatweb, wafw00f, httprobe, and nikto.""$NC";
echo -e "$BLUE""\\t-p \\n\\t\\t$ORANGE (optional) Enable portscanning phase, using masscan (run as root) and nmap.""$NC";
echo -e "$BLUE""\\t-I \\n\\t\\t$ORANGE (optional) Enable interactive mode. This allows you to select certain tool options and inputs interactively. This cannot be run with -D.""$NC";
echo -e "$BLUE""\\t-D \\n\\t\\t$ORANGE (optional) Enable default non-interactive mode. This mode uses pre-selected defaults and requires no user interaction or options. This cannot be run with -I.""$NC";
echo -e "\\t\\t\\t$ORANGE Options: Subdomain enumeration wordlist: short.""$NC";
echo -e "\\t\\t\\t$ORANGE Content discovery wordlist: small.""$NC";
echo -e "\\t\\t\\t$ORANGE Aquatone screenshots: yes.""$NC";
echo -e "\\t\\t\\t$ORANGE Portscanning: yes.""$NC";
echo -e "\\t\\t\\t$ORANGE Information gathering: yes.""$NC";
echo -e "\\t\\t\\t$ORANGE Domains to scan: all unique discovered.""$NC";
echo -e "$BLUE""\\t-b wordlist \\n\\t\\t$ORANGE (optional) Set custom domain blacklist file.""$NC";
echo -e "$BLUE""\\t-X wordlist \\n\\t\\t$ORANGE (optional) Set custom interesting word list.""$NC";
echo -e "$BLUE""\\t-o directory \\n\\t\\t$ORANGE (optional) Set custom output directory. It must exist and be writable.""$NC";
echo -e "$BLUE""\\t-n string \\n\\t\\t$ORANGE (optional) Notica URL parameter for notification when the script has completed. See notica.us for details.""$NC";
echo -e "$BLUE""\\t-a \\n\\t\\t$ORANGE (optional) Use all unique discovered domains for scans, rather than interesting domains. This cannot be used with -A.""$NC";
echo -e "$BLUE""\\t-A \\n\\t\\t$ORANGE (optional, default) Use only interesting discovered domains for scans, rather than all discovered domains. This cannot be used with -a.""$NC";
echo -e "$BLUE""\\t-H \\n\\t\\t$ORANGE (optional) Use HTTP for connecting to sites instead of HTTPS.""$NC";
echo -e "$BLUE""\\t-r \\n\\t\\t$ORANGE (optional) Enable creation of Burp scope JSON file with rescope.""$NC";
echo -e "$BLUE""\\t-h \\n\\t\\t$ORANGE (optional) Display this help page.""$NC";
}
# Check that a file path exists and is not empty
function exists() {
if [[ -e "$1" ]]; then
if [[ -s "$1" ]]; then
return 1;
else
return 0;
fi
else
return 0;
fi
}
# Check for root for runs using masscan
function check_root() {
if [[ $EUID -ne 0 ]]; then
while true; do
echo -e "$ORANGE""[!] Please note: Script is not being run as root."
echo -e "$ORANGE""[!] Provided script options include masscan, which must run as root."
echo -e "$ORANGE""[!] The script will hang while waiting for the sudo password."
echo -e "$ORANGE""[!] If you are using Notica notifications, you will be notified when the sudo password is needed."
read -rp "Do you want to exit and [R]e-run as root, [S]kip masscan, or [E]nter sudo password? " CHOICE;
case $CHOICE in
[rR]* )
echo -e "$RED""[!] Exiting script.""$NC";
exit 1;
;;
[sS]* )
echo -e "$ORANGE""Skipping masscan.""$NC";
SKIP_MASSCAN=1;
break;
;;
[eE]* )
echo -e "$ORANGE""Script will wait for sudo password.""$NC";
break;
;;
* )
echo -e "$ORANGE""Please enter [R]e-run, [S]kip masscan, or [E]nter sudo password.""$NC";
;;
esac
done
fi
}
# Parse configuration file
function parse_config() {
# Parse [general]
DOMAIN=$(grep '^DOMAIN' "$CONFIG_FILE" | cut -d '=' -f 2);
if [[ "$DOMAIN" == "" ]]; then
echo -e "$RED""[!] No domain was provided in the configuration file.""$NC";
exit 1;
else
DOMAIN_COUNT=$(echo "$DOMAIN" | awk -F "," "{ print NF }")
if [[ "$DOMAIN_COUNT" -gt 1 ]]; then
DOMAIN_ARRAY=();
for (( i=1; i<=$DOMAIN_COUNT; i++ )); do
DOMAIN_ARRAY+=($(echo $DOMAIN | cut -d ',' -f $i | tr -d " "));
done
fi
fi
if [[ $(grep '^ENABLE_HTTP' "$CONFIG_FILE" | cut -d '=' -f 2) == "YES" ]]; then
HTTP="http";
fi
OUTPUT_DIR=$(grep '^OUTPUT_DIR' "$CONFIG_FILE" | cut -d '=' -f 2);
if [[ "$OUTPUT_DIR" != "" ]]; then
if [[ -w "$OUTPUT_DIR" ]]; then
CUSTOM_WORKING_DIR="$OUTPUT_DIR";
else
echo -e "$RED""[!] Output directory $OUTPUT_DIR does not exist or is not writable. Please check the configuration file.""$NC";
exit 1;
fi
fi
if [[ $(grep '^USE_ALL' "$CONFIG_FILE" | cut -d '=' -f 2) == "YES" ]]; then
USE_ALL=1;
fi
if [[ $(grep '^NOTICA' "$CONFIG_FILE" | cut -d '=' -f 2) != "" ]]; then
NOTICA=$(grep '^NOTICA' "$CONFIG_FILE" | cut -d '=' -f 2)
fi
BLACKLIST_FILE=$(grep '^BLACKLIST' "$CONFIG_FILE" | cut -d '=' -f 2);
if [[ "$BLACKLIST_FILE" != "" ]]; then
if [[ -w "$BLACKLIST_FILE" ]]; then
BLACKLIST="$BLACKLIST_FILE";
else
echo -e "$RED""[!] Blacklist file $BLACKLIST_FILE does not exist or is not writable. Please check the configuration file.""$NC";
exit 1;
fi
fi
INTERESTING_FILE=$(grep '^INTERESTING' "$CONFIG_FILE" | cut -d '=' -f 2);
if [[ "$INTERESTING_FILE" != "" ]]; then
if [[ -w "$INTERESTING_FILE" ]]; then
INTERESTING="$INTERESTING_FILE";
else
echo -e "$RED""[!] Interesting file $INTERESTING_FILE does not exist or is not writable. Please check the configuration file.""$NC";
exit 1;
fi
fi
CONFIG_TOOL_PATH=$(grep '^TOOL_PATH' "$CONFIG_FILE" | cut -d '=' -f 2);
if [[ "$CONFIG_TOOL_PATH" != "" ]]; then
if [[ -w "$CONFIG_TOOL_PATH" ]]; then
TOOL_PATH="$CONFIG_TOOL_PATH";
set_tool_paths;
else
echo -e "$RED""[!] Custom tool path $CONFIG_TOOL_PATH does not exist or is not writable. Please check the configuration file.""$NC";
exit 1;
fi
fi
if [[ $(grep '^ENABLE_RESCOPE' "$CONFIG_FILE" | cut -d '=' -f 2) == "YES" ]]; then
ENABLE_RESCOPE=1;
fi
# Parse [subdomain enumeration]
if [[ $(grep '^ENABLE_DNSCAN' "$CONFIG_FILE" | cut -d '=' -f 2) == "YES" ]]; then
ENABLE_DNSCAN=1;
fi
if [[ $(grep '^ENABLE_SUBFINDER' "$CONFIG_FILE" | cut -d '=' -f 2) == "YES" ]]; then
ENABLE_SUBFINDER=1;
fi
if [[ $(grep '^ENABLE_SUBLIST3R' "$CONFIG_FILE" | cut -d '=' -f 2) == "YES" ]]; then
ENABLE_SUBLIST3R=1;
fi
if [[ $(grep '^ENABLE_KNOCK' "$CONFIG_FILE" | cut -d '=' -f 2) == "YES" ]]; then
ENABLE_KNOCK=1;
fi
if [[ $(grep '^ENABLE_GOALTDNS' "$CONFIG_FILE" | cut -d '=' -f 2) == "YES" ]]; then
ENABLE_GOALTDNS=1;
fi
if [[ $(grep '^ENABLE_AMASS' "$CONFIG_FILE" | cut -d '=' -f 2) == "YES" ]]; then
ENABLE_AMASS=1;
fi
SUB_WORDLIST=$(grep '^SUBDOMAIN_WORDLIST' "$CONFIG_FILE" | cut -d '=' -f 2);
# Set to one of the defaults, else use provided wordlist
case "$SUB_WORDLIST" in
SHORT )
SUBDOMAIN_WORDLIST="$SHORT";
;;
LONG )
SUBDOMAIN_WORDLIST="$LONG";
;;
HUGE )
SUBDOMAIN_WORDLIST="$HUGE";
;;
esac
if [[ "$SUBDOMAIN_WORDLIST" == "" ]]; then
if [[ "$SUB_WORDLIST" != "" ]]; then
if [[ -w "$SUB_WORDLIST" ]]; then
SUBDOMAIN_WORDLIST="$SUB_WORDLIST";
else
echo -e "$RED""[!] Subdomain enumeration wordlist $SUB_WORDLIST does not exist or is not writable. Please check the configuration file.""$NC";
exit 1;
fi
fi
fi
# Check that at least one subdomain enumeration tool is enabled
if [[ "$ENABLE_DNSCAN" -eq 0 ]] && [[ "$ENABLE_SUBFINDER" -eq 0 ]] && [[ "$ENABLE_SUBLIST3R" -eq 0 ]] && [[ "$ENABLE_KNOCK" -eq 0 ]] && [[ "$ENABLE_AMASS" -eq 0 ]]; then
echo -e "$RED""[!] At least one subdomain enumeration tool must be enabled. Please check the configuration file.""$NC";
exit 1;
fi
# Parse [content discovery]
if [[ $(grep '^ENABLE_INCEPTION' "$CONFIG_FILE" | cut -d '=' -f 2) == "YES" ]]; then
ENABLE_INCEPTION=1;
fi
if [[ $(grep '^ENABLE_WAYBACKURLS' "$CONFIG_FILE" | cut -d '=' -f 2) == "YES" ]]; then
ENABLE_WAYBACKURLS=1;
fi
if [[ $(grep '^ENABLE_FFUF' "$CONFIG_FILE" | cut -d '=' -f 2) == "YES" ]]; then
ENABLE_FFUF=1;
fi
if [[ $(grep '^ENABLE_GOBUSTER' "$CONFIG_FILE" | cut -d '=' -f 2) == "YES" ]]; then
ENABLE_GOBUSTER=1;
fi
if [[ $(grep '^ENABLE_DIRSEARCH' "$CONFIG_FILE" | cut -d '=' -f 2) == "YES" ]]; then
ENABLE_DIRSEARCH=1;
fi
CON_WORDLIST=$(grep '^CONTENT_WORDLIST' "$CONFIG_FILE" | cut -d '=' -f 2);
# Set to one of the defaults, else use provided wordlist
case "$CON_WORDLIST" in
SMALL )
CONTENT_WORDLIST="$SMALL";
;;
MEDIUM )
CONTENT_WORDLIST="$MEDIUM";
;;
LARGE )
CONTENT_WORDLIST="$LARGE";
;;
XL )
CONTENT_WORDLIST="$XL";
;;
XXL )
CONTENT_WORDLIST="$XXL";
;;
esac
if [[ "$CONTENT_WORDLIST" == "" ]]; then
if [[ "$CON_WORDLIST" != "" ]]; then
if [[ -w "$CON_WORDLIST" ]]; then
CONTENT_WORDLIST="$CON_WORDLIST";
else
echo -e "$RED""[!] Content discovery wordlist $CON_WORDLIST does not exist or is not writable. Please check the configuration file.""$NC";
exit 1;
fi
fi
fi
# Parse [information gathering]
if [[ $(grep '^ENABLE_SUBJACK' "$CONFIG_FILE" | cut -d '=' -f 2) == "YES" ]]; then
ENABLE_SUBJACK=1;
fi
if [[ $(grep '^ENABLE_CORSTEST' "$CONFIG_FILE" | cut -d '=' -f 2) == "YES" ]]; then
ENABLE_CORSTEST=1;
fi
if [[ $(grep '^ENABLE_S3SCANNER' "$CONFIG_FILE" | cut -d '=' -f 2) == "YES" ]]; then
ENABLE_S3SCANNER=1;
fi
if [[ $(grep '^ENABLE_BFAC' "$CONFIG_FILE" | cut -d '=' -f 2) == "YES" ]]; then
ENABLE_BFAC=1;
fi
if [[ $(grep '^ENABLE_WHATWEB' "$CONFIG_FILE" | cut -d '=' -f 2) == "YES" ]]; then
ENABLE_WHATWEB=1;
fi
if [[ $(grep '^ENABLE_WAFW00F' "$CONFIG_FILE" | cut -d '=' -f 2) == "YES" ]]; then
ENABLE_WAFW00F=1;
fi
if [[ $(grep '^ENABLE_HTTPROBE' "$CONFIG_FILE" | cut -d '=' -f 2) == "YES" ]]; then
ENABLE_HTTPROBE=1;
fi
if [[ $(grep '^ENABLE_NIKTO' "$CONFIG_FILE" | cut -d '=' -f 2) == "YES" ]]; then
ENABLE_NIKTO=1;
fi
# Parse [port scanning]
if [[ $(grep '^ENABLE_MASSCAN' "$CONFIG_FILE" | cut -d '=' -f 2) == "YES" ]]; then
check_root
ENABLE_MASSCAN=1;
fi
if [[ $(grep '^ENABLE_NMAP' "$CONFIG_FILE" | cut -d '=' -f 2) == "YES" ]]; then
ENABLE_NMAP=1;
fi
# Parse [screenshots]
if [[ $(grep '^ENABLE_SCREENSHOTS' "$CONFIG_FILE" | cut -d '=' -f 2) == "YES" ]]; then
ENABLE_SCREENSHOTS=1;
fi
}
# Handle CLI arguments
while getopts ":hu:d:L:C:sicb:IaADX:po:Hn:P:r" opt; do
case ${opt} in
h ) # -h help
usage;
exit;
;;
u ) # -u URL/domain
DOMAIN=$OPTARG;
;;
L ) # -L configuration file
exists "$OPTARG";
RESULT=$?;
if [[ "$RESULT" -eq 1 ]]; then
CONFIG_FILE="$OPTARG";
parse_config;
else
echo -e "$RED""[!] Provided configuration file $OPTARG is empty or doesn't exist.""$NC";
usage;
exit 1;
fi
# Exit early if config file is found
break;
;;
d ) # -d subdomain enumeration wordlist
# Set to one of the defaults, else use provided wordlist
case "$OPTARG" in
short )
SUBDOMAIN_WORDLIST="$SHORT";
;;
long )
SUBDOMAIN_WORDLIST="$LONG";
;;
huge )
SUBDOMAIN_WORDLIST="$HUGE";
;;
esac
if [[ "$SUBDOMAIN_WORDLIST" == "" ]]; then
exists "$OPTARG";
RESULT=$?;
if [[ "$RESULT" -eq 1 ]]; then
SUBDOMAIN_WORDLIST="$OPTARG";
else
echo -e "$RED""[!] Provided subdomain enumeration wordlist $OPTARG is empty or doesn't exist.""$NC";
usage;
exit 1;
fi
fi
;;
C ) # -C content discovery wordlist
# Set to one of the defaults, else use provided wordlist
case "$OPTARG" in
small )
CONTENT_WORDLIST="$SMALL";
;;
medium )
CONTENT_WORDLIST="$MEDIUM";
;;
large )
CONTENT_WORDLIST="$LARGE";
;;
xl )
CONTENT_WORDLIST="$XL";
;;
xxl )
CONTENT_WORDLIST="$XXL";
;;
esac
if [[ "$CONTENT_WORDLIST" == "" ]]; then
exists "$OPTARG";
RESULT=$?;
if [[ "$RESULT" -eq 1 ]]; then
CONTENT_WORDLIST="$OPTARG";
else
echo -e "$RED""[!] Provided content discovery wordlist $OPTARG is empty or doesn't exist.""$NC";
usage;
exit 1;
fi
fi
;;
c ) # -c enable content discovery
CONTENT_DISCOVERY=1;
;;
s ) # -s enable screenshots
SCREENSHOTS=1;
;;
i ) # -i enable information gathering
INFO_GATHERING=1;
;;
b ) # -b domain blacklist file
exists "$OPTARG";
RESULT=$?;
if [[ "$RESULT" -eq 1 ]]; then
BLACKLIST="$OPTARG";
else
echo -e "$RED""[!] Provided blacklist $OPTARG is empty or doesn't exist.""$NC";
usage;
exit 1;
fi
;;
I ) # -I enable interactive mode
INTERACTIVE=1;
;;
a ) # -a use all discovered domains
echo "Use all discovered domains."
# Check that USE_DISCOVERED is not set
if [[ "$USE_DISCOVERED" != 1 ]]; then
USE_ALL=1;
else
echo -e "$RED""[!] Using -A interesting domains is mutually exclusive to using -a all domains.""$NC";
usage;
exit 1;
fi
;;
A ) # -A use only interesting discovered domains
# Check that USE_DISCOVERED is not set
if [[ "$USE_ALL" != 1 ]]; then
USE_DISCOVERED=1;
else
echo -e "$RED""[!] Using -a all domains is mutually exclusive to using -A interesting domains.""$NC";
usage;
exit 1;
fi
echo "Use only interesting discovered domains."
;;
D ) # -D enable default non-interactive mode
DEFAULT_MODE=1;
;;
X ) # -X interesting word list file
exists "$OPTARG";
RESULT=$?;
if [[ "$RESULT" -eq 1 ]]; then
INTERESTING="$OPTARG";
else
echo -e "$RED""[!] Provided interesting words file $OPTARG is empty or doesn't exist.""$NC";
usage;
exit 1;
fi
;;
p ) # -p enable port scanning
PORTSCANNING=1;
;;
P ) # -P custom tool path
exists "$OPTARG";
RESULT=$?;
if [[ "$RESULT" -eq 1 ]]; then
TOOL_PATH="$OPTARG";
set_tool_paths;
else
echo -e "$RED""[!] Provided tool path $OPTARG is empty or doesn't exist.""$NC";
usage;
exit 1;
fi
;;
o ) # -o output directory
if [[ -w "$OPTARG" ]]; then
WORKING_DIR="$OPTARG";
CUSTOM_WORKING_DIR="$OPTARG";
else
echo -e "$RED""[!] Provided output directory $OPTARG is not writable or doesn't exist.""$NC";
usage;
exit 1;
fi
;;
H ) # -H enable HTTP for URLs
HTTP="http";
;;
n ) # -n Notica URL parameter
NOTICA="$OPTARG";
;;
r ) # -r run rescope
ENABLE_RESCOPE=1;
;;
\? ) # Invalid option
echo -e "$RED""[!] Invalid Option: -$OPTARG" 1>&2;
usage;
exit 1;
;;
: ) # Invalid option
echo -e "$RED""[!] Invalid Option: -$OPTARG requires an argument" 1>&2;
usage;
exit 1;
;;
* ) # Invalid option
echo -e "$RED""[!] Invalid Option: -$OPTARG" 1>&2;
usage;
exit 1;
;;
esac
done
shift $((OPTIND -1));
function check_paths() {
# Check if paths haven't been set and set them
set_tool_paths;
# Check for Debian/Ubuntu and set proper paths
grep 'Ubuntu' /etc/issue 1>/dev/null;
UBUNTU="$?";
if [[ "$UBUNTU" -eq 0 ]]; then
CHROMIUM=$(command -v chromium-browser);
fi
grep 'Debian' /etc/issue 1>/dev/null;
DEBIAN="$?";
if [[ "$DEBIAN" -eq 0 ]]; then
NIKTO="$TOOL_PATH/nikto/program/nikto.pl";
fi
# Check that all paths are set
if [[ "$SUBFINDER" == "" ]] || [[ ! -f "$SUBFINDER" ]]; then
echo -e "$RED""[!] The path or the file specified by the path for subfinder does not exit.";
exit 1;
fi
if [[ "$SUBJACK" == "" ]] || [[ ! -f "$SUBJACK" ]]; then
echo -e "$RED""[!] The path or the file specified by the path for subjack does not exit.";
exit 1;
fi
if [[ "$FFUF" == "" ]] || [[ ! -f "$FFUF" ]]; then
echo -e "$RED""[!] The path or the file specified by the path for ffuf does not exit.";
exit 1;
fi
if [[ "$WHATWEB" == "" ]] || [[ ! -f "$WHATWEB" ]]; then
echo -e "$RED""[!] The path or the file specified by the path for whatweb does not exit.";
exit 1;
fi
if [[ "$WAFW00F" == "" ]] || [[ ! -f "$WAFW00F" ]]; then
echo -e "$RED""[!] The path or the file specified by the path for wafw00f does not exit.";
exit 1;
fi
if [[ "$GOBUSTER" == "" ]] || [[ ! -f "$GOBUSTER" ]]; then
echo -e "$RED""[!] The path or the file specified by the path for gobuster does not exit.";
exit 1;
fi
if [[ "$CHROMIUM" == "" ]] || [[ ! -f "$CHROMIUM" ]]; then
echo -e "$RED""[!] The path or the file specified by the path for chromium does not exit.";
exit 1;
fi
if [[ "$NMAP" == "" ]] || [[ ! -f "$NMAP" ]]; then
echo -e "$RED""[!] The path or the file specified by the path for nmap does not exit.";
exit 1;
fi
if [[ "$MASSCAN" == "" ]] || [[ ! -f "$MASSCAN" ]]; then
echo -e "$RED""[!] The path or the file specified by the path for masscan does not exit.";
exit 1;
fi
# if [[ "$INCEPTION" == "" ]] || [[ ! -f "$INCEPTION" ]]; then
# echo -e "$RED""[!] The path or the file specified by the path for inception does not exit.";
# exit 1;
# fi
if [[ "$WAYBACKURLS" == "" ]] || [[ ! -f "$WAYBACKURLS" ]]; then
echo -e "$RED""[!] The path or the file specified by the path for waybackurls does not exit.";
exit 1;
fi
if [[ "$GOALTDNS" == "" ]] || [[ ! -f "$GOALTDNS" ]]; then
echo -e "$RED""[!] The path or the file specified by the path for goaltdns does not exit.";
exit 1;
fi
if [[ "$SUBLIST3R" == "" ]] || [[ ! -f "$SUBLIST3R" ]]; then
grep 'Kali' /etc/issue 1>/dev/null;
KALI=$?;
if [[ "$KALI" -eq 0 ]]; then
SUBLIST3R=$(command -v sublist3r);
else
echo -e "$RED""[!] The path or the file specified by the path for sublist3r does not exit.";
exit 1;
fi
fi
if [[ "$DNSCAN" == "" ]] || [[ ! -f "$DNSCAN" ]]; then
echo -e "$RED""[!] The path or the file specified by the path for dnscan does not exit.";
exit 1;
fi
if [[ "$MASSDNS_BIN" == "" ]] || [[ ! -f "$MASSDNS_BIN" ]]; then
echo -e "$RED""[!] The path or the file specified by the path for the massdns binary does not exit.";
exit 1;
fi
if [[ "$MASSDNS_RESOLVERS" == "" ]] || [[ ! -f "$MASSDNS_RESOLVERS" ]]; then
echo -e "$RED""[!] The path or the file specified by the path for massdns resolver file does not exit.";
exit 1;
fi
if [[ "$AQUATONE" == "" ]] || [[ ! -f "$AQUATONE" ]]; then
echo -e "$RED""[!] The path or the file specified by the path for aquatone does not exit.";
exit 1;
fi
if [[ "$BFAC" == "" ]] || [[ ! -f "$BFAC" ]]; then
echo -e "$RED""[!] The path or the file specified by the path for bfac does not exit.";
exit 1;
fi
if [[ "$DIRSEARCH" == "" ]] || [[ ! -f "$DIRSEARCH" ]]; then
echo -e "$RED""[!] The path or the file specified by the path for dirsearch does not exit.";
exit 1;
fi
if [[ "$CORSTEST" == "" ]] || [[ ! -f "$CORSTEST" ]]; then
echo -e "$RED""[!] The path or the file specified by the path for CORStest does not exit.";
exit 1;
fi
if [[ "$S3SCANNER" == "" ]] || [[ ! -f "$S3SCANNER" ]]; then
echo -e "$RED""[!] The path or the file specified by the path for S3Scanner does not exit.";
exit 1;
fi
if [[ "$AMASS" == "" ]] || [[ ! -f "$AMASS" ]]; then
echo -e "$RED""[!] The path or the file specified by the path for amass does not exit.";
exit 1;
fi
if [[ "$RESCOPE" == "" ]] || [[ ! -f "$RESCOPE" ]]; then
echo -e "$RED""[!] The path or the file specified by the path for rescope does not exit.";
exit 1;
fi
if [[ "$KNOCK" == "" ]] || [[ ! -f "$KNOCK" ]]; then
echo -e "$RED""[!] The path or the file specified by the path for knockpy does not exit.";
exit 1;
fi
if [[ "$HTTPROBE" == "" ]] || [[ ! -f "$HTTPROBE" ]]; then
echo -e "$RED""[!] The path or the file specified by the path for httprobe does not exit.";
exit 1;
fi
}
function unique() {
# Remove blacklisted domains from all discovered domains
if [[ ! -z $BLACKLIST ]]; then
while read -r bad; do
grep -v "$bad" "$WORKING_DIR"/$ALL_DOMAIN > "$WORKING_DIR"/temp;
mv "$WORKING_DIR"/temp "$WORKING_DIR"/$ALL_DOMAIN;
done < "$BLACKLIST";
fi
# Remove blacklisted domains from all resolved domains
if [[ ! -z $BLACKLIST ]]; then
while read -r bad; do
grep -v "$bad" "$WORKING_DIR"/$ALL_RESOLVED > "$WORKING_DIR"/temp1;
mv "$WORKING_DIR"/temp1 "$WORKING_DIR"/$ALL_RESOLVED;
done < "$BLACKLIST";
fi
# Get unique list of IPs and domains, ignoring case
sort "$WORKING_DIR"/$ALL_DOMAIN | uniq -i > "$WORKING_DIR"/temp2;
mv "$WORKING_DIR"/temp2 "$WORKING_DIR"/$ALL_DOMAIN;
sort -V "$WORKING_DIR"/$ALL_IP | uniq -i > "$WORKING_DIR"/temp2;
mv "$WORKING_DIR"/temp2 "$WORKING_DIR"/$ALL_IP;
sort "$WORKING_DIR"/$ALL_RESOLVED | uniq -i > "$WORKING_DIR"/temp3;
mv "$WORKING_DIR"/temp3 "$WORKING_DIR"/$ALL_RESOLVED;
}
function list_found() {
unique;
echo -e "$GREEN""[+] Found $(wc -l "$WORKING_DIR"/$ALL_IP | awk '{print $1}') unique IPs so far.""$NC"
echo -e "$GREEN""[+] Found $(wc -l "$WORKING_DIR"/$ALL_DOMAIN | awk '{print $1}') unique discovered domains so far.""$NC"
echo -e "$GREEN""[+] Found $(wc -l "$WORKING_DIR"/$ALL_RESOLVED | awk '{print $1}') unique resolvable domains so far.""$NC"
}
function get_interesting() {
# Takes optional silent argument as $1
while read -r word; do
grep "$word" "$WORKING_DIR"/$ALL_RESOLVED >> "$WORKING_DIR"/"$INTERESTING_DOMAINS";
done < "$INTERESTING";
# Make sure no there are duplicates
sort -u "$WORKING_DIR"/"$INTERESTING_DOMAINS" > "$WORKING_DIR"/temp4;
mv "$WORKING_DIR"/temp4 "$WORKING_DIR"/"$INTERESTING_DOMAINS";
if [[ "$1" == "silent" ]]; then
return;
else
# Make sure > 0 domains are found
FOUND=$(wc -l "$WORKING_DIR"/"$INTERESTING_DOMAINS" | awk '{print $1}');
if [[ $FOUND -gt 0 ]]; then
echo -e "$RED""[!] The following $(wc -l "$WORKING_DIR"/"$INTERESTING_DOMAINS" | awk '{print $1}') potentially interesting subdomains have been found ($WORKING_DIR/$INTERESTING_DOMAINS):""$ORANGE";
cat "$WORKING_DIR"/"$INTERESTING_DOMAINS";
sleep 1;
else
echo -e "$RED""[!] No interesting domains have been found yet.""$NC";
sleep 1;
fi
fi
}
function cancel() {
echo -e "$RED""\\n[!] Cancelling command.""$NC";
}
function run_dnscan() {
# Call with domain as $1 and wordlist as $2
# Trap SIGINT so broken dnscan runs can be cancelled
trap cancel SIGINT;
echo -e "$GREEN""[i]$BLUE Scanning $1 with dnscan.""$NC";
echo -e "$GREEN""[i]$ORANGE Command: $DNSCAN -d $1 -t 25 -o $WORKING_DIR/dnscan_out.txt -w $2.""$NC";
START=$(date +%s);
$DNSCAN -d "$1" -t 25 -o "$WORKING_DIR"/dnscan_out.txt -w "$2";
END=$(date +%s);
DIFF=$(( END - START ));
# Remove headers and leading spaces
sed '1,/A records/d' "$WORKING_DIR"/dnscan_out.txt | tr -d ' ' > "$WORKING_DIR"/trimmed;
cut "$WORKING_DIR"/trimmed -d '-' -f 1 > "$WORKING_DIR"/dnscan-ips.txt;
cut "$WORKING_DIR"/trimmed -d '-' -f 2 > "$WORKING_DIR"/dnscan-domains.txt;
rm "$WORKING_DIR"/trimmed;
# Cat output into main lists
cat "$WORKING_DIR"/dnscan-ips.txt >> "$WORKING_DIR"/$ALL_IP;
cat "$WORKING_DIR"/dnscan-domains.txt >> "$WORKING_DIR"/"$ALL_DOMAIN";
echo -e "$GREEN""[i]$BLUE dnsscan took $DIFF seconds to run.""$NC";
echo -e "$GREEN""[!]$ORANGE dnscan found $(wc -l "$WORKING_DIR"/dnscan-ips.txt | awk '{print $1}') IP/domain pairs.""$NC";
list_found;
sleep 1;
# Check if Ctrl+C was pressed and added to domain and IP files
grep -v 'KeyboardInterrupt' "$WORKING_DIR"/"$ALL_DOMAIN" > "$WORKING_DIR"/tmp;
mv "$WORKING_DIR"/tmp "$WORKING_DIR"/"$ALL_DOMAIN";
grep -v 'KeyboardInterrupt' "$WORKING_DIR"/"$ALL_IP" > "$WORKING_DIR"/tmp2;
mv "$WORKING_DIR"/tmp2 "$WORKING_DIR"/"$ALL_IP";
}
function run_subfinder() {
# Call with domain as $1 and wordlist as $2
# Trap SIGINT so broken subfinder runs can be cancelled
trap cancel SIGINT;
# Check for wordlist argument, else run without
echo -e "$GREEN""[i]$BLUE Scanning $1 with subfinder.""$NC";
echo -e "$GREEN""[i]$ORANGE Command: subfinder -nW -v --timeout 5 -d $1 -o $WORKING_DIR/subfinder-domains.txt -t 25.""$NC";
START=$(date +%s);
"$SUBFINDER" -nW -v --timeout 5 -d "$1" -o "$WORKING_DIR"/subfinder-domains.txt -t 25;
END=$(date +%s);
DIFF=$(( END - START ));
cat "$WORKING_DIR"/subfinder-domains.txt >> "$WORKING_DIR"/$ALL_DOMAIN;
echo -e "$GREEN""[i]$BLUE Subfinder took $DIFF seconds to run.""$NC";
echo -e "$GREEN""[!]$ORANGE Subfinder found $(wc -l "$WORKING_DIR"/subfinder-domains.txt | awk '{print $1}') domains.""$NC";
list_found;
sleep 1;
}
function run_sublist3r() {
# Call with domain as $1, doesn't support wordlists
# Trap SIGINT so broken sublist3r runs can be cancelled
trap cancel SIGINT;
echo -e "$GREEN""[i]$BLUE Scanning $1 with sublist3r.""$NC";
echo -e "$GREEN""[i]$ORANGE Command: $SUBLIST3R -d $1 -v -t 50 -o $WORKING_DIR/sublist3r-output.txt.""$NC";
START=$(date +%s);
"$SUBLIST3R" -d "$1" -v -t 50 -o "$WORKING_DIR"/sublist3r-output.txt
END=$(date +%s);
DIFF=$(( END - START ));
# Check that output file exists
if [[ -f "$WORKING_DIR"/sublist3r-output.txt ]]; then
# Cat output into main lists
cat "$WORKING_DIR"/sublist3r-output.txt >> "$WORKING_DIR"/$ALL_DOMAIN;
echo -e "$GREEN""[i]$BLUE sublist3r took $DIFF seconds to run.""$NC";
echo -e "$GREEN""[!]$ORANGE sublist3r found $(wc -l "$WORKING_DIR"/sublist3r-output.txt | awk '{print $1}') domains.""$NC";
fi
list_found;
sleep 1;
}
function run_knock() {
# Call with domain as $1 and wordlist as $2
# Trap SIGINT so broken knock runs can be cancelled
trap cancel SIGINT;
echo -e "$GREEN""[i]$BLUE Scanning $1 with knock.""$NC";
echo -e "$GREEN""[i]$ORANGE Command: knockpy $DOMAIN -w $2 -o $WORKING_DIR/knock-output.txt""$NC";
START=$(date +%s);
"$KNOCK" "$1" -w "$2" -o "$WORKING_DIR"/knock-output.txt;
END=$(date +%s);
DIFF=$(( END - START ));
# Parse output and add to all domain and IP lists
awk -F ',' '{print $2" "$3}' "$WORKING_DIR"/knock-output.txt | grep -e "$DOMAIN$" > "$WORKING_DIR"/knock-tmp.txt;
cut -d ' ' -f 1 "$WORKING_DIR"/knock-tmp.txt >> "$WORKING_DIR"/"$ALL_IP";
cut -d ' ' -f 2 "$WORKING_DIR"/knock-tmp.txt >> "$WORKING_DIR"/"$ALL_DOMAIN";
echo -e "$GREEN""[i]$BLUE knock took $DIFF seconds to run.""$NC";
echo -e "$GREEN""[!]$ORANGE knock found $(wc -l "$WORKING_DIR"/knock-tmp.txt | awk '{print $1}') domains.""$NC";
list_found;
sleep 1;
rm "$WORKING_DIR"/knock-tmp.txt;
}
function run_amass() {
# Call with domain as $1 and wordlist as $2
echo -e "$GREEN""[i]$BLUE Scanning $1 with amass.""$NC";
echo -e "$GREEN""[i]$ORANGE Command: amass enum -d $1 -w $2 -ip -rf resolvers.txt -active -o $WORKING_DIR/amass-output.txt -min-for-recursive 3 -bl $BLACKLIST""$NC";
START=$(date +%s);
"$AMASS" enum -d "$1" -brute -w "$2" -ipv4 -rf resolvers.txt -active -o "$WORKING_DIR"/amass-output.txt -min-for-recursive 3 -bl "$BLACKLIST";
END=$(date +%s);
DIFF=$(( END - START ));
# Check that output file exists amd parse output
if [[ -f "$WORKING_DIR"/amass-output.txt ]]; then
# Cat output into main lists
cut -d ' ' -f 1 "$WORKING_DIR"/amass-output.txt >> "$WORKING_DIR"/"$ALL_DOMAIN";
cut -d ' ' -f 2 "$WORKING_DIR"/amass-output.txt >> "$WORKING_DIR"/"$ALL_IP";
echo -e "$GREEN""[i]$BLUE amass took $DIFF seconds to run.""$NC";
echo -e "$GREEN""[!]$ORANGE amass found $(wc -l "$WORKING_DIR"/amass-output.txt | awk '{print $1}') domains.""$NC";
fi
list_found;
sleep 1;
}
function run_goaltdns() {
# Run goaltdns with found subdomains combined with altdns-wordlist.txt
echo -e "$GREEN""[i]$BLUE Running goaltdns against all $(wc -l "$WORKING_DIR"/$ALL_DOMAIN | awk '{print $1}') unique discovered subdomains to generate domains for masscan to resolve.""$NC";
echo -e "$GREEN""[i]$ORANGE Command: goaltdns -l $WORKING_DIR/$ALL_DOMAIN -w wordlists/altdns-words.txt -o $WORKING_DIR/goaltdns-output.txt.""$NC";
START=$(date +%s);
"$GOALTDNS" -l "$WORKING_DIR"/$ALL_DOMAIN -w wordlists/altdns-words.txt -o "$WORKING_DIR"/goaltdns-output.txt;
END=$(date +%s);
DIFF=$(( END - START ));
echo -e "$GREEN""[i]$BLUE Goaltdns took $DIFF seconds to run.""$NC";
echo -e "$GREEN""[i]$BLUE Goaltdns generated $(wc -l "$WORKING_DIR"/goaltdns-output.txt | awk '{print $1}') subdomains.""$NC";
sleep 1;
}
function run_massdns() {
# Call with domain as $1, wordlist as $2, and alone as $3
# Check if being called without goaltdns
if [[ "$3" == "alone" ]]; then
# Create wordlist with appended domain for massdns
sed "/.*/ s/$/\.$1/" $2 > "$WORKING_DIR"/massdns-appended.txt;
echo -e "$GREEN""[i]$BLUE Scanning $(cat "$WORKING_DIR"/$ALL_DOMAIN "$WORKING_DIR"/$ALL_IP "$WORKING_DIR"/massdns-appended.txt | sort | uniq | wc -l) current unique $1 domains with massdns (in quiet mode).""$NC";
echo -e "$GREEN""[i]$ORANGE Command: cat (all found domains and IPs) | $MASSDNS_BIN -r $MASSDNS_RESOLVERS -q -t A -o S -w $WORKING_DIR/massdns-result.txt.""$NC";
START=$(date +%s);
cat "$WORKING_DIR"/$ALL_DOMAIN "$WORKING_DIR"/$ALL_IP "$WORKING_DIR"/massdns-appended.txt | sort | uniq | $MASSDNS_BIN -r $MASSDNS_RESOLVERS -q -t A -o S -w "$WORKING_DIR"/massdns-result.txt;
END=$(date +%s);
DIFF=$(( END - START ));
else
# Run goaltdns to get altered domains to resolve along with other discovered domains
run_goaltdns;
# Create wordlist with appended domain for massdns
sed "/.*/ s/$/\.$1/" $2 > "$WORKING_DIR"/massdns-appended.txt;
echo -e "$GREEN""[i]$BLUE Scanning $(cat "$WORKING_DIR"/$ALL_DOMAIN "$WORKING_DIR"/$ALL_IP "$WORKING_DIR"/goaltdns-output.txt "$WORKING_DIR"/massdns-appended.txt | sort | uniq | wc -l) current unique $1 domains and IPs, goaltdns generated domains, and domain-appended wordlist with massdns (in quiet mode).""$NC";
echo -e "$GREEN""[i]$ORANGE Command: cat (all found domains and IPs) | $MASSDNS_BIN -r $MASSDNS_RESOLVERS -q -t A -o S -w $WORKING_DIR/massdns-result.txt.""$NC";
START=$(date +%s);
cat "$WORKING_DIR"/$ALL_DOMAIN "$WORKING_DIR"/$ALL_IP "$WORKING_DIR"/goaltdns-output.txt "$WORKING_DIR"/massdns-appended.txt | sort | uniq | $MASSDNS_BIN -r $MASSDNS_RESOLVERS -q -t A -o S -w "$WORKING_DIR"/massdns-result.txt;