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

feat: optional proxychains routing for external tools (#1041)

six2dez6cbabe068624
diff --git a/modules/utils.sh b/modules/utils.sh
index 47cb553..9eb8d96 100644
--- a/modules/utils.sh
+++ b/modules/utils.sh
@@ -489,6 +489,48 @@ function progress_bar() {
# Execute command in dry-run mode if enabled
# Usage: run_command <command> [args...]
+# _proxychains_bin — echo the proxychains binary to use, or fail.
+# PROXYCHAINS_BIN wins when set; otherwise proxychains4 is preferred because the
+# proxychains-ng fork is what ships as `proxychains4` on Debian/Ubuntu and as
+# `proxychains-ng` (binary `proxychains4`) on Homebrew.
+function _proxychains_bin() {
+ if [[ -n "${PROXYCHAINS_BIN:-}" ]]; then
+ command -v "$PROXYCHAINS_BIN" 2>/dev/null && return 0
+ return 1
+ fi
+ command -v proxychains4 2>/dev/null && return 0
+ command -v proxychains 2>/dev/null && return 0
+ return 1
+}
+
+# _proxychains_applies <tool-name> — false for tools proxychains cannot carry.
+#
+# proxychains hooks libc connect() and covers TCP only. Three classes break
+# under it, and breaking them silently is worse than not proxying them:
+#
+# * mass-DNS resolvers (massdns, puredns, dnsx, shuffledns) send raw UDP/53
+# from their own socket code. Under proxychains they either fall back to the
+# system resolver or return nothing at all — the resolution step then
+# reports zero hosts and the whole run looks empty for no visible reason.
+# * naabu/nmap SYN scanning uses raw sockets, which never reach connect().
+# * statically-linked Go binaries do not resolve libc symbols, so the LD_PRELOAD
+# hook is a no-op; they leak DIRECTLY while appearing proxied. The
+# ProjectDiscovery tools are the common case here, which is why the honest
+# answer for them is their own -proxy flag, not this wrapper.
+#
+# PROXYCHAINS_EXCLUDE lets an operator extend the list without editing code.
+function _proxychains_applies() {
+ local _tool="${1:-}"
+ [[ -z "$_tool" ]] && return 1
+
+ local _skip
+ for _skip in massdns puredns dnsx shuffledns naabu nmap masscan \
+ ${PROXYCHAINS_EXCLUDE:-}; do
+ [[ "$_tool" == "$_skip" ]] && return 1
+ done
+ return 0
+}
+
function run_command() {
if [[ "${DRY_RUN:-false}" == "true" ]]; then
# Extract tool name (first word, strip path)
@@ -520,6 +562,24 @@ function run_command() {
return $?
fi
+ # PROXYCHAINS (#1041): route this tool's traffic through the configured
+ # chain. Applied HERE because run_command is the single gate every external
+ # tool goes through, so one place covers all of them without touching each
+ # tool's own (mutually incompatible) proxy flags.
+ if [[ "${PROXYCHAINS:-false}" == "true" ]] && _proxychains_applies "$cmd_name"; then
+ local _pc
+ if _pc=$(_proxychains_bin); then
+ local -a _pc_argv=("$_pc" -q)
+ [[ -n "${PROXYCHAINS_CONF:-}" ]] && _pc_argv+=(-f "$PROXYCHAINS_CONF")
+ set -- "${_pc_argv[@]}" "$@"
+ else
+ # Fail LOUD, not silently direct: the whole point of enabling this is
+ # that the operator does not want these packets leaving un-proxied.
+ notification "PROXYCHAINS=true but no proxychains binary was found — ${cmd_name} would run UN-PROXIED; skipping it" warn
+ return 1
+ fi
+ fi
+
if [[ "${ADAPTIVE_RATE_LIMIT:-false}" == "true" ]]; then
run_with_adaptive_rate "$@"
else
diff --git a/reconftw.cfg b/reconftw.cfg
index e8a709c..06e5329 100644
--- a/reconftw.cfg
+++ b/reconftw.cfg
@@ -31,6 +31,16 @@ RESOLVER_DOWNLOAD_RETRY=2 # Retry count for resolver downloads
RESOLVER_DOWNLOAD_RETRY_DELAY=2 # Delay in seconds between resolver download retries
fuzzing_remote_list="https://raw.githubusercontent.com/six2dez/OneListForAll/main/onelistforallmicro.txt" # Used to send to Ax (if used) on fuzzing
proxy_url="http://127.0.0.1:8080/" # Proxy url
+# proxychains (#1041): route external tool traffic through a chain/rotating exit.
+# Distinct from proxy_url above, which only REPLAYS discovered URLs to a local
+# intercepting proxy (Burp/Caido) and does not carry scan traffic.
+# Requires proxychains (proxychains-ng recommended) and a configured chain.
+# NOT applied to mass-DNS resolvers, port scanners, or raw-socket tools — see
+# _proxychains_applies() in modules/utils.sh for why each is excluded.
+PROXYCHAINS=false # Wrap external tools in proxychains
+PROXYCHAINS_BIN="" # Binary to use; empty = autodetect proxychains4 then proxychains
+PROXYCHAINS_CONF="" # Explicit -f config; empty = proxychains' own default lookup
+PROXYCHAINS_EXCLUDE="" # Extra space-separated tool names to never proxy
install_golang=true # Set it to false if you already have Golang configured and ready
upgrade_tools=true
upgrade_before_running=false # Upgrade tools before running
@@ -127,6 +137,8 @@ POSTLEAKS_EXCLUDE="" # Optional exclude filter for postleaksNg URL results
THIRD_PARTIES=true # Check for 3rd parties misconfigs
SPOOF=true # Check spoofable domains
MAIL_HYGIENE=true # Check DMARC/SPF records
+LUNAR_EXPOSURE=false # Domain exposure in infostealer logs/breaches via Lunar API (free, no token; opt-in because it sends the target to a third party)
+LUNAR_TIMEOUT=30 # Seconds before giving up on the Lunar API
CLOUD_ENUM=true # Enumerate cloud storage across providers with cloud_enum
GITHUB_LEAKS=true # Search for leaked secrets across all of GitHub with ghleaks
GHLEAKS_THREADS=5 # Concurrent download threads for ghleaks
diff --git a/tests/unit/test_proxychains.bats b/tests/unit/test_proxychains.bats
new file mode 100644
index 0000000..1f17add
--- /dev/null
+++ b/tests/unit/test_proxychains.bats
@@ -0,0 +1,109 @@
+#!/usr/bin/env bats
+#
+# Coverage for the proxychains integration (#1041).
+#
+# The wrapping happens in run_command, the single gate every external tool goes
+# through, so these tests drive run_command rather than any one module.
+#
+# The property that matters is not "does it prepend proxychains" — it is that
+# the tools proxychains CANNOT carry are never wrapped, and that a missing
+# binary does not silently produce an un-proxied request. An operator turns this
+# on precisely because they do not want those packets leaving directly.
+
+setup() {
+ source "$(cd "$(dirname "$BATS_TEST_FILENAME")" && pwd)/../helpers/common.bash"
+ setup_recon_env
+
+ export TEST_DIR="$(mktemp -d)"
+ cd "$TEST_DIR"
+
+ # A stub `proxychains4` that records how it was invoked instead of proxying.
+ mkdir -p bin
+ cat > bin/proxychains4 <<'STUB'
+#!/usr/bin/env bash
+printf '%s\n' "$*" >> "$PC_CALLS"
+# Drop proxychains' own flags and run whatever it was asked to wrap.
+while [[ $# -gt 0 ]]; do
+ case "$1" in
+ -q) shift ;;
+ -f) shift 2 ;;
+ *) break ;;
+ esac
+done
+exec "$@"
+STUB
+ chmod +x bin/proxychains4
+ export PATH="$TEST_DIR/bin:$PATH"
+ export PC_CALLS="$TEST_DIR/pc_calls.txt"
+ : > "$PC_CALLS"
+
+ # An ordinary tool to be wrapped, and a DNS tool that must not be.
+ cat > bin/httpx <<'STUB'
+#!/usr/bin/env bash
+echo "httpx ran"
+STUB
+ cat > bin/puredns <<'STUB'
+#!/usr/bin/env bash
+echo "puredns ran"
+STUB
+ chmod +x bin/httpx bin/puredns
+
+ export PROXYCHAINS_BIN="" PROXYCHAINS_CONF="" PROXYCHAINS_EXCLUDE=""
+ export DRY_RUN=false ADAPTIVE_RATE_LIMIT=false DEBUG_LOG=""
+}
+
+teardown() {
+ cd /
+ rm -rf "$TEST_DIR"
+}
+
+@test "PROXYCHAINS=false leaves the command untouched" {
+ export PROXYCHAINS=false
+ run run_command httpx -silent
+ [ "$status" -eq 0 ] \
+ && [ "$output" = "httpx ran" ] \
+ && [ ! -s "$PC_CALLS" ]
+}
+
+@test "PROXYCHAINS=true wraps an ordinary tool" {
+ export PROXYCHAINS=true
+ run run_command httpx -silent
+ [ "$status" -eq 0 ] \
+ && [ -s "$PC_CALLS" ] \
+ && grep -q 'httpx' "$PC_CALLS"
+}
+
+@test "PROXYCHAINS_CONF is passed through as -f" {
+ export PROXYCHAINS=true
+ export PROXYCHAINS_CONF="$TEST_DIR/chain.conf"
+ : > "$PROXYCHAINS_CONF"
+ run run_command httpx -silent
+ [ "$status" -eq 0 ] && grep -q -- "-f $PROXYCHAINS_CONF" "$PC_CALLS"
+}
+
+@test "mass-DNS tools are never wrapped: proxychains cannot carry their UDP" {
+ export PROXYCHAINS=true
+ run run_command puredns resolve
+ # It must still run, and it must not have gone through the chain.
+ [ "$status" -eq 0 ] \
+ && [ "$output" = "puredns ran" ] \
+ && [ ! -s "$PC_CALLS" ]
+}
+
+@test "PROXYCHAINS_EXCLUDE adds tools to the never-wrap list" {
+ export PROXYCHAINS=true
+ export PROXYCHAINS_EXCLUDE="httpx"
+ run run_command httpx -silent
+ [ "$status" -eq 0 ] \
+ && [ "$output" = "httpx ran" ] \
+ && [ ! -s "$PC_CALLS" ]
+}
+
+@test "a missing proxychains binary fails the command instead of running it direct" {
+ export PROXYCHAINS=true
+ export PROXYCHAINS_BIN="proxychains-that-does-not-exist"
+ run run_command httpx -silent
+ # The tool must NOT have run: an un-proxied request is the one outcome the
+ # operator enabled this to prevent.
+ [ "$status" -ne 0 ] && [ "${output}" != "httpx ran" ]
+}