Skip to content

reconFTW is a tool designed to perform automated recon on a target domain by running the best set of tools to perform scanning and finding out vulnerabilities

new output

six2dez774461dbcab8
diff --git a/lib/common.sh b/lib/common.sh
index d177447..390b044 100644
--- a/lib/common.sh
+++ b/lib/common.sh
@@ -18,7 +18,7 @@ ensure_dirs() {
return 0
fi
if ! mkdir -p "$@" 2>/dev/null; then
- printf "%b[!] Failed to create directories: %s%b\n" "${bred:-}" "$*" "${reset:-}" >&2
+ _print_error "Failed to create directories: $*"
return 1
fi
return 0
@@ -79,6 +79,54 @@ count_lines_stdin() {
echo "${count:-0}"
}
+###############################################################################
+# Output Primitives
+###############################################################################
+
+# Section header for major phases (OSINT, Subdomains, Web, Vulns, etc.)
+# Usage: _print_section "OSINT"
+# Output: ══════════════════ OSINT ══════════════════
+_print_section() {
+ [[ "${OUTPUT_VERBOSITY:-1}" -lt 1 ]] && return 0
+ local title="$1"
+ printf "\n%b══════════════════ %s ══════════════════%b\n\n" "${bgreen:-}" "$title" "${reset:-}"
+}
+
+# Compact status line for OK/FAIL/WARN/SKIP/INFO
+# Usage: _print_status OK "sub_passive" "12s"
+# _print_status SKIP "sub_crt" "(disabled)"
+_print_status() {
+ [[ "${OUTPUT_VERBOSITY:-1}" -lt 1 ]] && return 0
+ local badge="$1" text="$2" detail="${3:-}"
+ local color
+ case "$badge" in
+ OK) color="${bgreen:-}" ;;
+ FAIL) color="${bred:-}" ;;
+ WARN) color="${yellow:-}" ;;
+ SKIP) color="${yellow:-}" ;;
+ *) color="${bblue:-}" ;;
+ esac
+ if [[ -n "$detail" ]]; then
+ printf " %b[%-4s]%b %-38s %s\n" "$color" "$badge" "${reset:-}" "$text" "$detail"
+ else
+ printf " %b[%-4s]%b %s\n" "$color" "$badge" "${reset:-}" "$text"
+ fi
+}
+
+# Error that always shows (even in quiet mode)
+# Usage: _print_error "something failed"
+_print_error() {
+ local msg="$1"
+ printf "%b[%s] ERROR: %s%b\n" "${bred:-}" "$(date +'%Y-%m-%d %H:%M:%S')" "$msg" "${reset:-}" >&2
+}
+
+# Thin decorative rule (replaces heavy ###...### separators)
+# Usage: _print_rule
+_print_rule() {
+ [[ "${OUTPUT_VERBOSITY:-1}" -lt 1 ]] && return 0
+ printf "%b──────────────────────────────────────────────────────────────%b\n" "${bgreen:-}" "${reset:-}"
+}
+
###############################################################################
# Notifications
###############################################################################
diff --git a/lib/parallel.sh b/lib/parallel.sh
index e962973..f0ea9ce 100644
--- a/lib/parallel.sh
+++ b/lib/parallel.sh
@@ -320,10 +320,11 @@ parallel_passive_enum() {
"sub_passive"
"sub_crt"
)
-
- printf "%b[*] Running passive enumeration in parallel (%d functions)%b\n" \
- "${bblue:-}" "${#funcs[@]}" "${reset:-}"
-
+
+ [[ "${OUTPUT_VERBOSITY:-1}" -ge 1 ]] && \
+ printf "%b[*] Running passive enumeration in parallel (%d functions)%b\n" \
+ "${bblue:-}" "${#funcs[@]}" "${reset:-}"
+
parallel_funcs 2 "${funcs[@]}"
}
@@ -336,10 +337,11 @@ parallel_active_enum() {
"sub_noerror"
"sub_dns"
)
-
- printf "%b[*] Running active enumeration in parallel (%d functions)%b\n" \
- "${bblue:-}" "${#funcs[@]}" "${reset:-}"
-
+
+ [[ "${OUTPUT_VERBOSITY:-1}" -ge 1 ]] && \
+ printf "%b[*] Running active enumeration in parallel (%d functions)%b\n" \
+ "${bblue:-}" "${#funcs[@]}" "${reset:-}"
+
parallel_funcs 3 "${funcs[@]}"
}
@@ -351,10 +353,11 @@ parallel_postactive_enum() {
"sub_tls"
"sub_analytics"
)
-
- printf "%b[*] Running post-active enumeration in parallel (%d functions)%b\n" \
- "${bblue:-}" "${#funcs[@]}" "${reset:-}"
-
+
+ [[ "${OUTPUT_VERBOSITY:-1}" -ge 1 ]] && \
+ printf "%b[*] Running post-active enumeration in parallel (%d functions)%b\n" \
+ "${bblue:-}" "${#funcs[@]}" "${reset:-}"
+
parallel_funcs 2 "${funcs[@]}"
}
@@ -368,9 +371,10 @@ parallel_brute_enum() {
)
# Brute force is resource intensive, run with limit of 2
- printf "%b[*] Running brute force enumeration (limited parallelism)%b\n" \
- "${bblue:-}" "${reset:-}"
-
+ [[ "${OUTPUT_VERBOSITY:-1}" -ge 1 ]] && \
+ printf "%b[*] Running brute force enumeration (limited parallelism)%b\n" \
+ "${bblue:-}" "${reset:-}"
+
parallel_funcs 2 "${funcs[@]}"
}
@@ -388,9 +392,10 @@ parallel_web_vulns() {
"xss"
)
- printf "%b[*] Running web vulnerability checks in parallel (%d checks)%b\n" \
- "${bblue:-}" "${#funcs[@]}" "${reset:-}"
-
+ [[ "${OUTPUT_VERBOSITY:-1}" -ge 1 ]] && \
+ printf "%b[*] Running web vulnerability checks in parallel (%d checks)%b\n" \
+ "${bblue:-}" "${#funcs[@]}" "${reset:-}"
+
parallel_funcs 4 "${funcs[@]}"
}
@@ -404,9 +409,10 @@ parallel_injection_vulns() {
"command_injection"
)
- printf "%b[*] Running injection vulnerability checks in parallel (%d checks)%b\n" \
- "${bblue:-}" "${#funcs[@]}" "${reset:-}"
-
+ [[ "${OUTPUT_VERBOSITY:-1}" -ge 1 ]] && \
+ printf "%b[*] Running injection vulnerability checks in parallel (%d checks)%b\n" \
+ "${bblue:-}" "${#funcs[@]}" "${reset:-}"
+
parallel_funcs 4 "${funcs[@]}"
}
@@ -419,9 +425,10 @@ parallel_server_vulns() {
"smuggling"
)
- printf "%b[*] Running server-side vulnerability checks in parallel (%d checks)%b\n" \
- "${bblue:-}" "${#funcs[@]}" "${reset:-}"
-
+ [[ "${OUTPUT_VERBOSITY:-1}" -ge 1 ]] && \
+ printf "%b[*] Running server-side vulnerability checks in parallel (%d checks)%b\n" \
+ "${bblue:-}" "${#funcs[@]}" "${reset:-}"
+
parallel_funcs 3 "${funcs[@]}"
}
@@ -440,9 +447,10 @@ parallel_osint() {
"domain_info"
)
- printf "%b[*] Running OSINT gathering in parallel (%d sources)%b\n" \
- "${bblue:-}" "${#funcs[@]}" "${reset:-}"
-
+ [[ "${OUTPUT_VERBOSITY:-1}" -ge 1 ]] && \
+ printf "%b[*] Running OSINT gathering in parallel (%d sources)%b\n" \
+ "${bblue:-}" "${#funcs[@]}" "${reset:-}"
+
parallel_funcs 4 "${funcs[@]}"
}
@@ -454,8 +462,9 @@ parallel_osint() {
# Usage: parallel_subdomains_full
# This replaces the sequential execution in subdomains_full()
parallel_subdomains_full() {
- printf "%b[*] Starting parallelized subdomain enumeration%b\n" \
- "${bblue:-}" "${reset:-}"
+ [[ "${OUTPUT_VERBOSITY:-1}" -ge 1 ]] && \
+ printf "%b[*] Starting parallelized subdomain enumeration%b\n" \
+ "${bblue:-}" "${reset:-}"
# Phase 1: Passive enumeration (parallel - no dependencies)
parallel_passive_enum
@@ -479,15 +488,17 @@ parallel_subdomains_full() {
[[ ${SUBSCRAPING:-false} == true ]] && sub_scraping
[[ ${SUB_RECURSIVE_BRUTE:-false} == true ]] && sub_recursive_brute
- printf "%b[*] Parallelized subdomain enumeration complete%b\n" \
- "${bgreen:-}" "${reset:-}"
+ [[ "${OUTPUT_VERBOSITY:-1}" -ge 1 ]] && \
+ printf "%b[*] Parallelized subdomain enumeration complete%b\n" \
+ "${bgreen:-}" "${reset:-}"
}
# Orchestrate full vulnerability scanning with parallelization
# Usage: parallel_vulns_full
parallel_vulns_full() {
- printf "%b[*] Starting parallelized vulnerability scanning%b\n" \
- "${bblue:-}" "${reset:-}"
+ [[ "${OUTPUT_VERBOSITY:-1}" -ge 1 ]] && \
+ printf "%b[*] Starting parallelized vulnerability scanning%b\n" \
+ "${bblue:-}" "${reset:-}"
# Run nuclei first (it's comprehensive)
nuclei_check
@@ -497,6 +508,7 @@ parallel_vulns_full() {
parallel_injection_vulns
parallel_server_vulns
- printf "%b[*] Parallelized vulnerability scanning complete%b\n" \
- "${bgreen:-}" "${reset:-}"
+ [[ "${OUTPUT_VERBOSITY:-1}" -ge 1 ]] && \
+ printf "%b[*] Parallelized vulnerability scanning complete%b\n" \
+ "${bgreen:-}" "${reset:-}"
}
diff --git a/modules/axiom.sh b/modules/axiom.sh
index a8436b4..bf2d977 100644
--- a/modules/axiom.sh
+++ b/modules/axiom.sh
@@ -112,7 +112,7 @@ function axiom_launch() {
# To re-enable: [[ -n ${AXIOM_FLEET_REGIONS-} ]] && AXIOM_FLEET_ARGS+=( --regions="${AXIOM_FLEET_REGIONS}" )
# Show the exact command with proper quoting
- printf 'axiom-fleet %q' "${AXIOM_FLEET_NAME}"
+ printf 'axiom-fleet2 %q' "${AXIOM_FLEET_NAME}"
printf ' %q' "${AXIOM_FLEET_ARGS[@]}"
echo
axiom-fleet2 "${AXIOM_FLEET_NAME}" "${AXIOM_FLEET_ARGS[@]}"
diff --git a/modules/core.sh b/modules/core.sh
index 5f1c2bc..a6ca278 100644
--- a/modules/core.sh
+++ b/modules/core.sh
@@ -11,15 +11,8 @@
exit 1
}
-# --------------------------------------
-# Classic UI wrappers (no tput/icons)
-# --------------------------------------
-
+# pt_header kept as no-op for backward compatibility (used by help())
pt_header() { :; }
-pt_msg_run() { printf "\n%b[%s] %s%b\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "$1" "$reset"; }
-pt_msg_ok() { printf "\n%b[%s] %s%b\n" "$bgreen" "$(date +'%Y-%m-%d %H:%M:%S')" "$1" "$reset"; }
-pt_msg_warn() { printf "\n%b[%s] %s%b\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "$1" "$reset"; }
-pt_msg_err() { printf "\n%b[%s] %s%b\n" "$bred" "$(date +'%Y-%m-%d %H:%M:%S')" "$1" "$reset"; }
# Ensure a safe default for early log redirections
# If LOGFILE is unset or empty, send logs to /dev/null until later initialization
@@ -66,8 +59,7 @@ enable_command_trace() {
fi
[[ -z ${LOGFILE:-} ]] && return
- printf "%b[%s] WARNING: Command tracing enabled. Logs may contain sensitive data.%b\n" \
- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset" >&2
+ _print_status WARN "Command tracing enabled" "Logs may contain sensitive data"
# Close any previous trace descriptor (native bash {varname} redirect syntax)
if [[ -n ${TRACE_FD:-} ]]; then
@@ -132,19 +124,19 @@ function check_version() {
# Check if git is installed
if ! command -v git >/dev/null 2>&1; then
- printf "\n%bGit is not installed. Cannot check for updates.%b\n\n" "$bred" "$reset"
+ _print_error "Git is not installed. Cannot check for updates"
return 1
fi
# Check if current directory is a git repository
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
- printf "\n%bCurrent directory is not a git repository. Cannot check for updates.%b\n\n" "$bred" "$reset"
+ _print_error "Current directory is not a git repository. Cannot check for updates"
return 1
fi
# Fetch updates with a timeout (supports gtimeout on macOS)
if ! { [[ -n $TIMEOUT_CMD ]] && $TIMEOUT_CMD 10 git fetch >/dev/null 2>&1; } && ! git fetch >/dev/null 2>&1; then
- printf "\n%bUnable to check updates (git fetch timed out).%b\n\n" "$bred" "$reset"
+ _print_error "Unable to check updates (git fetch timed out)"
return 1
fi
@@ -156,7 +148,7 @@ function check_version() {
local UPSTREAM
UPSTREAM=$(git rev-parse --abbrev-ref --symbolic-full-name "@{u}" 2>/dev/null)
if [[ -z $UPSTREAM ]]; then
- printf "\n%bNo upstream branch set for '%s'. Cannot check for updates.%b\n\n" "$bred" "$BRANCH" "$reset"
+ _print_error "No upstream branch set for '${BRANCH}'. Cannot check for updates"
return 1
fi
@@ -167,14 +159,13 @@ function check_version() {
# Compare local and remote hashes
if [[ $LOCAL != "$REMOTE" ]]; then
- printf "\n%bThere is a new version available. Run ./install.sh to get the latest version.%b\n\n" "$yellow" "$reset"
+ _print_status WARN "New version available" "Run ./install.sh to update"
fi
}
function tools_installed() {
# Check if all tools are installed
- printf "\n\n%b#######################################################################%b\n" "$bgreen" "$reset"
- printf "%b[%s] Checking installed tools %b\n\n" "$bblue" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"
+ _print_section "Tools Check"
local all_installed=true
local missing_tools=()
@@ -183,7 +174,7 @@ function tools_installed() {
local env_vars=("GOPATH" "GOROOT" "PATH")
for var in "${env_vars[@]}"; do
if [[ -z ${!var} ]]; then
- printf "%b [*] %s variable\t\t[NO]%b\n" "$bred" "$var" "$reset"
+ _print_status FAIL "${var} variable"
all_installed=false
missing_tools+=("$var environment variable")
fi
@@ -348,20 +339,16 @@ function tools_installed() {
done
if [[ $all_installed == true ]]; then
- printf "%b\n Good! All tools are installed! %b\n\n" "$bgreen" "$reset"
+ _print_status OK "All tools are installed"
else
- printf "\n%bSome tools or directories are missing:%b\n\n" "$yellow" "$reset"
+ _print_status WARN "Some tools or directories are missing"
for tool in "${missing_tools[@]}"; do
- printf "%b - %s %b\n" "$bred" "$tool" "$reset"
+ _print_status FAIL "$tool"
done
printf "\n%bTry running the installer script again: ./install.sh%b\n" "$yellow" "$reset"
- printf "%bIf it fails, try installing the missing tools manually.%b\n" "$yellow" "$reset"
- printf "%bEnsure that the %b\$tools%b variable is correctly set at the start of this script.%b\n" "$yellow" "$bred" "$yellow" "$reset"
- printf "%bIf you need assistance, feel free to contact me! :D%b\n\n" "$yellow" "$reset"
fi
- printf "%b[%s] Tools check finished%b\n" "$bblue" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"
- printf "%b#######################################################################\n%b" "$bgreen" "$reset"
+ _print_status INFO "Tools check finished"
if [[ $CHECK_TOOLS_OR_EXIT == true && $all_installed != true ]]; then
exit 2
@@ -386,15 +373,14 @@ function check_critical_dependencies() {
local missing_critical=()
local all_critical_ok=true
- printf "\n%b#######################################################################%b\n" "$bgreen" "$reset"
- printf "%b[%s] Checking critical dependencies%b\n\n" "$bblue" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"
+ _print_section "Critical Dependencies"
for item in "${critical_tools[@]}"; do
local tool="${item%%:*}"
local description="${item#*:}"
if ! command -v "$tool" >/dev/null 2>&1; then
- printf "%b [✗] %s (%s) - MISSING%b\n" "$bred" "$description" "$tool" "$reset"
+ _print_status FAIL "${description} (${tool})" "MISSING"
missing_critical+=("$tool")
all_critical_ok=false
else
@@ -410,28 +396,33 @@ function check_critical_dependencies() {
version=$($tool --version 2>&1 | head -n1 || echo "installed")
;;
esac
- printf "%b [✓] %s (%s) - %s%b\n" "$bgreen" "$description" "$tool" "$version" "$reset"
+ _print_status OK "${description} (${tool})" "${version}"
fi
done
- printf "\n"
-
if [[ $all_critical_ok == false ]]; then
- printf "%b[%s] ERROR: Critical dependencies missing!%b\n" "$bred" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"
- printf "%bThe following tools are required for reconFTW to function:%b\n" "$yellow" "$reset"
+ _print_error "Critical dependencies missing!"
for tool in "${missing_critical[@]}"; do
- printf "%b - %s%b\n" "$bred" "$tool" "$reset"
+ _print_status FAIL "$tool"
done
- printf "\n%bPlease install these tools and try again.%b\n" "$yellow" "$reset"
- printf "%bYou can run: ./install.sh to install all dependencies.%b\n" "$yellow" "$reset"
- printf "%b#######################################################################%b\n\n" "$bgreen" "$reset"
+ printf "\n%bPlease install these tools and try again: ./install.sh%b\n" "$yellow" "$reset"
exit 1
else
- printf "%b[%s] All critical dependencies are installed%b\n" "$bgreen" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"
- printf "%b#######################################################################%b\n\n" "$bgreen" "$reset"
+ _print_status OK "All critical dependencies are installed"
fi
}
+# Report optional API keys used by passive URL providers.
+# Missing keys are informational only; scan continues in best-effort mode.
+function check_optional_api_keys() {
+ local urlscan_state="configured"
+ local vt_state="configured"
+ [[ -z "${URLSCAN_API_KEY:-}" ]] && urlscan_state="not configured (best-effort mode)"
+ [[ -z "${VIRUSTOTAL_API_KEY:-}" ]] && vt_state="not configured (best-effort mode)"
+
+ _print_status INFO "Optional API keys" "URLSCAN=${urlscan_state} | VT=${vt_state}"
+}
+
###############################################################################################################
####################################### LOGGING ##################################################
###############################################################################################################
@@ -447,8 +438,7 @@ function log_init() {
STRUCTURED_LOG_FILE="${dir}/.log/structured_$(date +%Y%m%d_%H%M%S).jsonl"
mkdir -p "$(dirname "$STRUCTURED_LOG_FILE")"
- printf "%b[%s] Structured logging enabled: %s%b\n" \
- "$bgreen" "$(date +'%Y-%m-%d %H:%M:%S')" "$STRUCTURED_LOG_FILE" "$reset"
+ _print_status OK "Structured logging enabled" "$STRUCTURED_LOG_FILE"
}
# Log structured JSON event
@@ -1055,7 +1045,7 @@ function transfer {
function sendToNotify {
if [[ -z $1 ]]; then
- printf "\n${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] No file provided to send ${reset}\n"
+ _print_status WARN "No file provided to send"
else
if [[ -z $NOTIFY_CONFIG ]]; then
NOTIFY_CONFIG=~/.config/notify/provider-config.yaml
@@ -1084,9 +1074,7 @@ function sendToNotify {
}
function start_func() {
- if [[ "${OUTPUT_VERBOSITY:-1}" -ge 1 ]]; then
- printf "${bgreen}#######################################################################"
- fi
+ _print_rule
notification "${2}" info
echo "[$current_date] Start function: ${1} " >>"${LOGFILE}"
start=$(date +%s)
@@ -1098,13 +1086,15 @@ function end_func() {
end=$(date +%s)
getElapsedTime "$start" "$end"
record_func_timing "${2}" "$((end - start))"
- notification "${2} Finished in ${runtime}" info
+ local duration=$((end - start))
echo "[$current_date] End function: ${2} " >>"${LOGFILE}"
if [[ "${OUTPUT_VERBOSITY:-1}" -ge 1 ]]; then
- printf "${bblue}[$current_date] ${1} ${reset}\n"
- printf "${bgreen}#######################################################################${reset}\n"
+ _print_status OK "${2}" "${duration}s"
+ if [[ -n "${1:-}" ]]; then
+ printf " %b%s%b\n" "${bblue:-}" "${1}" "${reset:-}"
+ fi
fi
- log_json "SUCCESS" "${2}" "Function completed" "runtime=${runtime}" "duration_sec=$((end - start))"
+ log_json "SUCCESS" "${2}" "Function completed" "runtime=${runtime}" "duration_sec=${duration}"
}
function start_subfunc() {
@@ -1118,11 +1108,12 @@ function end_subfunc() {
touch "$called_fn_dir/.${2}"
end_sub=$(date +%s)
getElapsedTime "$start_sub" "$end_sub"
+ local duration=$((end_sub - start_sub))
if [[ "${OUTPUT_VERBOSITY:-1}" -ge 1 ]]; then
- notification " ${1} in ${runtime}" good
+ _print_status OK " ${2}" "${duration}s"
fi
echo "[$current_date] End subfunction: ${1} " >>"${LOGFILE}"
- log_json "SUCCESS" "${2}" "Subfunction completed" "runtime=${runtime}" "duration_sec=$((end_sub - start_sub))"
+ log_json "SUCCESS" "${2}" "Subfunction completed" "runtime=${runtime}" "duration_sec=${duration}"
}
function check_inscope() {
@@ -1707,6 +1698,29 @@ function export_csv_artifacts() {
fi
}
+# Export clean text artifacts for copy/paste workflows.
+# Outputs:
+# - report/subdomains_clean.txt
+# - report/webs_clean.txt
+# - report/ips_clean.txt
+function export_clean_text_artifacts() {
+ ensure_dirs report || return 1
+
+ if [[ -s subdomains/subdomains.txt ]]; then
+ sed '/^$/d' subdomains/subdomains.txt | sort -u >report/subdomains_clean.txt
+ else
+ : >report/subdomains_clean.txt
+ fi
+
+ if [[ -s webs/webs_all.txt ]]; then
+ sed '/^$/d' webs/webs_all.txt | sort -u >report/webs_clean.txt
+ else
+ : >report/webs_clean.txt
+ fi
+
+ cat hosts/ips.txt hosts/ips_v6.txt 2>/dev/null | sed '/^$/d' | sort -u >report/ips_clean.txt
+}
+
# Export orchestrator.
# EXPORT_FORMAT values: json | html | csv | all
function export_reports() {
@@ -1719,19 +1733,23 @@ function export_reports() {
case "$fmt" in
json)
export_findings_jsonl
+ export_clean_text_artifacts
notification "Exported JSON artifacts under report/" info
;;
html)
+ export_clean_text_artifacts
notification "Exported HTML report at report/index.html" info
;;
csv)
export_findings_jsonl
export_csv_artifacts
+ export_clean_text_artifacts
notification "Exported CSV artifacts under report/" info
;;
all)
export_findings_jsonl
export_csv_artifacts
+ export_clean_text_artifacts
notification "Exported JSONL + CSV + HTML artifacts under report/" info
;;
*)
@@ -1744,78 +1762,71 @@ function health_check() {
local failures=0
local warnings=0
- printf "\n%b#######################################################################%b\n" "$bgreen" "$reset"
- printf "%b[%s] reconFTW Health Check%b\n\n" "$bblue" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"
+ _print_section "Health Check"
# 1. Check critical tools
- printf "%b[*] Checking critical tools...%b\n" "$yellow" "$reset"
+ _print_status INFO "Checking critical tools..."
local critical_tools=("bash" "python3" "curl" "git" "jq")
for tool in "${critical_tools[@]}"; do
if command -v "$tool" >/dev/null 2>&1; then
- printf " %b[OK]%b %s\n" "$bgreen" "$reset" "$tool"
+ _print_status OK "$tool"
else
- printf " %b[FAIL]%b %s not found\n" "$bred" "$reset" "$tool"
+ _print_status FAIL "$tool" "not found"
((failures++))
fi
done
# 2. Check key recon tools
- printf "\n%b[*] Checking recon tools...%b\n" "$yellow" "$reset"
+ _print_status INFO "Checking recon tools..."
local recon_tools=("subfinder" "httpx" "nuclei" "naabu" "ffuf" "dnsx" "anew" "notify")
for tool in "${recon_tools[@]}"; do
if command -v "$tool" >/dev/null 2>&1; then
- printf " %b[OK]%b %s\n" "$bgreen" "$reset" "$tool"
+ _print_status OK "$tool"
else
- printf " %b[WARN]%b %s not found\n" "$byellow" "$reset" "$tool"
+ _print_status WARN "$tool" "not found"
((warnings++))
fi
done
# 3. Check network connectivity
- printf "\n%b[*] Checking network connectivity...%b\n" "$yellow" "$reset"
+ _print_status INFO "Checking network connectivity..."
if curl -s --connect-timeout 5 -o /dev/null -w "%{http_code}" "https://www.google.com" | grep -q "200\|301\|302"; then
- printf " %b[OK]%b Internet connectivity\n" "$bgreen" "$reset"
+ _print_status OK "Internet connectivity"
else
- printf " %b[WARN]%b No internet connectivity\n" "$byellow" "$reset"
+ _print_status WARN "No internet connectivity"
((warnings++))
fi
# 4. Check disk space
- printf "\n%b[*] Checking disk space...%b\n" "$yellow" "$reset"
+ _print_status INFO "Checking disk space..."
local avail_gb
- if [[ "$OSTYPE" == "darwin"* ]]; then
- # macOS: df -g shows GB directly
- avail_gb=$(df -g . 2>/dev/null | awk 'NR==2 {print $4}')
- else
- # Linux: df -BG shows GB with G suffix
- avail_gb=$(df -BG . 2>/dev/null | awk 'NR==2 {gsub(/G/,"",$4); print $4}')
- fi
+ avail_gb=$(df -Pk . 2>/dev/null | awk 'NR==2 {print int($4 / 1024 / 1024)}')
avail_gb=${avail_gb:-0}
-
+
if [[ ${avail_gb} -ge 5 ]]; then
- printf " %b[OK]%b %s GB available\n" "$bgreen" "$reset" "$avail_gb"
+ _print_status OK "Disk space" "${avail_gb} GB available"
elif [[ ${avail_gb} -ge 1 ]]; then
- printf " %b[WARN]%b Only %s GB available (recommend 5+ GB)\n" "$byellow" "$reset" "$avail_gb"
+ _print_status WARN "Disk space" "Only ${avail_gb} GB available (recommend 5+ GB)"
((warnings++))
else
- printf " %b[FAIL]%b Less than 1 GB available\n" "$bred" "$reset"
+ _print_status FAIL "Disk space" "Less than 1 GB available"
((failures++))
fi
# 5. Check resolver files
- printf "\n%b[*] Checking resolver files...%b\n" "$yellow" "$reset"
+ _print_status INFO "Checking resolver files..."
local resolvers_path="${resolvers:-${SCRIPTPATH}/resolvers.txt}"
if [[ -s "$resolvers_path" ]]; then
local count
count=$(wc -l <"$resolvers_path")
- printf " %b[OK]%b Resolvers file: %s (%s entries)\n" "$bgreen" "$reset" "$resolvers_path" "$count"
+ _print_status OK "Resolvers file" "${resolvers_path} (${count} entries)"
else
- printf " %b[WARN]%b Resolvers file not found or empty: %s\n" "$byellow" "$reset" "$resolvers_path"
+ _print_status WARN "Resolvers file" "not found or empty: ${resolvers_path}"
((warnings++))
fi
# 6. Check API key status
- printf "\n%b[*] Checking API keys...%b\n" "$yellow" "$reset"
+ _print_status INFO "Checking API keys..."
local -A api_keys=(
["SHODAN_API_KEY"]="${SHODAN_API_KEY:-}"
["WHOISXML_API"]="${WHOISXML_API:-}"
@@ -1824,25 +1835,21 @@ function health_check() {
)
for key_name in "${!api_keys[@]}"; do
if [[ -n "${api_keys[$key_name]}" ]]; then
- printf " %b[OK]%b %s configured\n" "$bgreen" "$reset" "$key_name"
+ _print_status OK "$key_name" "configured"
else
- printf " %b[INFO]%b %s not set\n" "$bblue" "$reset" "$key_name"
+ _print_status INFO "$key_name" "not set"
fi
done
# Summary
- printf "\n%b#######################################################################%b\n" "$bgreen" "$reset"
+ _print_rule
if [[ $failures -gt 0 ]]; then
- printf "%b[%s] Health check: %d FAILURES, %d warnings%b\n" \
- "$bred" "$(date +'%Y-%m-%d %H:%M:%S')" "$failures" "$warnings" "$reset"
+ _print_status FAIL "Health check" "${failures} FAILURES, ${warnings} warnings"
elif [[ $warnings -gt 0 ]]; then
- printf "%b[%s] Health check: PASSED with %d warnings%b\n" \
- "$byellow" "$(date +'%Y-%m-%d %H:%M:%S')" "$warnings" "$reset"
+ _print_status WARN "Health check" "PASSED with ${warnings} warnings"
else
- printf "%b[%s] Health check: ALL PASSED%b\n" \
- "$bgreen" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"
+ _print_status OK "Health check" "ALL PASSED"
fi
- printf "%b#######################################################################%b\n\n" "$bgreen" "$reset"
return $failures
}
diff --git a/modules/modes.sh b/modules/modes.sh
index c0e9b21..a667ebf 100644
--- a/modules/modes.sh
+++ b/modules/modes.sh
@@ -21,7 +21,7 @@ function start() {
# Check available disk space before starting (require at least 5GB by default)
local required_space_gb="${MIN_DISK_SPACE_GB:-5}"
if ! check_disk_space "$required_space_gb" "."; then
- printf "%b[%s] WARNING: Low disk space detected. Continuing anyway...%b\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"
+ _print_status WARN "Low disk space detected" "Continuing anyway..."
# Not exiting, just warning - user can set MIN_DISK_SPACE_GB=0 to disable
fi
@@ -44,6 +44,7 @@ function start() {
notification "Monitor cycle ${MONITOR_CYCLE}: skipping repeated tools check" info
else
tools_installed
+ check_optional_api_keys
fi
# Initialize incremental mode if enabled
@@ -126,9 +127,16 @@ function start() {
# Non-fatal error trap: log and continue (plus short explanation for common cases)
trap 'rc=$?; ts=$(date +"%Y-%m-%d %H:%M:%S"); cmd=${BASH_COMMAND}; loc_fn=${FUNCNAME[0]:-main}; loc_ln=${BASH_LINENO[0]:-0}; msg="[$ts] ERR($rc) @ ${loc_fn}:${loc_ln} :: ${cmd}"; if [[ -n "${LOGFILE:-}" ]]; then echo "$msg" >>"$LOGFILE"; else echo "$msg" >&2; fi; explain_err "$rc" "$cmd" "$loc_fn" "$loc_ln"' ERR
- printf "\n"
- printf "${bred}[$(date +'%Y-%m-%d %H:%M:%S')] Target: ${domain}\n\n"
- printf "%b[LEGAL]%b Authorized testing only. By running this scan you confirm you have explicit permission for the specified targets and will comply with all applicable laws and program rules. Unauthorized use is prohibited.\n\n" "$yellow" "$reset"
+ _print_rule
+ printf "%b Target: %s%b\n" "${bred:-}" "$domain" "${reset:-}"
+ if [[ "${OUTPUT_VERBOSITY:-1}" -ge 2 ]]; then
+ printf "%b Mode: %s | Parallel: %s | Verbosity: %s%b\n" \
+ "${bblue:-}" "${opt_mode:-r}" "${PARALLEL_MODE:-true}" "${OUTPUT_VERBOSITY:-1}" "${reset:-}"
+ fi
+ _print_rule
+ if [[ "${OUTPUT_VERBOSITY:-1}" -ge 1 ]]; then
+ printf "%b[LEGAL]%b Authorized testing only. By running this scan you confirm you have explicit permission for the specified targets and will comply with all applicable laws and program rules. Unauthorized use is prohibited.\n\n" "$yellow" "$reset"
+ fi
}
function end() {
@@ -212,7 +220,7 @@ function end() {
if [[ $FARADAY == true ]]; then
if ! faraday-cli status 2>>"$LOGFILE" >/dev/null; then
- printf "%b[!] Faraday server is not running. Skipping Faraday integration.%b\n" "$bred" "$reset"
+ _print_error "Faraday server is not running. Skipping Faraday integration"
else
if [[ -s ".tmp/tko_json.txt" ]]; then
faraday-cli tool report -w $FARADAY_WORKSPACE --plugin-id nuclei .tmp/tko_json.txt 2>>"$LOGFILE" >/dev/null
@@ -273,13 +281,16 @@ function end() {
global_end=$(date +%s)
getElapsedTime $global_start $global_end
- printf "${bgreen}#######################################################################${reset}\n"
+ _print_section "Scan Complete"
if [[ "${RECON_PARTIAL_RUN:-false}" == "true" ]]; then
- notification "Run completed with non-fatal warnings (osint_parallel=${RECON_OSINT_PARALLEL_FAILURES:-0})" warn
+ _print_status WARN "Run completed with non-fatal warnings" "osint_parallel=${RECON_OSINT_PARALLEL_FAILURES:-0}"
fi
+ printf "%b Target: %s%b\n" "${bgreen:-}" "$domain" "${reset:-}"
+ printf "%b Duration: %s%b\n" "${bgreen:-}" "$runtime" "${reset:-}"
+ printf "%b Output: %s%b\n" "${bgreen:-}" "$finaldir" "${reset:-}"
+ _print_rule
notification "Finished Recon on: ${domain} under ${finaldir} in: ${runtime}" good "$(date +'%Y-%m-%d %H:%M:%S')"
[ "$SOFT_NOTIFICATION" = true ] && echo "[$(date +'%Y-%m-%d %H:%M:%S')] Finished Recon on: ${domain} under ${finaldir} in: ${runtime}" | notify -silent
- printf "${bgreen}#######################################################################${reset}\n"
# Print performance timing summary
print_timing_summary
@@ -336,6 +347,9 @@ function build_hotlist() {
function passive() {
start
+
+ _print_section "OSINT"
+
domain_info
ip_info
emails
@@ -366,8 +380,13 @@ function passive() {
axiom_selected
fi
+ _print_section "Subdomains"
+
subdomains_full
remove_big_files
+
+ _print_section "Web Detection"
+
favicon
cdnprovider
# shellcheck disable=SC2034 # PORTSCAN_ACTIVE controls scan behavior
@@ -409,7 +428,7 @@ function vulns() {
if [[ $VULNS_GENERAL == true ]]; then
if [[ "${PARALLEL_MODE:-true}" == "true" ]] && declare -f parallel_funcs &>/dev/null; then
# Parallel execution - group independent checks
- printf "%b[*] Running vulnerability checks in parallel mode%b\n" "$bblue" "$reset"
+ [[ "${OUTPUT_VERBOSITY:-1}" -ge 1 ]] && printf "%b[*] Running vulnerability checks in parallel mode%b\n" "$bblue" "$reset"
parallel_funcs 4 cors open_redirect crlf_checks xss
local vulns_g1_rc=$?
if ((vulns_g1_rc > 0)); then
@@ -559,6 +578,8 @@ function recon() {
fi
progress_init "$progress_total"
+ _print_section "OSINT"
+
if [[ "${PARALLEL_MODE:-true}" == "true" ]] && declare -f parallel_funcs &>/dev/null; then
progress_step "OSINT: domain_info, ip_info, emails, dorks"
parallel_funcs 4 domain_info ip_info emails google_dorks
@@ -613,6 +634,8 @@ function recon() {
axiom_selected
fi
+ _print_section "Subdomains"
+
progress_step "subdomains_full"
subdomains_full
progress_step "webprobe_full"
@@ -624,6 +647,8 @@ function recon() {
s3buckets
cloud_extra_providers
+ _print_section "Web Detection"
+
if [[ "${PARALLEL_MODE:-true}" == "true" ]] && declare -f parallel_funcs &>/dev/null; then
progress_step "screenshot, cdnprovider, portscan"
parallel_funcs 3 screenshot cdnprovider portscan
@@ -661,6 +686,8 @@ function recon() {
${TIME_EST_FUZZ:-900} + ${TIME_EST_IIS:-60} + ${TIME_EST_URLCHECKS:-300} + ${TIME_EST_JSCHECKS:-300} + \
${TIME_EST_PARAM:-240} + ${TIME_EST_GRPC:-120}))
else
+ _print_section "Web Analysis"
+
progress_step "waf_checks"
waf_checks
progress_step "nuclei_check"
@@ -687,6 +714,8 @@ function recon() {
axiom_shutdown
fi
+ _print_section "Finalization"
+
progress_step "cms_scanner"
cms_scanner
progress_step "url_gf"
@@ -1001,6 +1030,8 @@ function subs_menu() {
axiom_selected
fi
+ _print_section "Subdomains"
+
subdomains_full
webprobe_full
subtakeover
@@ -1018,10 +1049,15 @@ function subs_menu() {
}
function webs_menu() {
+ _print_section "Web Detection"
+
subtakeover
remove_big_files
screenshot
# virtualhosts
+
+ _print_section "Web Analysis"
+
waf_checks
nuclei_check
graphql_scan
@@ -1038,6 +1074,9 @@ function webs_menu() {
url_ext
param_discovery
grpc_reflection
+
+ _print_section "Vulnerability Checks"
+
vulns
end
}
@@ -1048,11 +1087,17 @@ function zen_menu() {
axiom_launch
axiom_selected
fi
+
+ _print_section "Subdomains"
+
subdomains_full
webprobe_full
subtakeover
remove_big_files
s3buckets
+
+ _print_section "Web Analysis"
+
screenshot
# virtualhosts
cdnprovider
@@ -1241,6 +1286,9 @@ function help() {
printf " --incremental Only scan new findings since last run\n"
printf " --adaptive-rate Automatically adjust rate limits on errors (429/503)\n"
printf " --dry-run Show what would be executed without running commands\n"
+ printf " --quiet Minimal output (errors and final summary only)\n"
+ printf " --verbose Extra output (PIDs, debug info)\n"
+ printf " --parallel-log m Parallel output mode: summary (default), tail, or full\n"
printf " --parallel Run independent functions in parallel (faster but uses more resources)\n"
printf " --no-parallel Force sequential execution\n"
printf " --monitor Continuous monitoring mode (single target; -w supports -l)\n"
diff --git a/modules/osint.sh b/modules/osint.sh
index 706e19d..9513e7c 100644
--- a/modules/osint.sh
+++ b/modules/osint.sh
@@ -21,7 +21,7 @@ function google_dorks() {
start_func "${FUNCNAME[0]}" "Running: Google Dorks in process"
if ! "${tools}/dorks_hunter/venv/bin/python3" "${tools}/dorks_hunter/dorks_hunter.py" -d "$domain" -o "osint/dorks.txt" 2>>"$LOGFILE"; then
- printf "%b[!] dorks_hunter command failed.%b\n" "$bred" "$reset"
+ _print_error "dorks_hunter command failed"
fi
end_func "Results are saved in $domain/osint/dorks.txt" "${FUNCNAME[0]}"
else
@@ -42,17 +42,17 @@ function github_dorks() {
if [[ -s $GITHUB_TOKENS ]]; then
if [[ $DEEP == true ]]; then
if ! gitdorks_go -gd "${tools}/gitdorks_go/Dorks/medium_dorks.txt" -nws 20 -target "$domain" -tf "$GITHUB_TOKENS" -ew 3 | anew -q osint/gitdorks.txt; then
- printf "%b[!] gitdorks_go command failed.%b\n" "$bred" "$reset"
+ _print_error "gitdorks_go command failed"
return 1
fi
else
if ! gitdorks_go -gd "${tools}/gitdorks_go/Dorks/smalldorks.txt" -nws 20 -target "$domain" -tf "$GITHUB_TOKENS" -ew 3 | anew -q osint/gitdorks.txt; then
- printf "%b[!] gitdorks_go command failed.%b\n" "$bred" "$reset"
+ _print_error "gitdorks_go command failed"
return 1
fi
fi
else
- printf "\n%b[%s] Required file %s does not exist or is empty.%b\n" "$bred" "$(date +'%Y-%m-%d %H:%M:%S')" "$GITHUB_TOKENS" "$reset"
+ _print_error "Required file ${GITHUB_TOKENS} does not exist or is empty"
return 1
fi
end_func "Results are saved in $domain/osint/gitdorks.txt" "${FUNCNAME[0]}"
@@ -76,12 +76,12 @@ function github_repos() {
echo "$domain" | unfurl format %r >.tmp/company_name.txt
if ! enumerepo -token-string "$GH_TOKEN" -usernames .tmp/company_name.txt -o .tmp/company_repos.txt 2>>"$LOGFILE" >/dev/null; then
- printf "%b[!] enumerepo command failed.%b\n" "$bred" "$reset"
+ _print_error "enumerepo command failed"
fi
if [[ -s ".tmp/company_repos.txt" ]]; then
if ! jq -r '.[].repos[]|.url' <.tmp/company_repos.txt >.tmp/company_repos_url.txt 2>>"$LOGFILE"; then
- printf "%b[!] jq command failed.%b\n" "$bred" "$reset"
+ _print_error "jq command failed"
fi
fi
@@ -89,7 +89,7 @@ function github_repos() {
if [[ -s ".tmp/company_repos_url.txt" ]]; then
if ! interlace -tL .tmp/company_repos_url.txt -threads "$INTERLACE_THREADS" -c "git clone _target_ .tmp/github_repos/_cleantarget_" 2>>"$LOGFILE" >/dev/null; then
- printf "%b[!] interlace git clone command failed.%b\n" "$bred" "$reset"
+ _print_error "interlace git clone command failed"
return 1
fi
else
@@ -108,7 +108,7 @@ function github_repos() {
if [[ -s ".tmp/github_repos_folders.txt" ]]; then
if ! interlace -tL .tmp/github_repos_folders.txt -threads "$INTERLACE_THREADS" -c "gitleaks detect --source .tmp/github_repos/_target_ --no-banner --no-color -r .tmp/github/gh_secret_cleantarget_.json" 2>>"$LOGFILE" >/dev/null; then
- printf "%b[!] interlace gitleaks command failed.%b\n" "$bred" "$reset"
+ _print_error "interlace gitleaks command failed"
end_func "Results are saved in $domain/osint/github_company_secrets.json" "${FUNCNAME[0]}"
return 1
fi
@@ -120,14 +120,14 @@ function github_repos() {
if [[ -s ".tmp/company_repos_url.txt" ]]; then
if ! interlace -tL .tmp/company_repos_url.txt -threads "$INTERLACE_THREADS" -c "trufflehog git _target_ -j 2>&1 | jq -c > _output_/_cleantarget_" -o .tmp/github/ 2>>"$LOGFILE" >/dev/null; then
- printf "%b[!] interlace trufflehog command failed.%b\n" "$bred" "$reset"
+ _print_error "interlace trufflehog command failed"
return 1
fi
fi
if [[ -d ".tmp/github/" ]]; then
if ! cat .tmp/github/* 2>/dev/null | jq -c | jq -r >"osint/github_company_secrets.json" 2>>"$LOGFILE"; then
- printf "%b[!] Error combining results.%b\n" "$bred" "$reset"
+ _print_error "Error combining results"
return 1
fi
else
@@ -138,7 +138,7 @@ function github_repos() {
end_func "Results are saved in $domain/osint/github_company_secrets.json" "${FUNCNAME[0]}"
else
- printf "\n%s[%s] Required file %s does not exist or is empty.%b\n" "$bred" "$(date +'%Y-%m-%d %H:%M:%S')" "$GITHUB_TOKENS" "$reset"
+ _print_error "Required file ${GITHUB_TOKENS} does not exist or is empty"
return 1
fi
else
@@ -159,20 +159,28 @@ function metadata() {
ensure_dirs ".tmp/metagoofil_${domain}"
pushd "${tools}/metagoofil" >/dev/null || {
- printf "%b[!] Failed to change directory to %s in %s at line %s.%b\n" "${bred}" "${tools}/metagoofil" "${FUNCNAME[0]}" "${LINENO}" "${reset}"
+ _print_error "Failed to change directory to ${tools}/metagoofil in ${FUNCNAME[0]} at line ${LINENO}"
return 1
}
"${tools}/metagoofil/venv/bin/python3" "${tools}/metagoofil/metagoofil.py" -d "${domain}" -t pdf,docx,xlsx -l 10 -w -o "${dir}/.tmp/metagoofil_${domain}/" 2>>"${LOGFILE}" >/dev/null
popd >/dev/null || {
- printf "%b[!] Failed to return to the previous directory in %s at line %s.%b\n" "${bred}" "${FUNCNAME[0]}" "${LINENO}" "${reset}"
+ _print_error "Failed to return to the previous directory in ${FUNCNAME[0]} at line ${LINENO}"
return 1
}
# Check if exiftool is installed before running
if command -v exiftool &>/dev/null; then
- exiftool -r .tmp/metagoofil_${domain}/* 2>>"${LOGFILE}" | tee /dev/null | egrep -i "Author|Creator|Email|Producer|Template" | sort -u | anew -q "osint/metadata_results.txt"
+ if find ".tmp/metagoofil_${domain}" -type f -print -quit 2>/dev/null | grep -q .; then
+ exiftool -r ".tmp/metagoofil_${domain}" 2>>"${LOGFILE}" \
+ | tee /dev/null \
+ | egrep -i "Author|Creator|Email|Producer|Template" \
+ | sort -u \
+ | anew -q "osint/metadata_results.txt" || true
+ else
+ log_note "metadata: no files downloaded by metagoofil; skipping exif extraction" "${FUNCNAME[0]}" "${LINENO}"
+ fi
else
- printf "%b[!] exiftool is not installed. Skipping metadata extraction.%b\n" "${bred}" "${reset}"
+ _print_error "exiftool is not installed. Skipping metadata extraction"
printf "exiftool not installed - metadata extraction skipped\n" >>"${LOGFILE}"
fi
@@ -205,10 +213,13 @@ function apileaks() {
log_note "porch-pirate failed even without --dump" "${FUNCNAME[0]}" "${LINENO}"
fi
fi
+ if [[ ! -s "${dir}/osint/postman_leaks.txt" ]]; then
+ log_note "apileaks: porch-pirate returned empty output; continuing with swagger pipeline" "${FUNCNAME[0]}" "${LINENO}"
+ fi
# Change directory to SwaggerSpy
if ! pushd "${tools}/SwaggerSpy" >/dev/null; then
- printf "%b[!] Failed to change directory to %s in %s at line %s.%b\n" "$bred" "${tools}/SwaggerSpy" "${FUNCNAME[0]}" "$LINENO" "$reset"
+ _print_error "Failed to change directory to ${tools}/SwaggerSpy in ${FUNCNAME[0]} at line ${LINENO}"
return 1
fi
@@ -227,7 +238,7 @@ function apileaks() {
# Return to the previous directory
if ! popd >/dev/null; then
- printf "%b[!] Failed to return to the previous directory in %s at line %s.%b\n" "$bred" "${FUNCNAME[0]}" "$LINENO" "$reset"
+ _print_error "Failed to return to the previous directory in ${FUNCNAME[0]} at line ${LINENO}"
return 1
fi
@@ -270,7 +281,7 @@ function emails() {
# Change directory to LeakSearch
if ! pushd "${tools}/LeakSearch" >/dev/null; then
- printf "%b[!] Failed to change directory to %s in %s at line %s.%b\n" "$bred" "${tools}/LeakSearch" "${FUNCNAME[0]}" "$LINENO" "$reset"
+ _print_error "Failed to change directory to ${tools}/LeakSearch in ${FUNCNAME[0]} at line ${LINENO}"
return 1
fi
@@ -279,7 +290,7 @@ function emails() {
# Return to the previous directory
if ! popd >/dev/null; then
- printf "%b[!] Failed to return to the previous directory in %s at line %s.%b\n" "$bred" "${FUNCNAME[0]}" "$LINENO" "$reset"
+ _print_error "Failed to return to the previous directory in ${FUNCNAME[0]} at line ${LINENO}"
return 1
fi
diff --git a/modules/subdomains.sh b/modules/subdomains.sh
index 669c0ae..7b58984 100644
--- a/modules/subdomains.sh
+++ b/modules/subdomains.sh
@@ -391,7 +391,7 @@ _subdomains_finalize() {
local _sub_count _shown=0
_sub_count=$(wc -l < "subdomains/subdomains.txt" | tr -d ' ')
while IFS= read -r sub; do
- ((_shown++))
+ _shown=$((_shown + 1))
if [[ $_shown -le 20 ]]; then
printf "%b[%s] %s%b\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "$sub" "$reset"
else
@@ -416,7 +416,7 @@ _subdomains_finalize() {
local _web_count _wshown=0
_web_count=$(wc -l < "webs/webs.txt" | tr -d ' ')
while IFS= read -r web; do
- ((_wshown++))
+ _wshown=$((_wshown + 1))
if [[ $_wshown -le 20 ]]; then
printf "%b[%s] %s%b\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "$web" "$reset"
else
@@ -627,33 +627,47 @@ function sub_crt() {
if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $SUBCRT == true ]]; then
start_subfunc "${FUNCNAME[0]}" "Running: Crtsh Subdomain Enumeration"
+ : >.tmp/crtsh_subdomains.txt
+ : >.tmp/crtsh_subs_tmp.txt
+
# Run crt command and check for errors
# Apply time fencing if DNS_TIME_FENCE_DAYS is set and > 0
if [[ ${DNS_TIME_FENCE_DAYS:-0} -gt 0 ]]; then
local cutoff_date
cutoff_date=$(date -v-"${DNS_TIME_FENCE_DAYS}"d +%Y-%m-%d 2>/dev/null || date -d "-${DNS_TIME_FENCE_DAYS} days" +%Y-%m-%d 2>/dev/null)
if [[ -n "$cutoff_date" ]]; then
- run_command crt -s -json -l "${CTR_LIMIT}" "$domain" 2>>"$LOGFILE" \
+ if ! run_command crt -s -json -l "${CTR_LIMIT}" "$domain" 2>>"$LOGFILE" \
| jq -r --arg cutoff "$cutoff_date" '[.[] | select(.not_before >= $cutoff)] | .[].subdomain' 2>>"$LOGFILE" \
- | sed -e 's/^\*\.//' >.tmp/crtsh_subdomains.txt
+ | sed -e 's/^\*\.//' >.tmp/crtsh_subdomains.txt; then
+ log_note "sub_crt: crt source returned no valid JSON; continuing with fallback sources" "${FUNCNAME[0]}" "${LINENO}"
+ fi
printf "%b[*] Time fencing enabled: filtering crt.sh results to last %d days (since %s)%b\n" \
"$bblue" "${DNS_TIME_FENCE_DAYS}" "$cutoff_date" "$reset"
else
# Fallback if date calculation fails
- run_command crt -s -json -l "${CTR_LIMIT}" "$domain" 2>>"$LOGFILE" \
+ if ! run_command crt -s -json -l "${CTR_LIMIT}" "$domain" 2>>"$LOGFILE" \
| jq -r '.[].subdomain' 2>>"$LOGFILE" \
- | sed -e 's/^\*\.//' >.tmp/crtsh_subdomains.txt
+ | sed -e 's/^\*\.//' >.tmp/crtsh_subdomains.txt; then
+ log_note "sub_crt: crt source returned no valid JSON; continuing with fallback sources" "${FUNCNAME[0]}" "${LINENO}"
+ fi
fi
else
- run_command crt -s -json -l "${CTR_LIMIT}" "$domain" 2>>"$LOGFILE" \
+ if ! run_command crt -s -json -l "${CTR_LIMIT}" "$domain" 2>>"$LOGFILE" \
| jq -r '.[].subdomain' 2>>"$LOGFILE" \
- | sed -e 's/^\*\.//' >.tmp/crtsh_subdomains.txt
+ | sed -e 's/^\*\.//' >.tmp/crtsh_subdomains.txt; then
+ log_note "sub_crt: crt source returned no valid JSON; continuing with fallback sources" "${FUNCNAME[0]}" "${LINENO}"
+ fi
fi
- run_command curl -s "https://bgp.he.net/certs/api/list?domain=$domain" | jq -r 'try .domains[].domain' | sed -e 's/^\*\.//' | anew -q .tmp/crtsh_subdomains.txt
+ run_command curl -s "https://bgp.he.net/certs/api/list?domain=$domain" \
+ | jq -r 'try .domains[].domain' \
+ | sed -e 's/^\*\.//' \
+ | anew -q .tmp/crtsh_subdomains.txt || true
# Use anew to get new subdomains
- cat .tmp/crtsh_subdomains.txt | anew -q .tmp/crtsh_subs_tmp.txt
+ if [[ -s ".tmp/crtsh_subdomains.txt" ]]; then
+ anew -q .tmp/crtsh_subs_tmp.txt <.tmp/crtsh_subdomains.txt || true
+ fi
# If INSCOPE is true, check inscope
if [[ $INSCOPE == true ]]; then
if ! check_inscope .tmp/crtsh_subs_tmp.txt 2>>"$LOGFILE" >/dev/null; then
@@ -931,11 +945,16 @@ function sub_dns() {
| grep -E '^([a-zA-Z0-9][-a-zA-Z0-9]*\.)+[a-zA-Z]{2,}$' | sort -u \
| anew -q .tmp/subdomains_dns.txt
- for i in $(jq -r '.. | strings | select(test("^(\\d{1,3}\\.){3}\\d{1,3}$|^[0-9a-fA-F:]+$"))' <"subdomains/subdomains_dnsregs.json" | sort -u); do
- curl -s https://ip.thc.org/$i 2>>"$LOGFILE" | grep "\.${DOMAIN_ESCAPED}$" \
- | grep -E '^([a-zA-Z0-9][-a-zA-Z0-9]*\.)+[a-zA-Z]{2,}$' | sort -u \
- | anew -q .tmp/subdomains_dns.txt
- done
+ jq -r '.. | strings | select(test("^(\\d{1,3}\\.){3}\\d{1,3}$|^[0-9a-fA-F:]+$"))' <"subdomains/subdomains_dnsregs.json" \
+ | sort -u \
+ | while IFS= read -r ip; do
+ [[ -z "$ip" ]] && continue
+ curl -s "https://ip.thc.org/$ip" 2>>"$LOGFILE" \
+ | grep "\.${DOMAIN_ESCAPED}$" \
+ | grep -E '^([a-zA-Z0-9][-a-zA-Z0-9]*\.)+[a-zA-Z]{2,}$' \
+ | sort -u \
+ | anew -q .tmp/subdomains_dns.txt || true
+ done
jq -r 'select(.host) |"\(.host) - \((.a // [])[])", "\(.host) - \((.aaaa // [])[])"' <"subdomains/subdomains_dnsregs.json" \
| grep -E ' - [0-9a-fA-F:.]+$' | sort -u | anew -q "subdomains/subdomains_ips.txt"
@@ -1122,7 +1141,7 @@ function sub_scraping() {
if [[ -s ".tmp/url_extract_tmp.txt" ]]; then
cat .tmp/url_extract_tmp.txt | grep -a "$domain" \
| grep -aEo 'https?://[^ ]+' \
- | sed "s/^\*\.//" | unfurl -u domains 2>>"$LOGFILE" | anew -q .tmp/scrap_subs.txt
+ | sed "s/^\*\.//" | unfurl -u domains 2>>"$LOGFILE" | anew -q .tmp/scrap_subs.txt || true
fi
if command -v waymore &>/dev/null; then
@@ -1132,7 +1151,7 @@ function sub_scraping() {
if [[ -s ".tmp/waymore_urls_subs.txt" ]]; then
cat .tmp/waymore_urls_subs.txt | grep -a "$domain" \
| grep -aEo 'https?://[^ ]+' \
- | sed "s/^\*\.//" | unfurl -u domains 2>>"$LOGFILE" | anew -q .tmp/scrap_subs.txt
+ | sed "s/^\*\.//" | unfurl -u domains 2>>"$LOGFILE" | anew -q .tmp/scrap_subs.txt || true
fi
else
log_note "sub_scraping: waymore not found; skipping waymore passive collection" "${FUNCNAME[0]}" "${LINENO}"
@@ -1157,12 +1176,12 @@ function sub_scraping() {
| sed "s/^\*\.//" \
| anew .tmp/probed_tmp_scrap.txt \
| unfurl -u domains 2>>"$LOGFILE" \
- | anew -q .tmp/scrap_subs.txt
+ | anew -q .tmp/scrap_subs.txt || true
fi
if [[ -s ".tmp/probed_tmp_scrap.txt" ]]; then
cat .tmp/probed_tmp_scrap.txt | csprecon -s | grep -a "$domain" | sed "s/^\*\.//" | sort -u \
- | unfurl -u domains 2>>"$LOGFILE" | anew -q .tmp/scrap_subs.txt
+ | unfurl -u domains 2>>"$LOGFILE" | anew -q .tmp/scrap_subs.txt || true
fi
else
@@ -1184,12 +1203,12 @@ function sub_scraping() {
| sed "s/^\*\.//" \
| anew .tmp/probed_tmp_scrap.txt \
| unfurl -u domains 2>>"$LOGFILE" \
- | anew -q .tmp/scrap_subs.txt
+ | anew -q .tmp/scrap_subs.txt || true
fi
if [[ -s ".tmp/probed_tmp_scrap.txt" ]]; then
cat .tmp/probed_tmp_scrap.txt | csprecon -s | grep -a "$domain" | sed "s/^\*\.//" | sort -u \
- | unfurl -u domains 2>>"$LOGFILE" | anew -q .tmp/scrap_subs.txt
+ | unfurl -u domains 2>>"$LOGFILE" | anew -q .tmp/scrap_subs.txt || true
fi
fi
@@ -1201,7 +1220,7 @@ function sub_scraping() {
--wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" 2>>"$LOGFILE" >/dev/null
fi
- if [[ $INSCOPE == true ]]; then
+ if [[ $INSCOPE == true ]] && [[ -s ".tmp/scrap_subs_resolved.txt" ]]; then
if ! check_inscope .tmp/scrap_subs_resolved.txt 2>>"$LOGFILE" >/dev/null; then
printf "%b[!] check_inscope command failed.%b\n" "$bred" "$reset"
fi
@@ -1233,7 +1252,7 @@ function sub_scraping() {
| sed "s/^\*\.//" \
| anew .tmp/probed_tmp_scrap.txt \
| unfurl -u domains 2>>"$LOGFILE" \
- | anew -q .tmp/scrap_subs.txt
+ | anew -q .tmp/scrap_subs.txt || true
fi
fi
@@ -2024,7 +2043,9 @@ function subtakeover() {
# DNS Takeover
cat .tmp/subs_no_resolved.txt .tmp/subdomains_dns.txt .tmp/scrap_subs.txt \
- .tmp/analytics_subs_clean.txt .tmp/passive_recursive.txt 2>/dev/null | anew -q .tmp/subs_dns_tko.txt
+ .tmp/analytics_subs_clean.txt .tmp/passive_recursive.txt 2>/dev/null \
+ | sed '/^$/d' \
+ | anew -q .tmp/subs_dns_tko.txt || true
if [[ -s ".tmp/subs_dns_tko.txt" ]]; then
cat .tmp/subs_dns_tko.txt 2>/dev/null | dnstake -c "$DNSTAKE_THREADS" -s 2>>"$LOGFILE" \
diff --git a/modules/utils.sh b/modules/utils.sh
index a2f9037..1549bc0 100644
--- a/modules/utils.sh
+++ b/modules/utils.sh
@@ -299,15 +299,9 @@ function check_disk_space() {
local required_gb="$1"
local check_path="${2:-.}"
- # Get available space in GB
+ # Get available space in GB (portable across macOS/Linux).
local available_gb
- if [[ "$OSTYPE" == "darwin"* ]]; then
- # macOS
- available_gb=$(df -g "$check_path" | awk 'NR==2 {print $4}')
- else
- # Linux
- available_gb=$(df -BG "$check_path" | awk 'NR==2 {gsub(/G/, "", $4); print $4}')
- fi
+ available_gb=$(df -Pk "$check_path" 2>/dev/null | awk 'NR==2 {print int($4 / 1024 / 1024)}')
if [ -z "$available_gb" ] || [ "$available_gb" -lt "$required_gb" ]; then
printf "%b[%s] WARNING: Insufficient disk space. Required: %dGB, Available: %dGB at %s%b\n" \
diff --git a/modules/web.sh b/modules/web.sh
index 2dc78f9..9df7d6d 100644
--- a/modules/web.sh
+++ b/modules/web.sh
@@ -419,13 +419,16 @@ function portscan() {
else
# Domain is an IP address
- printf "%b\n" "$domain" | grep -aEiv "^(127|10|169\.254|172\.1[6-9]|172\.2[0-9]|172\.3[0-1]|192\.168)\." | grep -oE '\b([0-9]{1,3}\.){3}[0-9]{1,3}\b' | anew -q hosts/ips.txt
+ printf "%b\n" "$domain" \
+ | grep -aEiv "^(127|10|169\.254|172\.1[6-9]|172\.2[0-9]|172\.3[0-1]|192\.168)\." \
+ | grep -oE '\b([0-9]{1,3}\.){3}[0-9]{1,3}\b' \
+ | anew -q hosts/ips.txt || true
fi
# Check for CDN providers
if [[ ! -s "hosts/cdn_providers.txt" ]]; then
if [[ -s "hosts/ips.txt" ]]; then
- cat hosts/ips.txt | cdncheck -silent -resp -cdn -waf -nc 2>/dev/null | anew -q hosts/cdn_providers.txt
+ cat hosts/ips.txt | cdncheck -silent -resp -cdn -waf -nc 2>/dev/null | anew -q hosts/cdn_providers.txt || true
fi
fi
@@ -433,7 +436,7 @@ function portscan() {
# Remove CDN IPs
comm -23 <(sort -u hosts/ips.txt) <(cut -d'[' -f1 hosts/cdn_providers.txt | sed 's/[[:space:]]*$//' | sort -u) \
| grep -aEiv "^(127|10|169\.254|172\.1[6-9]|172\.2[0-9]|172\.3[0-1]|192\.168)\." | grep -oE '\b([0-9]{1,3}\.){3}[0-9]{1,3}\b' \
- | sort -u | anew -q .tmp/ips_nocdn.txt
+ | sort -u | anew -q .tmp/ips_nocdn.txt || true
fi
# Display resolved IPs without CDN
@@ -458,10 +461,10 @@ function portscan() {
if [[ $IPV6_SCAN == true ]]; then
if [[ -s "subdomains/subdomains_dnsregs.json" ]]; then
jq -r '.. | strings | select(test("^[0-9a-fA-F:]+$"))' <"subdomains/subdomains_dnsregs.json" \
- | grep -v '\\.' | sort -u | anew -q hosts/ips_v6.txt
+ | grep -v '\\.' | sort -u | anew -q hosts/ips_v6.txt || true
fi
# Add target if it's an IPv6 literal
- if [[ $domain =~ : ]]; then echo "$domain" | anew -q hosts/ips_v6.txt; fi
+ if [[ $domain =~ : ]]; then echo "$domain" | anew -q hosts/ips_v6.txt || true; fi
fi
if [[ $PORTSCAN_PASSIVE == true ]]; then
@@ -1106,8 +1109,31 @@ function cms_scanner() {
fi
# Run CMSeeK with timeout
- if ! timeout -k 1m "${CMSSCAN_TIMEOUT}s" "${tools}/CMSeeK/venv/bin/python3" "${tools}/CMSeeK/cmseek.py" -l .tmp/cms.txt --batch -r &>>"$LOGFILE"; then
+ local cmseek_cmd=(
+ timeout -k 1m "${CMSSCAN_TIMEOUT}s"
+ "${tools}/CMSeeK/venv/bin/python3" "${tools}/CMSeeK/cmseek.py"
+ -l .tmp/cms.txt --batch -r
+ )
+ local exit_status=0
+ local log_start=0
+ log_start=$(wc -l <"$LOGFILE" 2>/dev/null || echo 0)
+ if ! "${cmseek_cmd[@]}" &>>"$LOGFILE"; then
exit_status=$?
+ # Attempt one-time repair on known CMSeeK index corruption.
+ if tail -n +"$((log_start + 1))" "$LOGFILE" 2>/dev/null | grep -q "cmseekdb/createindex.py" \
+ && tail -n +"$((log_start + 1))" "$LOGFILE" 2>/dev/null | grep -q "JSONDecodeError"; then
+ log_note "cms_scanner: detected CMSeeK index corruption, repairing index and retrying once" "${FUNCNAME[0]}" "${LINENO}"
+ find "${tools}/CMSeeK/Result" -type f -name "*.json" -size 0 -delete 2>>"$LOGFILE" || true
+ if [[ -f "${tools}/CMSeeK/cmseekdb/createindex.py" ]]; then
+ "${tools}/CMSeeK/venv/bin/python3" "${tools}/CMSeeK/cmseekdb/createindex.py" &>>"$LOGFILE" || true
+ fi
+ if ! "${cmseek_cmd[@]}" &>>"$LOGFILE"; then
+ exit_status=$?
+ else
+ exit_status=0
+ fi
+ fi
+
if [[ ${exit_status} -eq 124 || ${exit_status} -eq 137 ]]; then
echo "TIMEOUT cmseek.py - investigate manually for $dir" >>"$LOGFILE"
end_func "TIMEOUT cmseek.py - investigate manually for $dir" "${FUNCNAME[0]}"
@@ -1416,22 +1442,21 @@ function url_ext() {
for t in "${ext[@]}"; do
# Extract unique matching URLs
- matches=$(
- (grep -aEi "\.(${t})($|/|\?)" ".tmp/url_extract_tmp.txt" 2>>"$LOGFILE" || true) \
- | sort -u | sed '/^$/d'
- )
+ grep -aEi "\.(${t})($|/|\?)" ".tmp/url_extract_tmp.txt" 2>>"$LOGFILE" \
+ | sort -u \
+ | sed '/^$/d' >".tmp/urls_by_ext_${t}.tmp" || true
- NUMOFLINES=$(echo "$matches" | wc -l)
+ NUMOFLINES=$(wc -l <".tmp/urls_by_ext_${t}.tmp" 2>/dev/null || echo 0)
if [[ $NUMOFLINES -gt 0 ]]; then
printf "\n############################\n + %s + \n############################\n" "$t" >>webs/urls_by_ext.txt
- echo "$matches" >>webs/urls_by_ext.txt
+ cat ".tmp/urls_by_ext_${t}.tmp" >>webs/urls_by_ext.txt
fi
done
# Append ssrf.txt to redirect.txt if ssrf.txt exists and is not empty
if [[ -s "gf/ssrf.txt" ]]; then
- cat "gf/ssrf.txt" | anew -q "gf/redirect.txt"
+ cat "gf/ssrf.txt" | anew -q "gf/redirect.txt" || true
fi
end_func "Results are saved in $domain/webs/urls_by_ext.txt" "${FUNCNAME[0]}"
@@ -1476,17 +1501,17 @@ function jschecks() {
printf "%bRunning: Fetching URLs 1/6%b\n" "$yellow" "$reset"
if [[ $AXIOM != true ]]; then
subjs -ua "Mozilla/5.0 (X11; Linux x86_64; rv:72.0) Gecko/20100101 Firefox/72.0" -c 40 <.tmp/url_extract_js.txt \
- | grep "$domain" \
- | grep -aEo 'https?://[^ ]+' | anew -q .tmp/subjslinks.txt
+ | grep -F "$domain" \
+ | grep -aEo 'https?://[^ ]+' | anew -q .tmp/subjslinks.txt || true
else
axiom-scan .tmp/url_extract_js.txt -m subjs -o .tmp/subjslinks.txt "$AXIOM_EXTRA_ARGS" 2>>"$LOGFILE" >/dev/null
fi
- if [[ -s ".tmp/subjslinks.txt" ]]; then
- grep -Eiv "\.(eot|jpg|jpeg|gif|css|tif|tiff|png|ttf|otf|woff|woff2|ico|pdf|svg|txt|js)$" .tmp/subjslinks.txt \
- | anew -q js/nojs_links.txt
- grep -iE '\.js([?#].*)?$|\.js([/?&].*)' .tmp/subjslinks.txt | anew -q .tmp/url_extract_js.txt
- fi
+ if [[ -s ".tmp/subjslinks.txt" ]]; then
+ grep -Eiv "\.(eot|jpg|jpeg|gif|css|tif|tiff|png|ttf|otf|woff|woff2|ico|pdf|svg|txt|js)$" .tmp/subjslinks.txt \
+ | anew -q js/nojs_links.txt || true
+ grep -iE '\.js([?#].*)?$|\.js([/?&].*)' .tmp/subjslinks.txt | anew -q .tmp/url_extract_js.txt || true
+ fi
urless <.tmp/url_extract_js.txt \
| anew -q js/url_extract_js.txt 2>>"$LOGFILE" >/dev/null
@@ -1505,7 +1530,7 @@ function jschecks() {
-content-type -retries 2 -no-color -o .tmp/js_livelinks.txt "$AXIOM_EXTRA_ARGS" 2>>"$LOGFILE" >/dev/null
if [[ -s ".tmp/js_livelinks.txt" ]]; then
cat .tmp/js_livelinks.txt | anew .tmp/web_full_info.txt \
- | grep "[200]" | grep "javascript" | cut -d ' ' -f1 | anew -q js/js_livelinks.txt
+ | grep "[200]" | grep "javascript" | cut -d ' ' -f1 | anew -q js/js_livelinks.txt || true
fi
fi
fi
@@ -1527,7 +1552,7 @@ function jschecks() {
fi
find .tmp/sourcemapper/ \( -name "*.js" -o -name "*.ts" \) -type f \
- | jsluice urls | jq -r .url | anew -q .tmp/js_endpoints.txt
+ | jsluice urls | jq -r .url | anew -q .tmp/js_endpoints.txt || true
printf "%bRunning: Gathering endpoints 4/6%b\n" "$yellow" "$reset"
if [[ -s "js/js_livelinks.txt" ]]; then
@@ -1537,19 +1562,24 @@ function jschecks() {
if [[ -s ".tmp/js_endpoints.txt" ]]; then
sed_i '/^\//!d' .tmp/js_endpoints.txt
- cat .tmp/js_endpoints.txt | anew -q js/js_endpoints.txt
+ cat .tmp/js_endpoints.txt | anew -q js/js_endpoints.txt || true
fi
printf "%bRunning: Gathering secrets 5/6%b\n" "$yellow" "$reset"
if [[ -s "js/js_livelinks.txt" ]]; then
if [[ $AXIOM != true ]]; then
- cat js/js_livelinks.txt | mantra -ua \"$HEADER\" -s | anew -q js/js_secrets.txt 2>>"$LOGFILE" >/dev/null
+ cat js/js_livelinks.txt | mantra -ua \"$HEADER\" -s | anew -q js/js_secrets.txt 2>>"$LOGFILE" >/dev/null || true
else
axiom-exec "go install github.com/Brosck/mantra@latest" 2>>"$LOGFILE" >/dev/null
axiom-scan js/js_livelinks.txt -m mantra -ua "$HEADER" -s -o js/js_secrets.txt "$AXIOM_EXTRA_ARGS" &>/dev/null
fi
mkdir -p .tmp/sourcemapper/secrets
- for i in $(cat js/js_secrets.txt | cut -d' ' -f2); do wget -q -P .tmp/sourcemapper/secrets $i; done
+ if [[ -s "js/js_secrets.txt" ]]; then
+ while IFS= read -r i; do
+ [[ -z "$i" ]] && continue
+ wget -q -P .tmp/sourcemapper/secrets -- "$i" || true
+ done < <(cut -d' ' -f2 js/js_secrets.txt)
+ fi
trufflehog filesystem .tmp/sourcemapper/ -j 2>/dev/null | jq -c | anew -q js/js_secrets_jsmap.txt
find .tmp/sourcemapper/ -type f -name "*.js" | jsluice secrets -j --patterns="${tools}/jsluice_patterns.json" | anew -q js/js_secrets_jsmap_jsluice.txt
fi
@@ -1561,11 +1591,11 @@ function jschecks() {
(
# shellcheck source=/dev/null
source "${GETJSWORDS_VENV}/bin/activate"
- if python3 -c "import jsbeautifier" 2>/dev/null; then
+ if python3 -c "import jsbeautifier, requests" 2>/dev/null; then
interlace -tL js/js_livelinks.txt -threads "$INTERLACE_THREADS" \
-c "python3 ${tools}/getjswords.py '_target_' | anew -q webs/dict_words.txt" 2>>"$LOGFILE" >/dev/null
else
- log_note "jsbeautifier not installed in venv ${GETJSWORDS_VENV}; skipping getjswords wordlist step" "${FUNCNAME[0]}" "${LINENO}"
+ log_note "jschecks: jsbeautifier/requests missing in venv ${GETJSWORDS_VENV}; skipping getjswords wordlist step" "${FUNCNAME[0]}" "${LINENO}"
fi
deactivate || true
)
@@ -1576,11 +1606,11 @@ function jschecks() {
local getjs_py="${GETJSWORDS_PYTHON:-python3}"
if ! command -v "$getjs_py" >/dev/null 2>&1; then
log_note "getjswords python not found: ${getjs_py}; skipping wordlist step" "${FUNCNAME[0]}" "${LINENO}"
- elif "$getjs_py" -c "import jsbeautifier" 2>/dev/null; then
+ elif "$getjs_py" -c "import jsbeautifier, requests" 2>/dev/null; then
interlace -tL js/js_livelinks.txt -threads "$INTERLACE_THREADS" \
-c "${getjs_py} ${tools}/getjswords.py '_target_' | anew -q webs/dict_words.txt" 2>>"$LOGFILE" >/dev/null
else
- log_note "jsbeautifier not installed in ${getjs_py}; skipping getjswords wordlist step" "${FUNCNAME[0]}" "${LINENO}"
+ log_note "jschecks: jsbeautifier/requests missing in ${getjs_py}; skipping getjswords wordlist step" "${FUNCNAME[0]}" "${LINENO}"
fi
fi
fi
@@ -1605,8 +1635,8 @@ function websocket_checks() {
start_func "${FUNCNAME[0]}" "WebSocket discovery and handshake"
# Collect ws/wss endpoints from JS endpoints and URLs
touch .tmp/ws_endpoints_raw.txt
- [[ -s js/js_endpoints.txt ]] && grep -aEo 'wss?://[^ ]+' js/js_endpoints.txt | anew -q .tmp/ws_endpoints_raw.txt
- [[ -s webs/url_extract.txt ]] && grep -aEo 'wss?://[^ ]+' webs/url_extract.txt | anew -q .tmp/ws_endpoints_raw.txt
+ [[ -s js/js_endpoints.txt ]] && grep -aEo 'wss?://[^ ]+' js/js_endpoints.txt | anew -q .tmp/ws_endpoints_raw.txt || true
+ [[ -s webs/url_extract.txt ]] && grep -aEo 'wss?://[^ ]+' webs/url_extract.txt | anew -q .tmp/ws_endpoints_raw.txt || true
if [[ -s .tmp/ws_endpoints_raw.txt ]]; then
# Normalize and de-dup
cat .tmp/ws_endpoints_raw.txt | sed 's/\"//g' | sed 's/[\]\[ ]//g' | sort -u >.tmp/ws_endpoints.txt
@@ -1624,7 +1654,7 @@ function websocket_checks() {
-H 'Sec-WebSocket-Version: 13' \
"$ws" || true)
if [[ $code == "101" ]]; then
- printf "HANDSHAKE %s\n" "$ws" | anew -q vulns/websockets.txt
+ printf "HANDSHAKE %s\n" "$ws" | anew -q vulns/websockets.txt || true
# Origin test: send a cross-origin header, expect failure ideally
wskey2=$(head -c 16 /dev/urandom | base64 2>/dev/null || echo dGVzdGtleQ==)
code2=$(curl -sk --http1.1 -o /dev/null -w '%{http_code}' \
@@ -1634,7 +1664,7 @@ function websocket_checks() {
-H 'Sec-WebSocket-Version: 13' \
"$ws" || true)
if [[ $code2 == "101" ]]; then
- printf "ORIGIN-ALLOWED %s\n" "$ws" | anew -q vulns/websocket_misconfig.txt
+ printf "ORIGIN-ALLOWED %s\n" "$ws" | anew -q vulns/websocket_misconfig.txt || true
fi
fi
done <.tmp/ws_endpoints.txt
diff --git a/reconftw.sh b/reconftw.sh
index 48d510a..8defa5b 100755
--- a/reconftw.sh
+++ b/reconftw.sh
@@ -90,19 +90,19 @@ fi
# macOS PATH initialization, thanks @0xtavian <3
if [[ $OSTYPE == "darwin"* ]]; then
if ! command -v brew &>/dev/null; then
- printf "\n%bBrew is not installed or not in the PATH.%b\n\n" "$bred" "$reset"
+ _print_error "Brew is not installed or not in the PATH"
exit 1
fi
if [[ ! -x "$(brew --prefix gnu-getopt)/bin/getopt" ]]; then
- printf "\n%bBrew formula gnu-getopt is not installed.%b\n\n" "$bred" "$reset"
+ _print_error "Brew formula gnu-getopt is not installed"
exit 1
fi
if [[ ! -d "$(brew --prefix coreutils)/libexec/gnubin" ]]; then
- printf "\n%bBrew formula coreutils is not installed.%b\n\n" "$bred" "$reset"
+ _print_error "Brew formula coreutils is not installed"
exit 1
fi
if [[ ! -d "$(brew --prefix gnu-sed)/libexec/gnubin" ]]; then
- printf "\n%bBrew formula gnu-sed is not installed.%b\n\n" "$bred" "$reset"
+ _print_error "Brew formula gnu-sed is not installed"
exit 1
fi
# Prefix is different depending on Intel vs Apple Silicon
@@ -222,7 +222,7 @@ while true; do
custom_function=$2
# Validate that the custom function exists
if ! declare -f "$custom_function" >/dev/null 2>&1; then
- printf "%bError: Custom function '%s' is not defined%b\n" "$bred" "$custom_function" "$reset" >&2
+ _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
@@ -453,7 +453,7 @@ fi
if [[ -n $outOfScope_file ]]; then
isAsciiText "$outOfScope_file"
if [[ "False" == "$IS_ASCII" ]]; then
- printf "\n\n${bred} Out of Scope file is not a text file${reset}\n\n"
+ _print_error "Out of Scope file is not a text file"
exit
fi
fi
@@ -461,7 +461,7 @@ fi
if [[ -n $inScope_file ]]; then
isAsciiText "$inScope_file"
if [[ "False" == "$IS_ASCII" ]]; then
- printf "\n\n${bred} In Scope file is not a text file${reset}\n\n"
+ _print_error "In Scope file is not a text file"
exit
fi
fi
@@ -492,9 +492,9 @@ fi
# Show DRY_RUN mode warning if enabled
if [[ "${DRY_RUN:-false}" == "true" ]]; then
- printf "\n%b#######################################################################%b\n" "$bgreen" "$reset"
- printf "%b[%s] DRY-RUN MODE ENABLED - Commands will be shown but not executed%b\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"
- printf "%b#######################################################################%b\n\n" "$bgreen" "$reset"
+ _print_rule
+ _print_status WARN "DRY-RUN MODE ENABLED" "Commands will be shown but not executed"
+ _print_rule
fi
startdir=${PWD}
@@ -603,7 +603,7 @@ case $opt_mode in
cp "${SCRIPTPATH}/$list" "$dir/webs/webs.txt"
fi
else
- printf "\n\n${bred} Web mode needs a website list file as target (./reconftw.sh -l target.txt -w) ${reset}\n\n"
+ _print_error "Web mode needs a website list file as target (./reconftw.sh -l target.txt -w)"
exit
fi
webs_menu
diff --git a/tests/unit/test_exports.bats b/tests/unit/test_exports.bats
index 97323db..a70fc92 100644
--- a/tests/unit/test_exports.bats
+++ b/tests/unit/test_exports.bats
@@ -13,6 +13,7 @@ setup() {
echo "a.example.com" > subdomains/subdomains.txt
echo "https://a.example.com" > webs/webs_all.txt
echo "1.1.1.1" > hosts/ips.txt
+ echo "2606:4700:4700::1111" > hosts/ips_v6.txt
echo '{"template-id":"tpl-h","matcher-name":"m1","type":"http","info":{"severity":"high","name":"High finding","tags":["x"]},"matched-at":"https://a.example.com","host":"a.example.com"}' > nuclei_output/high_json.txt
echo '{"type":"finding","value":"test","ts":"2026-01-01","source":"unit"}' > assets.jsonl
runtime="1 minutes 0 seconds"
@@ -49,4 +50,11 @@ teardown() {
[ -f report/report.json ]
[ -f report/findings.csv ]
[ -f report/export_all.jsonl ]
+ [ -f report/subdomains_clean.txt ]
+ [ -f report/webs_clean.txt ]
+ [ -f report/ips_clean.txt ]
+ grep -q "^a.example.com$" report/subdomains_clean.txt
+ grep -q "^https://a.example.com$" report/webs_clean.txt
+ grep -q "^1.1.1.1$" report/ips_clean.txt
+ grep -q "^2606:4700:4700::1111$" report/ips_clean.txt
}
diff --git a/tests/unit/test_verbosity.bats b/tests/unit/test_verbosity.bats
new file mode 100644
index 0000000..0739e90
--- /dev/null
+++ b/tests/unit/test_verbosity.bats
@@ -0,0 +1,162 @@
+#!/usr/bin/env bats
+# Tests for OUTPUT_VERBOSITY gating across core functions
+
+setup() {
+ TEST_DIR=$(mktemp -d)
+ cd "$TEST_DIR" || exit 1
+
+ # Minimal color vars
+ bred=""
+ bblue=""
+ bgreen=""
+ byellow=""
+ yellow=""
+ reset=""
+ cyan=""
+ green=""
+ red=""
+ blue=""
+
+ # Stubs for sourced modules
+ SCRIPTPATH="${BATS_TEST_DIRNAME}/../.."
+ LOGFILE="/dev/null"
+ NOTIFICATION=false
+ DIFF=false
+ domain="test.com"
+ called_fn_dir="$TEST_DIR/.called_fn"
+ mkdir -p "$called_fn_dir"
+
+ # Stubs for functions used by start_func/end_func
+ getElapsedTime() { runtime="0s"; }
+ record_func_timing() { :; }
+ log_json() { :; }
+
+ # Source common.sh (skip re-source guard)
+ _COMMON_SH_LOADED=""
+ source "${BATS_TEST_DIRNAME}/../../lib/common.sh"
+
+ # Extract individual functions from core.sh using sed
+ local corefile="${BATS_TEST_DIRNAME}/../../modules/core.sh"
+
+ # Extract notification function
+ eval "$(sed -n '/^function notification()/,/^}/p' "$corefile")"
+ # Extract start_func
+ eval "$(sed -n '/^function start_func()/,/^}/p' "$corefile")"
+ # Extract end_func
+ eval "$(sed -n '/^function end_func()/,/^}/p' "$corefile")"
+ # Extract progress_step
+ eval "$(sed -n '/^function progress_step()/,/^}/p' "$corefile")"
+}
+
+teardown() {
+ cd /
+ rm -rf "$TEST_DIR"
+}
+
+###############################################################################
+# notification() verbosity tests
+###############################################################################
+
+@test "notification prints info at verbosity 1" {
+ OUTPUT_VERBOSITY=1
+ run notification "hello world" info
+ [ "$status" -eq 0 ]
+ [[ "$output" == *"hello world"* ]]
+}
+
+@test "notification suppresses info at verbosity 0" {
+ OUTPUT_VERBOSITY=0
+ run notification "hello world" info
+ [ "$status" -eq 0 ]
+ [[ "$output" == "" ]]
+}
+
+@test "notification shows errors at verbosity 0" {
+ OUTPUT_VERBOSITY=0
+ run notification "something broke" error
+ [ "$status" -eq 0 ]
+ [[ "$output" == *"something broke"* ]]
+}
+
+@test "notification shows all at verbosity 2" {
+ OUTPUT_VERBOSITY=2
+ run notification "detail info" info
+ [ "$status" -eq 0 ]
+ [[ "$output" == *"detail info"* ]]
+}
+
+###############################################################################
+# skip_notification() verbosity tests
+###############################################################################
+
+@test "skip_notification prints at verbosity 1" {
+ OUTPUT_VERBOSITY=1
+ run skip_notification "disabled"
+ [ "$status" -eq 0 ]
+ [[ "$output" == *"skipped"* ]]
+}
+
+@test "skip_notification suppressed at verbosity 0" {
+ OUTPUT_VERBOSITY=0
+ run skip_notification "disabled"
+ [ "$status" -eq 0 ]
+ [[ "$output" == "" ]]
+}
+
+###############################################################################
+# start_func / end_func verbosity tests
+###############################################################################
+
+@test "start_func shows rule at verbosity 1" {
+ OUTPUT_VERBOSITY=1
+ run start_func "test_fn" "Testing function"
+ [ "$status" -eq 0 ]
+ [[ "$output" == *"──"* ]]
+}
+
+@test "start_func hides rule at verbosity 0" {
+ OUTPUT_VERBOSITY=0
+ run start_func "test_fn" "Testing function"
+ [ "$status" -eq 0 ]
+ [[ "$output" != *"──"* ]]
+}
+
+@test "end_func shows status at verbosity 1" {
+ OUTPUT_VERBOSITY=1
+ start=1
+ run end_func "Results" "test_fn"
+ [ "$status" -eq 0 ]
+ [[ "$output" == *"[OK"* ]]
+}
+
+@test "end_func hides status at verbosity 0" {
+ OUTPUT_VERBOSITY=0
+ start=1
+ run end_func "Results" "test_fn"
+ [ "$status" -eq 0 ]
+ [[ "$output" != *"[OK"* ]]
+}
+
+###############################################################################
+# progress_step() verbosity tests
+###############################################################################
+
+@test "progress_step prints at verbosity 1" {
+ OUTPUT_VERBOSITY=1
+ _PROGRESS_TOTAL_STEPS=10
+ _PROGRESS_CURRENT_STEP=0
+ _PROGRESS_START_TIME=$(date +%s)
+ run progress_step "scanning"
+ [ "$status" -eq 0 ]
+ [[ "$output" == *"Progress"* ]]
+}
+
+@test "progress_step suppressed at verbosity 0" {
+ OUTPUT_VERBOSITY=0
+ _PROGRESS_TOTAL_STEPS=10
+ _PROGRESS_CURRENT_STEP=0
+ _PROGRESS_START_TIME=$(date +%s)
+ run progress_step "scanning"
+ [ "$status" -eq 0 ]
+ [[ "$output" == "" ]]
+}