-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathreconftw.sh
More file actions
executable file
·854 lines (807 loc) · 25.2 KB
/
reconftw.sh
File metadata and controls
executable file
·854 lines (807 loc) · 25.2 KB
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
#!/bin/bash
# shellcheck disable=SC2034,SC2154
# Defaults aimed at unattended execution (fail-soft)
set -o pipefail
set -E
set +e
IFS=$'\n\t'
# SC2034: Variables set here are used in sourced modules (modes.sh, vulns.sh, web.sh, etc.)
# SC2154: Variables like bred, reset, bgreen, yellow are defined in reconftw.cfg
# Standard exit/return codes (guard for re-source in test harnesses)
if [[ -z "${E_SUCCESS+x}" ]]; then
readonly E_SUCCESS=0
readonly E_GENERAL=1
readonly E_MISSING_DEP=2
readonly E_INVALID_INPUT=3
readonly E_NETWORK=4
readonly E_DISK_SPACE=5
readonly E_PERMISSION=6
readonly E_TIMEOUT=7
readonly E_CONFIG=8
fi
# Welcome to reconFTW main script
# ██▀███ ▓█████ ▄████▄ ▒█████ ███▄ █ █████▒▄▄▄█████▓ █ █░
# ▓██ ▒ ██▒▓█ ▀ ▒██▀ ▀█ ▒██▒ ██▒ ██ ▀█ █ ▓██ ▒ ▓ ██▒ ▓▒▓█░ █ ░█░
# ▓██ ░▄█ ▒▒███ ▒▓█ ▄ ▒██░ ██▒▓██ ▀█ ██▒▒████ ░ ▒ ▓██░ ▒░▒█░ █ ░█
# ▒██▀▀█▄ ▒▓█ ▄ ▒▓▓▄ ▄██▒▒██ ██░▓██▒ ▐▌██▒░▓█▒ ░ ░ ▓██▓ ░ ░█░ █ ░█
# ░██▓ ▒██▒░▒████▒▒ ▓███▀ ░░ ████▓▒░▒██░ ▓██░░▒█░ ▒██▒ ░ ░░██▒██▓
# ░ ▒▓ ░▒▓░░░ ▒░ ░░ ░▒ ▒ ░░ ▒░▒░▒░ ░ ▒░ ▒ ▒ ▒ ░ ▒ ░░ ░ ▓░▒ ▒
# ░▒ ░ ▒░ ░ ░ ░ ░ ▒ ░ ▒ ▒░ ░ ░░ ░ ▒░ ░ ░ ▒ ░ ░
# ░░ ░ ░ ░ ░ ░ ░ ▒ ░ ░ ░ ░ ░ ░ ░ ░
# ░ ░ ░░ ░ ░ ░ ░ ░
#
# Detect if the script is being run (not sourced) in macOS and re-exec with modern Bash.
# Supports both Apple Silicon (/opt/homebrew) and Intel (/usr/local) Homebrew prefixes.
if [[ "${BASH_SOURCE[0]}" == "${0}" && $OSTYPE == "darwin"* ]]; then
_mac_bash=""
for _candidate in /opt/homebrew/bin/bash /usr/local/bin/bash /bin/bash; do
if [[ -x "$_candidate" ]]; then
_major="$("$_candidate" -lc 'echo "${BASH_VERSINFO[0]}"' 2>/dev/null || echo 0)"
if [[ "$_major" =~ ^[0-9]+$ ]] && [[ "$_major" -ge 4 ]]; then
_mac_bash="$_candidate"
break
fi
fi
done
if [[ -n "$_mac_bash" ]] && [[ "$BASH" != "$_mac_bash" ]]; then
exec "$_mac_bash" "$0" "$@"
fi
unset _mac_bash _candidate _major
fi
# timeout/gtimeout compatibility
if command -v timeout >/dev/null 2>&1; then
TIMEOUT_CMD="timeout"
elif command -v gtimeout >/dev/null 2>&1; then
TIMEOUT_CMD="gtimeout"
else
TIMEOUT_CMD=""
fi
# Ensure a safe default for early log redirections
# If LOGFILE is unset or empty, send logs to /dev/null until later initialization
: "${LOGFILE:=/dev/null}"
###############################################################################################################
############################################## MODULE LOADING #################################################
###############################################################################################################
# Determine script path for module loading
# (full SCRIPTPATH is set later during config phase; use a temporary value here)
_INIT_SCRIPTPATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd -P)"
SCRIPTPATH="${_INIT_SCRIPTPATH}"
# Source libraries first (pure utilities)
source "${_INIT_SCRIPTPATH}/lib/validation.sh"
source "${_INIT_SCRIPTPATH}/lib/common.sh"
source "${_INIT_SCRIPTPATH}/lib/ui.sh"
source "${_INIT_SCRIPTPATH}/lib/parallel.sh"
# Source all modules in dependency order
source "${_INIT_SCRIPTPATH}/modules/utils.sh"
source "${_INIT_SCRIPTPATH}/modules/core.sh"
source "${_INIT_SCRIPTPATH}/modules/osint.sh"
source "${_INIT_SCRIPTPATH}/modules/subdomains.sh"
source "${_INIT_SCRIPTPATH}/modules/web.sh"
source "${_INIT_SCRIPTPATH}/modules/vulns.sh"
source "${_INIT_SCRIPTPATH}/modules/axiom.sh"
source "${_INIT_SCRIPTPATH}/modules/modes.sh"
# Normalize legacy-friendly AXIOM syntax:
# -v 20 -> -v --vps-count 20
function normalize_vps_count_args() {
local -a raw_args=("$@")
local -a normalized_args=()
local idx=0
local current next
while ((idx < ${#raw_args[@]})); do
current="${raw_args[idx]}"
if [[ "$current" == "-v" ]]; then
next="${raw_args[idx+1]:-}"
if validate_integer "$next" 1; then
normalized_args+=("-v" "--vps-count" "$next")
idx=$((idx + 2))
continue
fi
fi
normalized_args+=("$current")
idx=$((idx + 1))
done
printf '%s\0' "${normalized_args[@]}"
}
# Allow sourcing functions without execution (for testing)
# Must be checked before argument parsing to avoid side effects
if [[ "${1:-}" == "--source-only" ]]; then
return 0 2>/dev/null || exit 0
fi
###############################################################################################################
########################################### START SCRIPT #####################################################
###############################################################################################################
# macOS PATH initialization, thanks @0xtavian <3
if [[ $OSTYPE == "darwin"* ]]; then
if ! command -v brew &>/dev/null; then
_print_error "Brew is not installed or not in the PATH"
exit 1
fi
# Cache brew --prefix to avoid calling it 6+ times (100-300ms each)
_brew_prefix="$(brew --prefix)"
if [[ ! -x "${_brew_prefix}/opt/gnu-getopt/bin/getopt" ]]; then
_print_error "Brew formula gnu-getopt is not installed"
exit 1
fi
if [[ ! -d "${_brew_prefix}/opt/coreutils/libexec/gnubin" ]]; then
_print_error "Brew formula coreutils is not installed"
exit 1
fi
if [[ ! -d "${_brew_prefix}/opt/gnu-sed/libexec/gnubin" ]]; then
_print_error "Brew formula gnu-sed is not installed"
exit 1
fi
PATH="${_brew_prefix}/opt/gnu-getopt/bin:$PATH"
PATH="${_brew_prefix}/opt/coreutils/libexec/gnubin:$PATH"
PATH="${_brew_prefix}/opt/gnu-sed/libexec/gnubin:$PATH"
unset _brew_prefix
fi
CLI_ARGS=()
mapfile -d '' -t CLI_ARGS < <(normalize_vps_count_args "$@")
PROGARGS=$(getopt -o 'd:m:l:x:i:o:f:q:c:zrspanwvyh' --long 'domain:,list:,recon,subdomains,passive,all,web,osint,zen,deep,help,vps,vps-count:,ai,check-tools,health-check,quick-rescan,incremental,adaptive-rate,dry-run,parallel,no-parallel,monitor,monitor-interval:,monitor-cycles:,refresh-cache,gen-resolvers,force,export:,report-only,no-report,parallel-log:,quiet,verbose,no-color,log-format:,show-cache,banner,no-banner,legal' -n 'reconFTW' -- "${CLI_ARGS[@]}")
exit_status=$?
if [[ $exit_status -ne 0 ]]; then
UNKNOWN_ARGUMENT=true
fi
# Note the quotes around "$PROGARGS": they are essential!
# shellcheck disable=SC2086
eval set -- "$PROGARGS"
unset PROGARGS
CLI_PARALLEL_MODE=""
CLI_AXIOM_FLEET_COUNT=""
SHOW_CACHE=false
SHOW_BANNER=false
SHOW_LEGAL=false
while true; do
case "$1" in
'-d' | '--domain')
# Sanitize target input to prevent command injection
target_input="$2"
if [[ "$target_input" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+(/[0-9]+)?$ ]]; then
if ! domain=$(sanitize_ip "$target_input"); then
print_errorf "Invalid IP/CIDR provided: '%s'" "$target_input"
exit 1
fi
else
if ! domain=$(sanitize_domain "$target_input"); then
print_errorf "Invalid domain provided: '%s'" "$target_input"
exit 1
fi
fi
ipcidr_target "$domain"
shift 2
continue
;;
'-m')
multi=$2
shift 2
continue
;;
'-l' | '--list')
list="$2"
if ! validate_file_readable "$list"; then
print_errorf "List file not found or not readable: '%s'" "$list"
_print_msg WARN "Usage: -l <file> where file contains one target per line"
exit 1
fi
while IFS= read -r t || [[ -n "$t" ]]; do
[[ -z "$t" ]] && continue
t=$(_sanitize_list_entry "$t") || continue
ipcidr_target "$t" "$list"
done <"$list"
shift 2
continue
;;
'-x')
outOfScope_file=$2
if [[ -n "$outOfScope_file" ]] && ! validate_file_readable "$outOfScope_file"; then
print_errorf "Out-of-scope file not found or not readable: '%s'" "$outOfScope_file"
exit 1
fi
shift 2
continue
;;
'-i')
inScope_file=$2
if [[ -n "$inScope_file" ]] && ! validate_file_readable "$inScope_file"; then
print_errorf "In-scope file not found or not readable: '%s'" "$inScope_file"
exit 1
fi
shift 2
continue
;;
# modes
'-r' | '--recon')
opt_mode='r'
shift
continue
;;
'-s' | '--subdomains')
opt_mode='s'
shift
continue
;;
'-p' | '--passive')
opt_mode='p'
shift
continue
;;
'-a' | '--all')
opt_mode='a'
shift
continue
;;
'-w' | '--web')
opt_mode='w'
shift
continue
;;
'-n' | '--osint')
opt_mode='n'
shift
continue
;;
'-c' | '--custom')
custom_function=$2
# Validate that the custom function exists
if ! declare -f "$custom_function" >/dev/null 2>&1; then
_print_error "Custom function '${custom_function}' is not defined"
printf "Available functions can be found in modules/*.sh\n" >&2
printf "Example: -c my_custom_recon\n" >&2
exit $E_INVALID_INPUT
fi
opt_mode='c'
shift 2
continue
;;
'--show-cache')
SHOW_CACHE=true
shift
continue
;;
'--banner')
SHOW_BANNER=true
shift
continue
;;
'--no-banner')
NO_BANNER=true
shift
continue
;;
'--legal')
SHOW_LEGAL=true
shift
continue
;;
'-z' | '--zen')
opt_mode='z'
shift
continue
;;
'-y' | '--ai')
opt_ai=true
shift
continue
;;
# extra stuff
'-o')
if [[ $2 != /* ]]; then
dir_output=$PWD/$2
else
dir_output=$2
fi
shift 2
continue
;;
'-v' | '--vps')
command -v axiom-ls &>/dev/null || {
printf "\n Axiom is needed for this mode and is not installed \n You have to install it manually \n" && exit
}
AXIOM=true
shift
continue
;;
'--vps-count')
if ! validate_integer "$2" 1; then
print_errorf "Invalid --vps-count value '%s' (must be an integer >= 1)" "$2"
exit 1
fi
CLI_AXIOM_FLEET_COUNT="$2"
shift 2
continue
;;
'-f')
CUSTOM_CONFIG=$2
shift 2
continue
;;
'-q')
rate_limit=$2
shift 2
continue
;;
'--deep')
opt_deep=true
shift
continue
;;
'--')
shift
break
;;
'--check-tools')
CHECK_TOOLS_OR_EXIT=true
shift
continue
;;
'--health-check')
HEALTH_CHECK=true
shift
continue
;;
'--quick-rescan')
CLI_QUICK_RESCAN=true
shift
continue
;;
'--incremental')
CLI_INCREMENTAL_MODE=true
shift
continue
;;
'--adaptive-rate')
CLI_ADAPTIVE_RATE_LIMIT=true
shift
continue
;;
'--dry-run')
CLI_DRY_RUN=true
shift
continue
;;
'--parallel')
PARALLEL_MODE=true
CLI_PARALLEL_MODE=true
shift
continue
;;
'--no-parallel')
PARALLEL_MODE=false
CLI_PARALLEL_MODE=false
shift
continue
;;
'--monitor')
CLI_MONITOR_MODE=true
shift
continue
;;
'--monitor-interval')
CLI_MONITOR_INTERVAL_MIN="$2"
shift 2
continue
;;
'--monitor-cycles')
CLI_MONITOR_MAX_CYCLES="$2"
shift 2
continue
;;
'--refresh-cache')
CLI_CACHE_REFRESH=true
shift
continue
;;
'--gen-resolvers')
CLI_GENERATE_RESOLVERS=true
shift
continue
;;
'--force')
CLI_FORCE_RESCAN=true
shift
continue
;;
'--export')
CLI_EXPORT_FORMAT="$2"
if [[ ! "$CLI_EXPORT_FORMAT" =~ ^(json|html|csv|all)$ ]]; then
print_errorf "Invalid --export value '%s' (allowed: json|html|csv|all)" "$CLI_EXPORT_FORMAT"
exit 1
fi
shift 2
continue
;;
'--report-only')
CLI_REPORT_ONLY=true
shift
continue
;;
'--no-report')
CLI_NO_REPORT=true
shift
continue
;;
'--parallel-log')
CLI_PARALLEL_LOG_MODE="$2"
if [[ ! "$CLI_PARALLEL_LOG_MODE" =~ ^(summary|tail|full)$ ]]; then
print_errorf "Invalid --parallel-log value '%s' (allowed: summary|tail|full)" "$CLI_PARALLEL_LOG_MODE"
exit 1
fi
shift 2
continue
;;
'--quiet')
CLI_OUTPUT_VERBOSITY=0
shift
continue
;;
'--verbose')
CLI_OUTPUT_VERBOSITY=2
shift
continue
;;
'--no-color')
CLI_NO_COLOR=1
shift
continue
;;
'--log-format')
CLI_LOG_FORMAT="$2"
if [[ ! "$CLI_LOG_FORMAT" =~ ^(plain|jsonl|jsonl-strict)$ ]]; then
print_errorf "Invalid --log-format value '%s' (allowed: plain|jsonl|jsonl-strict)" "$CLI_LOG_FORMAT"
exit 1
fi
shift 2
continue
;;
'--help' | '-h')
HELP_REQUESTED=true
break
;;
*)
# echo "Unknown argument: $1"
UNKNOWN_ARGUMENT=true
break
;;
esac
done
# This is the first thing to do to read in alternate config
SCRIPTPATH="$(
cd "$(dirname "$0")" >/dev/null 2>&1 || exit
pwd -P
)"
. "${SCRIPTPATH}"/reconftw.cfg || {
_print_error "Error importing reconftw.cfg"
exit 1
}
# Source optional secrets file (gitignored, for API keys and tokens)
[[ -f "${SCRIPTPATH}/secrets.cfg" ]] && . "${SCRIPTPATH}/secrets.cfg"
if [[ -s $CUSTOM_CONFIG ]]; then
# shellcheck source=/home/six2dez/Tools/reconftw/custom_config.cfg
. "${CUSTOM_CONFIG}" || {
_print_error "Error importing custom config"
exit 1
}
fi
# Re-apply CLI overrides after config load (config defaults should not clobber CLI flags)
if [[ "${CLI_MONITOR_MODE:-false}" == "true" ]]; then
MONITOR_MODE=true
fi
if [[ -n "${CLI_MONITOR_INTERVAL_MIN:-}" ]]; then
MONITOR_INTERVAL_MIN="${CLI_MONITOR_INTERVAL_MIN}"
fi
if [[ -n "${CLI_MONITOR_MAX_CYCLES:-}" ]]; then
MONITOR_MAX_CYCLES="${CLI_MONITOR_MAX_CYCLES}"
fi
if [[ "${CLI_CACHE_REFRESH:-false}" == "true" ]]; then
CACHE_REFRESH=true
fi
if [[ "${CLI_GENERATE_RESOLVERS:-false}" == "true" ]]; then
generate_resolvers=true
fi
if [[ -n "${CLI_EXPORT_FORMAT:-}" ]]; then
EXPORT_FORMAT="${CLI_EXPORT_FORMAT}"
fi
if [[ "${CLI_REPORT_ONLY:-false}" == "true" ]]; then
REPORT_ONLY=true
fi
if [[ -n "${CLI_PARALLEL_MODE:-}" ]]; then
PARALLEL_MODE="${CLI_PARALLEL_MODE}"
fi
if [[ -n "${CLI_PARALLEL_LOG_MODE:-}" ]]; then
PARALLEL_LOG_MODE="${CLI_PARALLEL_LOG_MODE}"
fi
if [[ -n "${CLI_OUTPUT_VERBOSITY:-}" ]]; then
OUTPUT_VERBOSITY="${CLI_OUTPUT_VERBOSITY}"
# Backward compat: verbose level sets VERBOSE=true
[[ "${OUTPUT_VERBOSITY}" -ge 2 ]] && VERBOSE=true
fi
if [[ -n "${CLI_LOG_FORMAT:-}" ]]; then
LOG_FORMAT="${CLI_LOG_FORMAT}"
fi
if [[ -n "${CLI_NO_COLOR:-}" ]]; then
NO_COLOR=1
fi
if [[ -n "${CLI_AXIOM_FLEET_COUNT:-}" ]]; then
AXIOM=true
AXIOM_FLEET_LAUNCH=true
AXIOM_FLEET_COUNT="${CLI_AXIOM_FLEET_COUNT}"
fi
if [[ "${CLI_QUICK_RESCAN:-false}" == "true" ]]; then
QUICK_RESCAN=true
fi
if [[ "${CLI_INCREMENTAL_MODE:-false}" == "true" ]]; then
INCREMENTAL_MODE=true
fi
if [[ "${CLI_ADAPTIVE_RATE_LIMIT:-false}" == "true" ]]; then
ADAPTIVE_RATE_LIMIT=true
fi
if [[ "${CLI_DRY_RUN:-false}" == "true" ]]; then
DRY_RUN=true
fi
if [[ "${CLI_FORCE_RESCAN:-false}" == "true" ]]; then
FORCE_RESCAN=true
fi
if [[ "${CLI_NO_REPORT:-false}" == "true" ]]; then
NO_REPORT=true
fi
if [[ "${LOG_FORMAT:-plain}" == "jsonl-strict" ]]; then
# Machine-only output mode: suppress human-oriented rendering.
OUTPUT_VERBOSITY=0
fi
if [[ "${HELP_REQUESTED:-false}" == "true" ]]; then
help
exit 0
fi
if [[ "${NO_BANNER:-false}" == "true" ]]; then
SHOW_BANNER=false
else
SHOW_BANNER=true
fi
if [[ "${OUTPUT_VERBOSITY:-1}" -eq 0 ]]; then
SHOW_BANNER=false
SHOW_LEGAL=false
fi
if [[ "${NO_REPORT:-false}" == "true" ]]; then
EXPORT_FORMAT=""
elif [[ -z "${EXPORT_FORMAT:-}" ]]; then
EXPORT_FORMAT="all"
fi
if [[ $opt_deep ]]; then
DEEP=true
fi
if [[ $rate_limit ]]; then
NUCLEI_RATELIMIT=$rate_limit
FFUF_RATELIMIT=$rate_limit
HTTPX_RATELIMIT=$rate_limit
fi
if [[ -n $outOfScope_file ]]; then
isAsciiText "$outOfScope_file"
if [[ "False" == "$IS_ASCII" ]]; then
_print_error "Out of Scope file is not a text file"
exit $E_INVALID_INPUT
fi
fi
if [[ -n $inScope_file ]]; then
isAsciiText "$inScope_file"
if [[ "False" == "$IS_ASCII" ]]; then
_print_error "In Scope file is not a text file"
exit $E_INVALID_INPUT
fi
fi
if [[ $(id -u | grep -o '^0$') == "0" ]]; then
# Root: keep empty to avoid passing a space as a command when IFS excludes spaces
SUDO=""
else
SUDO="sudo"
fi
startdir=${PWD}
SHOW_BANNER=${SHOW_BANNER:-true}
# Initialize UI layer after config and CLI overrides (before any output)
ui_init
if [[ "${SHOW_BANNER:-false}" == "true" ]]; then
banner
printf "\n" # Single empty line after banner
fi
if [[ "${SHOW_LEGAL:-false}" == "true" ]]; then
printf " %b[LEGAL]%b Authorized testing only. You confirm explicit permission\n" "$yellow" "$reset"
printf " for specified targets and compliance with applicable laws.\n"
printf " Unauthorized use is prohibited.\n\n"
printf "\n"
fi
if [[ "${DRY_RUN:-false}" != "true" ]]; then
check_version
fi
# Check critical dependencies before proceeding
if [[ "${SKIP_CRITICAL_CHECK:-false}" != "true" ]]; then
check_critical_dependencies
fi
# Run health check if requested and exit
if [[ "${HEALTH_CHECK:-false}" == "true" ]]; then
health_check
exit $?
fi
# Show DRY_RUN mode warning if enabled
if [[ "${DRY_RUN:-false}" == "true" ]]; then
_print_status WARN "DRY-RUN MODE ENABLED" "0s"
fi
startdir=${PWD}
if [[ -n $list ]]; then
if [[ $list == ./* ]]; then
flist="${startdir}/${list:2}"
elif [[ $list == ~* ]]; then
flist="${HOME}/${list:2}"
elif [[ $list == /* ]]; then
flist=$list
else
flist="$startdir/$list"
fi
else
flist=''
fi
if [[ "${REPORT_ONLY:-false}" == "true" ]]; then
report_only_mode
exit
fi
if [[ "${MONITOR_MODE:-false}" == "true" ]]; then
monitor_mode "${opt_mode:-r}"
exit
fi
case $opt_mode in
'r')
if [[ -n $multi ]]; then
if [[ $AXIOM == true ]]; then
mode="multi_recon"
fi
multi_recon
exit
fi
if [[ -n $list ]]; then
if [[ $AXIOM == true ]]; then
mode="list_recon"
fi
sed_i 's/\r$//' "$flist"
while IFS= read -r domain <&3 || [[ -n "$domain" ]]; do
[[ -z "$domain" ]] && continue
domain=$(_sanitize_list_entry "$domain") || continue
start
recon
end
done 3<"$flist"
else
if [[ $AXIOM == true ]]; then
mode="recon"
fi
start
recon
end
fi
;;
's')
if [[ -n $list ]]; then
if [[ $AXIOM == true ]]; then
mode="subs_menu"
fi
sed_i 's/\r$//' "$flist"
while IFS= read -r domain <&3 || [[ -n "$domain" ]]; do
[[ -z "$domain" ]] && continue
domain=$(_sanitize_list_entry "$domain") || continue
subs_menu
done 3<"$flist"
else
subs_menu
fi
;;
'p')
if [[ -n $list ]]; then
if [[ $AXIOM == true ]]; then
mode="passive"
fi
sed_i 's/\r$//' "$flist"
while IFS= read -r domain <&3 || [[ -n "$domain" ]]; do
[[ -z "$domain" ]] && continue
domain=$(_sanitize_list_entry "$domain") || continue
passive
done 3<"$flist"
else
passive
fi
;;
'a')
export VULNS_GENERAL=true
if [[ -n $list ]]; then
if [[ $AXIOM == true ]]; then
mode="all"
fi
sed_i 's/\r$//' "$flist"
while IFS= read -r domain <&3 || [[ -n "$domain" ]]; do
[[ -z "$domain" ]] && continue
domain=$(_sanitize_list_entry "$domain") || continue
all
done 3<"$flist"
else
all
fi
;;
'w')
if [[ -n $list ]]; then
start
if [[ $list == /* ]]; then
cp "$list" "$dir/webs/webs.txt"
else
cp "${SCRIPTPATH}/$list" "$dir/webs/webs.txt"
fi
else
_print_error "Web mode needs a website list file as target (./reconftw.sh -l target.txt -w)"
exit $E_INVALID_INPUT
fi
webs_menu
exit 0
;;
'n')
PRESERVE=true
if [[ -n $multi ]]; then
multi_osint
exit
fi
if [[ -n $list ]]; then
sed_i 's/\r$//' "$flist"
while IFS= read -r domain <&3 || [[ -n "$domain" ]]; do
[[ -z "$domain" ]] && continue
domain=$(_sanitize_list_entry "$domain") || continue
start
osint
end
done 3<"$flist"
else
start
osint
end
fi
;;
'z')
if [[ -n $list ]]; then
if [[ $AXIOM == true ]]; then
mode="zen_menu"
fi
sed_i 's/\r$//' "$flist"
while IFS= read -r domain <&3 || [[ -n "$domain" ]]; do
[[ -z "$domain" ]] && continue
domain=$(_sanitize_list_entry "$domain") || continue
zen_menu
done 3<"$flist"
else
zen_menu
fi
;;
'c')
if [[ -n $multi ]]; then
if [[ $AXIOM == true ]]; then
mode="multi_custom"
fi
multi_custom
else
export DIFF=true
dir="${SCRIPTPATH}/Recon/$domain"
cd "$dir" || {
echo "Failed to cd directory '$dir'"
exit 1
}
LOGFILE="${dir}/.log/${NOW}_${NOWT}.txt"
called_fn_dir=$dir/.called_fn
run_module_with_axiom_failover "$custom_function"
cd "${SCRIPTPATH}" || {
echo "Failed to cd directory '${SCRIPTPATH}'"
exit 1
}
fi
exit
;;
# No mode selected. EXIT!
*)
help
tools_installed
if [[ $UNKNOWN_ARGUMENT == true ]]; then
exit 1
fi
;;
esac