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
Shell bug-bountybugbountybugbounty-tooldnshackingnucleiosintpenetration-testingpentestpentest-toolpentestingreconreconnaissancescannersecuritysecurity-toolssubdomainsubdomain-enumerationvulnerabilities
Fix webprobe simple2
six2dez53337473d870
diff --git a/lib/common.sh b/lib/common.shindex 5b2675e..6882761 100644--- a/lib/common.sh+++ b/lib/common.sh@@ -91,6 +91,34 @@ dedupe_append() {fi}+# Pipe-safe anew wrapper: treats rc=1 (no new lines added) as success.+# Usage: ... | anew_safe <file>+anew_safe() {+ local file="$1"+ if ! command -v anew &>/dev/null; then+ cat >> "$file"+ return 0+ fi+ anew "$file"+ local rc=$?+ (( rc <= 1 )) && return 0+ return "$rc"+}++# Pipe-safe anew -q wrapper: treats rc=1 (no new lines added) as success.+# Usage: ... | anew_q_safe <file>+anew_q_safe() {+ local file="$1"+ if ! command -v anew &>/dev/null; then+ cat >> "$file"+ return 0+ fi+ anew -q "$file"+ local rc=$?+ (( rc <= 1 )) && return 0+ return "$rc"+}+# Count non-empty lines in a file safely# Usage: count_lines filename# Returns: line count (0 if file doesn't exist or is empty)@@ -161,6 +189,7 @@ print_task() {WARN) color="${yellow:-}" ;;FAIL) color="${bred:-}" ;;SKIP|CACHE) color="${dim_color:-}" ;;+ RUN) color="${cyan:-}" ;;INFO) color="${bblue:-}" ;;*) color="${bblue:-}" ;;esacdiff --git a/lib/ui.sh b/lib/ui.shindex 0cb166f..895fa98 100644--- a/lib/ui.sh+++ b/lib/ui.sh@@ -126,6 +126,9 @@ ui_header() {printf "Mode: %s | Target: %s | Profile: %s | Parallel: %s | Jobs: %s\n" \"$mode_label" "$target" "$(basename "${profile}")" "$parallel" "$threads"printf "Output: %s\n" "$outdir"+ if [[ -n "${RECON_BEHIND_NAT:-}" ]] || [[ -n "${DNS_RESOLVER_SELECTED:-}" ]]; then+ printf "Network: behind_nat=%s | DNS: %s\n" "${RECON_BEHIND_NAT:-unknown}" "${DNS_RESOLVER_SELECTED:-unknown}"+ fiif [[ -n "${PERF_PROFILE_INFO:-}" ]] || [[ -n "${DISK_SPACE_INFO:-}" ]]; thenlocal info_line=""if [[ -n "${PERF_PROFILE_INFO:-}" ]]; thendiff --git a/modules/axiom.sh b/modules/axiom.shindex b2730c2..5fcc166 100644--- a/modules/axiom.sh+++ b/modules/axiom.sh@@ -98,6 +98,7 @@ function axiom_launch() {start_func "${FUNCNAME[0]}" "Launching our Axiom fleet"# Check to see if we have a fleet already, if so, SKIP THIS!+ print_notice RUN "axiom_launch" "launching axiom fleet"NUMOFNODES=$(timeout 30 axiom-ls 2>>"$LOGFILE" | grep -c "$AXIOM_FLEET_NAME" || true)if [[ $NUMOFNODES -ge $AXIOM_FLEET_COUNT ]]; thenaxiom-select "$AXIOM_FLEET_NAME*" 2>>"$LOGFILE" >/dev/null@@ -152,6 +153,7 @@ function axiom_selected() {fi# Probe Axiom connectivity and optionally auto-repair host-key mismatches.+ print_notice RUN "axiom_selected" "checking axiom connectivity"local axiom_probe_outaxiom_probe_out="$(axiom-exec "echo reconftw-axiom-probe" 2>&1 || true)"if echo "$axiom_probe_out" | grep -q "REMOTE HOST IDENTIFICATION HAS CHANGED"; thendiff --git a/modules/subdomains.sh b/modules/subdomains.shindex a84b08b..cd8952f 100644--- a/modules/subdomains.sh+++ b/modules/subdomains.sh@@ -1030,6 +1030,7 @@ function sub_scraping() {fiif command -v waymore &>/dev/null; then+ print_notice RUN "waymore" "collecting passive URLs (waymore)"if ! "$TIMEOUT_CMD" "${WAYMORE_TIMEOUT:-30m}" waymore -i "$domain" -mode U -oU .tmp/waymore_urls_subs.txt 2>>"$LOGFILE" >/dev/null; thenlog_note "sub_scraping: waymore failed or timed out; continuing" "${FUNCNAME[0]}" "${LINENO}"fi@@ -1808,6 +1809,7 @@ function subtakeover() {elsecat subdomains/subdomains.txt webs/webs_all.txt 2>>"$LOGFILE" | sed '/^$/d' | anew -q .tmp/webs_subs.txtif [[ -s ".tmp/webs_subs.txt" ]]; then+ print_notice RUN "takeover_nuclei" "scanning takeovers on axiom"run_command axiom-scan .tmp/webs_subs.txt -m nuclei --nuclei-templates "${NUCLEI_TEMPLATES_PATH}" \-tags takeover -nh -severity info,low,medium,high,critical -retries 3 -rl "$NUCLEI_RATELIMIT" \-t "${NUCLEI_TEMPLATES_PATH}" -j -o .tmp/tko_json.txt $AXIOM_EXTRA_ARGS 2>>"$LOGFILE" >/dev/null@@ -2010,6 +2012,7 @@ function s3buckets() {fiprintf "Processing domain: %s\n" "$domain" >>"$LOGFILE"+ print_notice RUN "cloudhunter" "enumerating cloud buckets (CloudHunter)"(if ! cd "$tools/CloudHunter"; thenprint_warnf "Failed to cd to %s." "$tools/CloudHunter"diff --git a/modules/utils.sh b/modules/utils.shindex b0c3cd0..888fe89 100644--- a/modules/utils.sh+++ b/modules/utils.sh@@ -1075,6 +1075,15 @@ init_dns_resolver() {local ipip=$(_get_local_ip)+ # Expose NAT detection and local IP for UI/logging.+ # Note: This is a best-effort heuristic based on the primary local IPv4 address.+ RECON_LOCAL_IP="${ip:-}"+ RECON_BEHIND_NAT="yes"+ if _ip_is_public_ipv4 "$ip"; then+ RECON_BEHIND_NAT="no"+ fi+ export RECON_LOCAL_IP RECON_BEHIND_NAT+DNS_RESOLVER_SELECTED=""case "$mode" inpuredns|dnsx)diff --git a/modules/web.sh b/modules/web.shindex d1e3907..7e6e2cc 100644--- a/modules/web.sh+++ b/modules/web.sh@@ -52,12 +52,12 @@ _process_httpx_output() {| grep "$domain" \| grep -aEo 'https?://[^ ]+' \| sed 's/*.//' \- | anew -q "$url_output"-+ | anew_q_safe "$url_output"+# Extract plain web infojq -r 'try . | "\(.url) [\(.status_code)] [\(.title)] [\(.webserver)] \(.tech)"' "$json_file" \| grep "$domain" \- | anew -q "$info_output"+ | anew_q_safe "$info_output"}# Send URLs to proxy if enabled@@ -155,13 +155,13 @@ function webprobe_simple() {if [[ -s "webs/web_full_info.txt" ]]; thenjq -r 'try (.url // empty)' webs/web_full_info.txt 2>/dev/null \| awk -v dom="$domain" 'index($0, dom) && $0 ~ /^https?:\\/\\// {print}' \- | sed 's/*.//' | anew -q .tmp/probed_tmp.txt+ | sed 's/*.//' | anew_q_safe .tmp/probed_tmp.txtfielselog_note "webprobe_simple: probe output not JSON; treating as URL list" "${FUNCNAME[0]}" "${LINENO}"if [[ -s ".tmp/web_full_info_probe.txt" ]]; thenawk -v dom="$domain" 'index($0, dom) && $0 ~ /^https?:\\/\\// {print}' .tmp/web_full_info_probe.txt 2>/dev/null \- | sed 's/*.//' | anew -q .tmp/probed_tmp.txt+ | sed 's/*.//' | anew_q_safe .tmp/probed_tmp.txtfifi@@ -174,7 +174,7 @@ function webprobe_simple() {# Extract web info to plain textif [[ -s "webs/web_full_info.txt" ]]; thenjq -r 'try . |"\(.url) [\(.status_code)] [\(.title)] [\(.webserver)] \(.tech)"' webs/web_full_info.txt \- | grep "$domain" | anew -q webs/web_full_info_plain.txt+ | grep "$domain" | anew_q_safe webs/web_full_info_plain.txtfi# Remove out-of-scope entries@@ -187,7 +187,7 @@ function webprobe_simple() {touch .tmp/probed_tmp.txt# Count new websites- if ! NUMOFLINES=$(anew webs/webs.txt <.tmp/probed_tmp.txt 2>/dev/null | sed '/^$/d' | wc -l); then+ if ! NUMOFLINES=$(anew_safe webs/webs.txt <.tmp/probed_tmp.txt 2>/dev/null | sed '/^$/d' | wc -l); thenprint_warnf "Failed to count new websites."NUMOFLINES=0fi@@ -260,22 +260,22 @@ function webprobe_full() {| grep "$domain" \| grep -aEo 'https?://[^ ]+' \| sed 's/*.//' \- | anew -q .tmp/probed_uncommon_ports_tmp.txt+ | anew_q_safe .tmp/probed_uncommon_ports_tmp.txt# Extract plain web infojq -r 'try . | "\(.url) [\(.status_code)] [\(.title)] [\(.webserver)] \(.tech)"' .tmp/web_full_info_uncommon.txt \| grep "$domain" \- | anew -q webs/web_full_info_uncommon_plain.txt+ | anew_q_safe webs/web_full_info_uncommon_plain.txt# Update webs_full_info_uncommon.txt based on whether domain is IPif [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then- cat .tmp/web_full_info_uncommon.txt 2>>"$LOGFILE" | anew -q webs/web_full_info_uncommon.txt+ cat .tmp/web_full_info_uncommon.txt 2>>"$LOGFILE" | anew_q_safe webs/web_full_info_uncommon.txtelse- grep "$domain" .tmp/web_full_info_uncommon.txt | anew -q webs/web_full_info_uncommon.txt+ grep "$domain" .tmp/web_full_info_uncommon.txt | anew_q_safe webs/web_full_info_uncommon.txtfi# Count new websites- if ! NUMOFLINES=$(anew webs/webs_uncommon_ports.txt <.tmp/probed_uncommon_ports_tmp.txt | sed '/^$/d' | wc -l); then+ if ! NUMOFLINES=$(anew_safe webs/webs_uncommon_ports.txt <.tmp/probed_uncommon_ports_tmp.txt | sed '/^$/d' | wc -l); thenprint_warnf "Failed to count new websites."NUMOFLINES=0fidiff --git a/tests/unit/test_common.bats b/tests/unit/test_common.batsindex f82223b..bb68f62 100644--- a/tests/unit/test_common.bats+++ b/tests/unit/test_common.bats@@ -231,3 +231,40 @@ teardown() {run test_func[ "$status" -eq 0 ]}++###############################################################################+# anew_safe / anew_q_safe tests+###############################################################################++@test "anew_q_safe returns 0 when anew adds new lines" {+ local outfile="$TEST_DIR/out.txt"+ touch "$outfile"+ run bash -c 'echo "newline" | anew_q_safe "'"$outfile"'"'+ [ "$status" -eq 0 ]+ grep -q "newline" "$outfile"+}++@test "anew_q_safe returns 0 when anew adds no new lines (rc=1 from anew)" {+ local outfile="$TEST_DIR/out.txt"+ echo "duplicate" > "$outfile"+ run bash -c 'echo "duplicate" | anew_q_safe "'"$outfile"'"'+ [ "$status" -eq 0 ]+}++@test "anew_q_safe writes unique lines to file" {+ local outfile="$TEST_DIR/out.txt"+ echo "existing" > "$outfile"+ run bash -c 'printf "existing\nnewone\n" | anew_q_safe "'"$outfile"'"'+ [ "$status" -eq 0 ]+ grep -q "newone" "$outfile"+ [ "$(wc -l < "$outfile")" -eq 2 ]+}++@test "anew_safe returns 0 and outputs new lines" {+ local outfile="$TEST_DIR/out.txt"+ echo "old" > "$outfile"+ run bash -c 'printf "old\nnew\n" | anew_safe "'"$outfile"'"'+ [ "$status" -eq 0 ]+ [[ "$output" == *"new"* ]]+ grep -q "new" "$outfile"+}