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

updates and fixes

six2dez2d2994b732d0
diff --git a/install.sh b/install.sh
index e2bde4f..789a82c 100755
--- a/install.sh
+++ b/install.sh
@@ -21,7 +21,10 @@ if [[ ! -f $CONFIG_FILE ]]; then
fi
# shellcheck source=./reconftw.cfg
-source "$CONFIG_FILE"
+if ! source "$CONFIG_FILE"; then
+ printf "[!] Failed to parse config file %s. Check for syntax errors.\n" "$CONFIG_FILE" >&2
+ exit 1
+fi
# Initialize variables
dir="${tools}"
@@ -114,6 +117,39 @@ ensure_git_dir() {
fi
}
+# Install Rust toolchain, uv package manager, smugglex, and shodan CLI.
+# Called from install_apt/install_yum/install_pacman/install_brew to avoid duplication.
+install_rust_uv() {
+ local _tmpfile
+ # Install rustup via downloaded script (verify before executing)
+ _tmpfile=$(mktemp "${TMPDIR:-/tmp}/rustup_install.XXXXXX")
+ if curl -sSf https://sh.rustup.rs -o "$_tmpfile" 2>/dev/null; then
+ sh "$_tmpfile" -y >/dev/null 2>&1
+ else
+ msg_warn "[!] Failed to download rustup installer"
+ fi
+ rm -f "$_tmpfile"
+
+ # shellcheck source=/dev/null
+ source "${HOME}/.cargo/env" 2>/dev/null || true
+ cargo install smugglex &>/dev/null
+
+ # Install uv via downloaded script (verify before executing)
+ _tmpfile=$(mktemp "${TMPDIR:-/tmp}/uv_install.XXXXXX")
+ if curl -LsSf https://astral.sh/uv/install.sh -o "$_tmpfile" 2>/dev/null; then
+ sh "$_tmpfile" &>/dev/null
+ else
+ msg_warn "[!] Failed to download uv installer"
+ fi
+ rm -f "$_tmpfile"
+
+ # shellcheck source=/dev/null
+ source "${HOME}/.local/bin/env" 2>/dev/null || export PATH="${HOME}/.local/bin:$PATH"
+ uv tool update-shell &>/dev/null || true
+ # Install shodan CLI via uv
+ uv tool install shodan --force &>/dev/null || uv tool upgrade shodan &>/dev/null || true
+}
+
# Non-fatal error trap: log and continue
trap 'rc=$?; ts=$(date +"%Y-%m-%d %H:%M:%S"); cmd=${BASH_COMMAND}; loc_ln=${BASH_LINENO[0]:-0}; msg="[$ts] install.sh ERR($rc) @ line ${loc_ln} :: ${cmd}"; if [[ -n "${LOGFILE:-}" ]]; then echo "$msg" >>"$LOGFILE"; else echo "$msg" >&2; fi' ERR
@@ -123,12 +159,10 @@ trap 'rc=$?; ts=$(date +"%Y-%m-%d %H:%M:%S"); cmd=${BASH_COMMAND}; loc_ln=${BASH
header() { printf "%bRunning: %s%b\n" "$bblue" "$1" "$reset"; }
msg_run() { printf "%b%s%b\n" "$yellow" "$1" "$reset"; }
-msg_ok() { printf "%b%s%b\n" "$yellow" "$1" "$reset"; }
+msg_ok() { printf "%b%s%b\n" "$bgreen" "$1" "$reset"; }
msg_warn() { printf "%b%s%b\n" "$yellow" "$1" "$reset"; }
msg_err() { printf "%b%s%b\n" "$red" "$1" "$reset"; }
-# Progress helper (simple spinner output)
-progress_update() { :; }
with_spinner() {
local _msg="$1"
shift
@@ -142,6 +176,17 @@ with_spinner() {
"$@"
return $?
fi
+ if [[ ! -t 1 ]]; then
+ [[ -n $_msg ]] && printf "%s ... " "$_msg"
+ "$@" >/dev/null 2>&1
+ local exit_code=$?
+ if [[ $exit_code -eq 0 ]]; then
+ printf "done\n"
+ else
+ printf "failed\n"
+ fi
+ return $exit_code
+ fi
local spinner="|/-\\"
local spinner_len=4
local i=0
@@ -163,20 +208,21 @@ with_spinner() {
return $exit_code
}
-# Keep arrays defined for potential later use, but classic UI prints a short summary only
-declare -a INST_GO_OK INST_GO_SKIP INST_GO_FAIL
-declare -a INST_PX_OK INST_PX_SKIP INST_PX_FAIL
-declare -a REPOS_CLONED REPOS_SKIPPED REPOS_FAIL
-
# Basic network precheck
check_network() {
printf "%bRunning: Network precheck%b\n" "$bblue" "$reset"
+ local _net_ok=true
# Silence successful output; show message only on failure. Use q_to to respect --verbose.
if ! q_to 5 bash -lc 'getent hosts github.com >/dev/null 2>&1 || dig +short github.com >/dev/null 2>&1 || nslookup github.com >/dev/null 2>&1'; then
printf "%b[!] DNS resolution for github.com failed. Check your network.%b\n" "$bred" "$reset"
+ _net_ok=false
fi
if ! q_to 10 curl -I -s https://github.com >/dev/null 2>&1; then
printf "%b[!] HTTPS connectivity to github.com failed. Installer may fail.%b\n" "$yellow" "$reset"
+ _net_ok=false
+ fi
+ if [[ $_net_ok == true ]]; then
+ printf "%bNetwork OK%b\n" "$bgreen" "$reset"
fi
}
@@ -190,67 +236,101 @@ if [[ $BASH_VERSION_NUM -lt 4 ]]; then
exit 1
fi
-# Declare Go tools and their installation commands
+# Load pinned versions from manifest file
+VERSIONS_FILE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/config/tool_versions.txt"
+declare -A TOOL_VERSIONS=()
+if [[ -f "$VERSIONS_FILE" ]]; then
+ local_section=""
+ while IFS= read -r line; do
+ # Skip comments and empty lines
+ [[ -z "$line" || "$line" == \#* ]] && continue
+ # Track section headers
+ if [[ "$line" == "[repos]" ]]; then
+ local_section="repos"
+ continue
+ fi
+ if [[ "$line" == *=* ]]; then
+ local_key="${line%%=*}"
+ local_val="${line#*=}"
+ # Prefix repo keys to avoid collisions with go tool names
+ if [[ "$local_section" == "repos" ]]; then
+ TOOL_VERSIONS["repo:${local_key}"]="$local_val"
+ else
+ TOOL_VERSIONS["${local_key}"]="$local_val"
+ fi
+ fi
+ done < "$VERSIONS_FILE"
+fi
+
+# Helper: get pinned version for a tool (returns "latest" if not found)
+get_tool_version() {
+ local tool="$1"
+ local prefix="${2:-}" # optional prefix like "repo:"
+ local ver="${TOOL_VERSIONS[${prefix}${tool}]:-latest}"
+ echo "$ver"
+}
+
+# Declare Go tools: name -> module path (version resolved from config/tool_versions.txt)
declare -A gotools=(
- ["gf"]="go install -v github.com/tomnomnom/gf@latest"
- ["brutespray"]="go install -v github.com/x90skysn3k/brutespray@latest"
- ["qsreplace"]="go install -v github.com/tomnomnom/qsreplace@latest"
- ["ffuf"]="go install -v github.com/ffuf/ffuf/v2@latest"
- ["github-subdomains"]="go install -v github.com/gwen001/github-subdomains@latest"
- ["gitlab-subdomains"]="go install -v github.com/gwen001/gitlab-subdomains@latest"
- ["nuclei"]="go install -v github.com/projectdiscovery/nuclei/v3/cmd/nuclei@latest"
- ["anew"]="go install -v github.com/tomnomnom/anew@latest"
- ["notify"]="go install -v github.com/projectdiscovery/notify/cmd/notify@latest"
- ["unfurl"]="go install -v github.com/tomnomnom/[email protected]"
- ["httpx"]="go install -v github.com/projectdiscovery/httpx/cmd/httpx@latest"
- ["github-endpoints"]="go install -v github.com/gwen001/github-endpoints@latest"
- ["dnsx"]="go install -v github.com/projectdiscovery/dnsx/cmd/dnsx@latest"
- ["subjs"]="go install -v github.com/lc/subjs@latest"
- ["Gxss"]="go install -v github.com/KathanP19/Gxss@latest"
- ["katana"]="go install -v github.com/projectdiscovery/katana/cmd/katana@latest"
- ["crlfuzz"]="go install -v github.com/dwisiswant0/crlfuzz/cmd/crlfuzz@latest"
- ["dalfox"]="go install -v github.com/hahwul/dalfox/v2@latest"
- ["puredns"]="go install -v github.com/d3mondev/puredns/v2@latest"
- ["interactsh-client"]="go install -v github.com/projectdiscovery/interactsh/cmd/interactsh-client@latest"
- ["analyticsrelationships"]="go install -v github.com/Josue87/analyticsrelationships@latest"
- ["gotator"]="go install -v github.com/Josue87/gotator@latest"
- ["roboxtractor"]="go install -v github.com/Josue87/roboxtractor@latest"
- ["mapcidr"]="go install -v github.com/projectdiscovery/mapcidr/cmd/mapcidr@latest"
- ["cdncheck"]="go install -v github.com/projectdiscovery/cdncheck/cmd/cdncheck@latest"
- ["asnmap"]="go install -v github.com/projectdiscovery/asnmap/cmd/asnmap@latest"
- ["dnstake"]="go install -v github.com/pwnesia/dnstake/cmd/dnstake@latest"
- ["tlsx"]="go install -v github.com/projectdiscovery/tlsx/cmd/tlsx@latest"
- ["gitdorks_go"]="go install -v github.com/damit5/gitdorks_go@latest"
- ["smap"]="go install -v github.com/s0md3v/smap/cmd/smap@latest"
- ["dsieve"]="go install -v github.com/trickest/dsieve@master"
- ["inscope"]="go install -v github.com/tomnomnom/hacks/inscope@latest"
- ["enumerepo"]="go install -v github.com/trickest/enumerepo@latest"
- ["Web-Cache-Vulnerability-Scanner"]="go install -v github.com/Hackmanit/Web-Cache-Vulnerability-Scanner@latest"
- ["subfinder"]="go install -v github.com/projectdiscovery/subfinder/v2/cmd/subfinder@latest"
- ["hakip2host"]="go install -v github.com/hakluke/hakip2host@latest"
- ["mantra"]="go install -v github.com/Brosck/mantra@latest"
- ["crt"]="go install -v github.com/cemulus/crt@latest"
- ["s3scanner"]="go install -v github.com/sa7mon/s3scanner@latest"
- ["nmapurls"]="go install -v github.com/sdcampbell/nmapurls@latest"
- ["naabu"]="go install -v github.com/projectdiscovery/naabu/v2/cmd/naabu@latest"
- ["shortscan"]="go install -v github.com/bitquark/shortscan/cmd/shortscan@latest"
- ["hakoriginfinder"]="go install -v github.com/hakluke/hakoriginfinder@latest"
- ["sourcemapper"]="go install -v github.com/denandz/sourcemapper@latest"
- ["jsluice"]="go install -v github.com/BishopFox/jsluice/cmd/jsluice@latest"
- ["urlfinder"]="go install -v github.com/projectdiscovery/urlfinder/cmd/urlfinder@latest"
- ["cent"]="go install -v github.com/xm1k3/cent@latest"
- ["csprecon"]="go install github.com/edoardottt/csprecon/cmd/csprecon@latest"
- ["VhostFinder"]="go install -v github.com/wdahlenburg/VhostFinder@latest"
- ["misconfig-mapper"]="go install github.com/intigriti/misconfig-mapper/cmd/misconfig-mapper@latest"
- ["grpcurl"]="go install -v github.com/fullstorydev/grpcurl/cmd/grpcurl@latest"
- ["toxicache"]="go install -v github.com/xhzeem/toxicache@latest"
- ["favirecon"]="go install -v github.com/edoardottt/favirecon/cmd/favirecon@latest"
- ["second-order"]="go install -v github.com/mhmdiaa/second-order@latest"
- ["TInjA"]="go install -v github.com/Hackmanit/TInjA@latest"
- ["nerva"]="go install -v github.com/praetorian-inc/nerva/cmd/nerva@latest"
- ["brutus"]="go install -v github.com/praetorian-inc/brutus/cmd/brutus@latest"
- ["julius"]="go install -v github.com/praetorian-inc/julius/cmd/julius@latest"
- ["titus"]="go install -v github.com/praetorian-inc/titus/cmd/titus@latest"
+ ["gf"]="github.com/tomnomnom/gf"
+ ["brutespray"]="github.com/x90skysn3k/brutespray"
+ ["qsreplace"]="github.com/tomnomnom/qsreplace"
+ ["ffuf"]="github.com/ffuf/ffuf/v2"
+ ["github-subdomains"]="github.com/gwen001/github-subdomains"
+ ["gitlab-subdomains"]="github.com/gwen001/gitlab-subdomains"
+ ["nuclei"]="github.com/projectdiscovery/nuclei/v3/cmd/nuclei"
+ ["anew"]="github.com/tomnomnom/anew"
+ ["notify"]="github.com/projectdiscovery/notify/cmd/notify"
+ ["unfurl"]="github.com/tomnomnom/unfurl"
+ ["httpx"]="github.com/projectdiscovery/httpx/cmd/httpx"
+ ["github-endpoints"]="github.com/gwen001/github-endpoints"
+ ["dnsx"]="github.com/projectdiscovery/dnsx/cmd/dnsx"
+ ["subjs"]="github.com/lc/subjs"
+ ["Gxss"]="github.com/KathanP19/Gxss"
+ ["katana"]="github.com/projectdiscovery/katana/cmd/katana"
+ ["crlfuzz"]="github.com/dwisiswant0/crlfuzz/cmd/crlfuzz"
+ ["dalfox"]="github.com/hahwul/dalfox/v2"
+ ["puredns"]="github.com/d3mondev/puredns/v2"
+ ["interactsh-client"]="github.com/projectdiscovery/interactsh/cmd/interactsh-client"
+ ["analyticsrelationships"]="github.com/Josue87/analyticsrelationships"
+ ["gotator"]="github.com/Josue87/gotator"
+ ["roboxtractor"]="github.com/Josue87/roboxtractor"
+ ["mapcidr"]="github.com/projectdiscovery/mapcidr/cmd/mapcidr"
+ ["cdncheck"]="github.com/projectdiscovery/cdncheck/cmd/cdncheck"
+ ["asnmap"]="github.com/projectdiscovery/asnmap/cmd/asnmap"
+ ["dnstake"]="github.com/pwnesia/dnstake/cmd/dnstake"
+ ["tlsx"]="github.com/projectdiscovery/tlsx/cmd/tlsx"
+ ["gitdorks_go"]="github.com/damit5/gitdorks_go"
+ ["smap"]="github.com/s0md3v/smap/cmd/smap"
+ ["dsieve"]="github.com/trickest/dsieve"
+ ["inscope"]="github.com/tomnomnom/hacks/inscope"
+ ["enumerepo"]="github.com/trickest/enumerepo"
+ ["Web-Cache-Vulnerability-Scanner"]="github.com/Hackmanit/Web-Cache-Vulnerability-Scanner"
+ ["subfinder"]="github.com/projectdiscovery/subfinder/v2/cmd/subfinder"
+ ["hakip2host"]="github.com/hakluke/hakip2host"
+ ["mantra"]="github.com/Brosck/mantra"
+ ["crt"]="github.com/cemulus/crt"
+ ["s3scanner"]="github.com/sa7mon/s3scanner"
+ ["nmapurls"]="github.com/sdcampbell/nmapurls"
+ ["naabu"]="github.com/projectdiscovery/naabu/v2/cmd/naabu"
+ ["shortscan"]="github.com/bitquark/shortscan/cmd/shortscan"
+ ["hakoriginfinder"]="github.com/hakluke/hakoriginfinder"
+ ["sourcemapper"]="github.com/denandz/sourcemapper"
+ ["jsluice"]="github.com/BishopFox/jsluice/cmd/jsluice"
+ ["urlfinder"]="github.com/projectdiscovery/urlfinder/cmd/urlfinder"
+ ["cent"]="github.com/xm1k3/cent"
+ ["csprecon"]="github.com/edoardottt/csprecon/cmd/csprecon"
+ ["VhostFinder"]="github.com/wdahlenburg/VhostFinder"
+ ["misconfig-mapper"]="github.com/intigriti/misconfig-mapper/cmd/misconfig-mapper"
+ ["grpcurl"]="github.com/fullstorydev/grpcurl/cmd/grpcurl"
+ ["toxicache"]="github.com/xhzeem/toxicache"
+ ["favirecon"]="github.com/edoardottt/favirecon/cmd/favirecon"
+ ["second-order"]="github.com/mhmdiaa/second-order"
+ ["TInjA"]="github.com/Hackmanit/TInjA"
+ ["nerva"]="github.com/praetorian-inc/nerva/cmd/nerva"
+ ["brutus"]="github.com/praetorian-inc/brutus/cmd/brutus"
+ ["julius"]="github.com/praetorian-inc/julius/cmd/julius"
+ ["titus"]="github.com/praetorian-inc/titus/cmd/titus"
)
# Declare uv tool-managed Python tools and their GitHub paths
@@ -308,7 +388,7 @@ declare -A repos=(
# Function to display the banner
function banner() {
- tput clear
+ printf "\n"
cat <<EOF
██▀███ ▓█████ ▄████▄ ▒█████ ███▄ █ █████▒▄▄▄█████▓ █ █░
@@ -336,31 +416,28 @@ function install_tools() {
local go_ok=0 go_skip=0 go_fail=0
for gotool in "${!gotools[@]}"; do
((++go_step))
+ # Build go install command with pinned version from manifest
+ local _go_ver
+ _go_ver=$(get_tool_version "$gotool")
+ local _go_cmd="go install -v ${gotools[$gotool]}@${_go_ver}"
# Always run go install so already-present binaries also get updated.
- if q bash -lc "${gotools[$gotool]}"; then
- INST_GO_OK+=("$gotool")
+ if q bash -lc "$_go_cmd"; then
((++go_ok))
- progress_update "Go tools" "$go_step" "$total_go" "$go_ok" "$go_skip" "$go_fail"
- [[ $COMPACT != "true" ]] && msg_ok "[$go_step/$total_go] ${gotool} installed"
+ msg_ok "[$go_step/$total_go] ${gotool} installed"
else
# If the binary is already present, the upgrade failed but the tool still works.
# Treat this as a warning rather than a hard failure.
if command -v "$gotool" >/dev/null 2>&1; then
- INST_GO_SKIP+=("$gotool")
((++go_skip))
- progress_update "Go tools" "$go_step" "$total_go" "$go_ok" "$go_skip" "$go_fail"
msg_warn "[$go_step/$total_go] ${gotool} upgrade failed (existing binary kept)"
else
failed_tools+=("$gotool")
- INST_GO_FAIL+=("$gotool")
((++go_fail))
double_check=true
- progress_update "Go tools" "$go_step" "$total_go" "$go_ok" "$go_skip" "$go_fail"
msg_err "[$go_step/$total_go] ${gotool} failed"
fi
fi
done
- [[ $COMPACT == "true" && $IS_TTY -eq 1 ]] && printf "\n"
header "Installing uv tools (${#pipxtools[@]})"
@@ -373,8 +450,13 @@ function install_tools() {
((++pipx_step))
# Always use git+https URL for both install and upgrade to avoid PyPI lookups
- # which fail for tools not on PyPI.
+ # which fail for tools not on PyPI. Pin to version from manifest.
+ local _px_ver
+ _px_ver=$(get_tool_version "$pipxtool")
local tool_url="git+https://github.com/${pipxtools[$pipxtool]}"
+ if [[ "$_px_ver" != "latest" && "$_px_ver" != "HEAD" ]]; then
+ tool_url="${tool_url}@${_px_ver}"
+ fi
# Prepare arguments array
local tool_args=()
@@ -387,22 +469,15 @@ function install_tools() {
# Always force install/reinstall from the git URL
# This handles both initial install and upgrades correctly
if q uv tool install "${tool_args[@]}" "$tool_url" --force; then
- if [[ " ${INST_PX_OK[*]} " != *" $pipxtool "* ]]; then
- INST_PX_OK+=("$pipxtool")
- ((++px_ok))
- fi
- progress_update "uv tools" "$pipx_step" "$total_px" "$px_ok" "$px_skip" "$px_fail"
- [[ $COMPACT != "true" ]] && msg_ok "[$pipx_step/$total_px] ${pipxtool} ready"
+ ((++px_ok))
+ msg_ok "[$pipx_step/$total_px] ${pipxtool} ready"
else
failed_pipx_tools+=("$pipxtool")
- INST_PX_FAIL+=("$pipxtool")
((++px_fail))
double_check=true
- progress_update "uv tools" "$pipx_step" "$total_px" "$px_ok" "$px_skip" "$px_fail"
msg_err "[$pipx_step/$total_px] ${pipxtool} failed"
fi
done
- [[ $COMPACT == "true" && $IS_TTY -eq 1 ]] && printf "\n"
header "Installing repositories (${#repos[@]})"
@@ -431,49 +506,36 @@ function install_tools() {
if [[ $upgrade_tools == "false" ]]; then
if [[ -d "${dir}/${repo}" ]]; then
# Keep Python deps updated even when repository sync is skipped.
- if cd "${dir}/${repo}" 2>/dev/null; then
- if ! install_repo_requirements "$repo"; then
- msg_err "[$repos_step/$total_repo] $repo: pip requirements failed"
- failed_repos+=("$repo")
- REPOS_FAIL+=("$repo")
- ((++repo_fail))
- double_check=true
- fi
- cd "$dir" || true
+ if ! ( cd "${dir}/${repo}" && install_repo_requirements "$repo" ); then
+ msg_err "[$repos_step/$total_repo] $repo: pip requirements failed"
+ failed_repos+=("$repo")
+ ((++repo_fail))
+ double_check=true
fi
- REPOS_SKIPPED+=("$repo")
((++repo_skip))
- progress_update "repos" "$repos_step" "$total_repo" "$repo_ok" "$repo_skip" "$repo_fail"
- [[ $COMPACT != "true" ]] && msg_warn "[$repos_step/$total_repo] $repo already present at ${dir}/${repo}"
+ msg_warn "[$repos_step/$total_repo] $repo already present at ${dir}/${repo}"
continue
fi
fi
- # Clone the repository
- if [[ ! -d "${dir}/${repo}" || -z "$(ls -A "${dir}/${repo}")" ]]; then
+ # Clone the repository (check for .git to detect incomplete clones)
+ if [[ ! -d "${dir}/${repo}/.git" ]]; then
msg_run "[$repos_step/${#repos[@]}] $repo (clone)"
- if retry 3 3 q_to 180 git clone --filter="blob:none" "https://github.com/${repos[$repo]}" "${dir}/${repo}"; then
- exit_status=0
- else
- exit_status=$?
- fi
+ retry 3 3 q_to 180 git clone --filter="blob:none" "https://github.com/${repos[$repo]}" "${dir}/${repo}"
+ exit_status=$?
if [[ $exit_status -ne 0 ]]; then
msg_err "[$repos_step/$total_repo] $repo clone failed"
failed_repos+=("$repo")
- REPOS_FAIL+=("$repo")
((++repo_fail))
double_check=true
continue
fi
- REPOS_CLONED+=("$repo")
((++repo_ok))
- progress_update "repos" "$repos_step" "$total_repo" "$repo_ok" "$repo_skip" "$repo_fail"
fi
# Navigate to the repository directory
cd "${dir}/${repo}" || {
msg_err "[$repos_step/$total_repo] $repo: cannot enter ${dir}/${repo}"
failed_repos+=("$repo")
- REPOS_FAIL+=("$repo")
((++repo_fail))
double_check=true
continue
@@ -481,53 +543,77 @@ function install_tools() {
# Pull the latest changes
msg_run "[$repos_step/${#repos[@]}] $repo (pull)"
- if retry 3 3 q_to 60 git pull; then
- exit_status=0
- else
- exit_status=$?
- fi
+ retry 3 3 q_to 60 git pull
+ exit_status=$?
if [[ $exit_status -ne 0 ]]; then
msg_err "[$repos_step/$total_repo] $repo pull failed"
failed_repos+=("$repo")
- REPOS_FAIL+=("$repo")
((++repo_fail))
double_check=true
continue
fi
+ # Checkout pinned version from manifest if available
+ local _repo_ver
+ _repo_ver=$(get_tool_version "$repo" "repo:")
+ if [[ "$_repo_ver" != "latest" && "$_repo_ver" != "HEAD" ]]; then
+ git fetch --tags &>/dev/null || true
+ if ! git checkout "$_repo_ver" &>/dev/null; then
+ msg_warn "[$repos_step/$total_repo] $repo: could not checkout $_repo_ver, staying on HEAD"
+ fi
+ fi
+
# Install requirements inside a virtual environment
if ! install_repo_requirements "$repo"; then
msg_err "[$repos_step/$total_repo] $repo: pip requirements failed"
failed_repos+=("$repo")
- REPOS_FAIL+=("$repo")
((++repo_fail))
double_check=true
fi
- # Special handling for certain repositories
+ # Special handling for certain repositories (verify build exit codes)
case "$repo" in
"massdns")
- make &>/dev/null && strip -s bin/massdns && $SUDO cp bin/massdns /usr/local/bin/ &>/dev/null
+ if ! make &>/dev/null; then
+ msg_warn "[$repos_step/$total_repo] $repo: make failed"
+ else
+ strip -s bin/massdns 2>/dev/null || true
+ $SUDO cp bin/massdns /usr/local/bin/ &>/dev/null
+ fi
;;
"gitleaks")
- make build &>/dev/null && $SUDO cp ./gitleaks /usr/local/bin/ &>/dev/null
+ if ! make build &>/dev/null; then
+ msg_warn "[$repos_step/$total_repo] $repo: make build failed"
+ else
+ $SUDO cp ./gitleaks /usr/local/bin/ &>/dev/null
+ fi
;;
"ghleaks")
- go build -o ghleaks . &>/dev/null && chmod +x ./ghleaks
+ if ! go build -o ghleaks . &>/dev/null; then
+ msg_warn "[$repos_step/$total_repo] $repo: go build failed"
+ else
+ chmod +x ./ghleaks
+ fi
;;
"nomore403")
- go get &>/dev/null
- go build &>/dev/null
- chmod +x ./nomore403
+ go get &>/dev/null || true
+ if ! go build &>/dev/null; then
+ msg_warn "[$repos_step/$total_repo] $repo: go build failed"
+ else
+ chmod +x ./nomore403
+ fi
;;
"ffufPostprocessing")
git reset --hard origin/master &>/dev/null
git pull &>/dev/null
- go build -o ffufPostprocessing main.go &>/dev/null
- chmod +x ./ffufPostprocessing
+ if ! go build -o ffufPostprocessing main.go &>/dev/null; then
+ msg_warn "[$repos_step/$total_repo] $repo: go build failed"
+ else
+ chmod +x ./ffufPostprocessing
+ fi
;;
"trufflehog")
- go install &>/dev/null
+ go install &>/dev/null || msg_warn "[$repos_step/$total_repo] $repo: go install failed"
;;
"gato")
if [[ ! -d "venv" ]]; then
@@ -564,28 +650,33 @@ function install_tools() {
msg_ok "[$repos_step/$total_repo] $repo ready"
done
- [[ $COMPACT == "true" && $IS_TTY -eq 1 ]] && printf "\n"
- # Notify and ensure subfinder is installed twice (as per original script)
- # Guard with command checks to avoid aborting under set -e
+ # Initialize tool configs on first run
q command -v notify >/dev/null 2>&1 && q notify || true
q command -v subfinder >/dev/null 2>&1 && q subfinder || true
- q command -v subfinder >/dev/null 2>&1 && q subfinder || true
mkdir -p ${NUCLEI_TEMPLATES_PATH} &>/dev/null
#cent init -f &>/dev/null
#cent -p ${NUCLEI_TEMPLATES_PATH} &>/dev/null
- # Handle failed installations
- if [[ ${#failed_tools[@]} -ne 0 ]]; then
- printf "\n%bFailed to install the following Go tools: %s%b\n" "$red" "${failed_tools[*]}" "$reset"
- fi
-
- if [[ ${#failed_pipx_tools[@]} -ne 0 ]]; then
- printf "\n%bFailed to install the following uv tools: %s%b\n" "$red" "${failed_pipx_tools[*]}" "$reset"
- fi
-
- if [[ ${#failed_repos[@]} -ne 0 ]]; then
- printf "\n%bFailed to clone or update the following repositories:%b\n%s\n" "$red" "$reset" "${failed_repos[*]}"
+ # Installation summary
+ printf "\n%b--- Tool Installation Summary ---%b\n" "$bblue" "$reset"
+ printf " Go tools: %b%d OK%b, %d skipped, %b%d failed%b (of %d)\n" \
+ "$bgreen" "$go_ok" "$reset" "$go_skip" \
+ "$([[ $go_fail -gt 0 ]] && echo "$red" || echo "$bgreen")" "$go_fail" "$reset" "$total_go"
+ printf " uv tools: %b%d OK%b, %b%d failed%b (of %d)\n" \
+ "$bgreen" "$px_ok" "$reset" \
+ "$([[ $px_fail -gt 0 ]] && echo "$red" || echo "$bgreen")" "$px_fail" "$reset" "$total_px"
+ printf " Repos: %b%d OK%b, %d skipped, %b%d failed%b (of %d)\n" \
+ "$bgreen" "$repo_ok" "$reset" "$repo_skip" \
+ "$([[ $repo_fail -gt 0 ]] && echo "$red" || echo "$bgreen")" "$repo_fail" "$reset" "$total_repo"
+
+ local _total_fail=$(( go_fail + px_fail + repo_fail ))
+ if [[ $_total_fail -gt 0 ]]; then
+ printf "\n%bFailed items:%b\n" "$red" "$reset"
+ [[ ${#failed_tools[@]} -gt 0 ]] && printf " Go: %s\n" "${failed_tools[*]}"
+ [[ ${#failed_pipx_tools[@]} -gt 0 ]] && printf " uv: %s\n" "${failed_pipx_tools[*]}"
+ [[ ${#failed_repos[@]} -gt 0 ]] && printf " Repos: %s\n" "${failed_repos[*]}"
+ printf "\n%bRe-run install.sh to retry failed items.%b\n" "$yellow" "$reset"
fi
}
@@ -627,8 +718,9 @@ function check_updates() {
cp reconftw.cfg "$cfg_backup"
printf "%breconftw.cfg has been backed up to %s%b\n" "$yellow" "$cfg_backup" "$reset"
fi
- git reset --hard &>/dev/null
+ git stash --include-untracked &>/dev/null || true
run_to 60 git pull &>/dev/null
+ git stash pop &>/dev/null || true
printf "%bUpdated! Running the new installer version...%b\n" "$bgreen" "$reset"
# Show config diff against new default
@@ -661,9 +753,9 @@ function check_updates() {
# Function to install Golang
function install_golang_version() {
- local version="go1.25.3"
+ local version="go1.23.6"
local latest_version
- latest_version=$(curl -s https://go.dev/VERSION?m=text | head -1 || echo "go1.20.7")
+ latest_version=$(curl -s https://go.dev/VERSION?m=text | head -1 || echo "go1.23.6")
if [[ $latest_version == g* ]]; then
version="$latest_version"
fi
@@ -713,17 +805,35 @@ function install_golang_version() {
return 1
fi
+ # Verify SHA256 checksum from go.dev
+ local expected_sha256
+ expected_sha256=$(curl -sL "${archive_url}.sha256" 2>/dev/null || true)
+ if [[ -n $expected_sha256 ]]; then
+ local actual_sha256
+ if command -v sha256sum &>/dev/null; then
+ actual_sha256=$(sha256sum "$archive_path" | awk '{print $1}')
+ elif command -v shasum &>/dev/null; then
+ actual_sha256=$(shasum -a 256 "$archive_path" | awk '{print $1}')
+ fi
+ if [[ -n ${actual_sha256:-} && $actual_sha256 != "$expected_sha256" ]]; then
+ msg_err "[!] SHA256 checksum mismatch for Go archive (expected: ${expected_sha256}, got: ${actual_sha256})"
+ rm -f "$archive_path"
+ return 1
+ fi
+ else
+ msg_warn "[!] Could not fetch SHA256 checksum for Go archive; skipping verification"
+ fi
+
local tmp_unpack
tmp_unpack=$(mktemp -d 2>/dev/null || mktemp -d -t goinstall)
+ trap 'rm -rf "$tmp_unpack" "$archive_path"' RETURN
if ! tar -C "$tmp_unpack" -xzf "$archive_path" &>/dev/null; then
msg_err "[!] Failed to extract ${archive_path}"
- rm -rf "$tmp_unpack"
return 1
fi
if [[ ! -d "${tmp_unpack}/go" ]]; then
msg_err "[!] Extracted archive missing 'go' directory"
- rm -rf "$tmp_unpack"
return 1
fi
@@ -743,16 +853,13 @@ function install_golang_version() {
if [[ -n $go_backup && -d $go_backup ]]; then
$SUDO mv "$go_backup" /usr/local/go &>/dev/null || msg_warn "[!] Unable to restore previous Golang installation from backup."
fi
- rm -rf "$tmp_unpack"
return 1
fi
if [[ -n $go_backup ]]; then
$SUDO rm -rf "$go_backup" &>/dev/null
fi
- rm -rf "$tmp_unpack"
- rm -f "$archive_path" 2>/dev/null
-
+ # tmp_unpack and archive_path cleaned up by RETURN trap
$SUDO ln -sf /usr/local/go/bin/go /usr/local/bin/ 2>/dev/null
fi
@@ -829,15 +936,7 @@ function install_apt() {
# Move chromium browser dependencies (required by `nuclei -headless -id screenshot`) into a separate apt install command, and add a fallback for Ubuntu 24.04 (where `libasound2` is renamed to `libasound2t64`)
$SUDO apt-get install -y libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libxkbcommon-x11-0 libxcomposite-dev libxdamage1 libxrandr2 libgbm-dev libpangocairo-1.0-0 libasound2 &>/dev/null \
|| $SUDO apt-get install -y libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libxkbcommon-x11-0 libxcomposite-dev libxdamage1 libxrandr2 libgbm-dev libpangocairo-1.0-0 libasound2t64 &>/dev/null
- curl https://sh.rustup.rs -sSf | sh -s -- -y >/dev/null 2>&1
- source "${HOME}/.cargo/env"
- cargo install smugglex &>/dev/null
- # Install uv (replaces pip, venv, pipx)
- curl -LsSf https://astral.sh/uv/install.sh | sh &>/dev/null
- source "${HOME}/.local/bin/env" 2>/dev/null || export PATH="${HOME}/.local/bin:$PATH"
- uv tool update-shell &>/dev/null || true
- # Install shodan CLI via uv
- uv tool install shodan --force &>/dev/null || uv tool upgrade shodan &>/dev/null || true
+ install_rust_uv
}
# Function to install required packages for macOS
@@ -848,13 +947,13 @@ function install_brew() {
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
brew update &>/dev/null
- brew install --formula bash coreutils gnu-getopt gnu-sed python uv massdns jq gcc cmake ruby git curl wget zip pv bind whois exiftool nmap lynx medusa &>/dev/null
- brew install rustup &>/dev/null
- rustup-init -y &>/dev/null
- cargo install smugglex &>/dev/null
- uv tool update-shell &>/dev/null || true
- # Install shodan CLI via uv
- uv tool install shodan --force &>/dev/null || uv tool upgrade shodan &>/dev/null || true
+ brew install --formula bash coreutils gnu-getopt gnu-sed python uv massdns jq gcc cmake ruby git curl wget zip pv bind whois exiftool nmap lynx medusa &>/dev/null
+ brew install rustup &>/dev/null
+ rustup-init -y &>/dev/null
+ cargo install smugglex &>/dev/null
+ uv tool update-shell &>/dev/null || true
+ # Install shodan CLI via uv
+ uv tool install shodan --force &>/dev/null || uv tool upgrade shodan &>/dev/null || true
}
# Function to install required packages for RedHat-based systems
@@ -907,29 +1006,13 @@ function install_yum() {
fi
fi
- curl https://sh.rustup.rs -sSf | sh -s -- -y >/dev/null 2>&1
- source "${HOME}/.cargo/env"
- cargo install smugglex &>/dev/null
- # Install uv (replaces pip, venv, pipx)
- curl -LsSf https://astral.sh/uv/install.sh | sh &>/dev/null
- source "${HOME}/.local/bin/env" 2>/dev/null || export PATH="${HOME}/.local/bin:$PATH"
- uv tool update-shell &>/dev/null || true
- # Install shodan CLI via uv
- uv tool install shodan --force &>/dev/null || uv tool upgrade shodan &>/dev/null || true
+ install_rust_uv
}
# Function to install required packages for Arch-based systems
function install_pacman() {
$SUDO pacman -Sy --noconfirm python base-devel gcc cmake ruby git curl libpcap whois perl-image-exiftool wget zip pv bind openssl libffi libxml2 libxslt zlib nmap jq lynx medusa xorg-server-xvfb &>/dev/null
- curl https://sh.rustup.rs -sSf | sh -s -- -y >/dev/null 2>&1
- source "${HOME}/.cargo/env"
- cargo install smugglex &>/dev/null
- # Install uv (replaces pip, venv, pipx)
- curl -LsSf https://astral.sh/uv/install.sh | sh &>/dev/null
- source "${HOME}/.local/bin/env" 2>/dev/null || export PATH="${HOME}/.local/bin:$PATH"
- uv tool update-shell &>/dev/null || true
- # Install shodan CLI via uv
- uv tool install shodan --force &>/dev/null || uv tool upgrade shodan &>/dev/null || true
+ install_rust_uv
}
# Setup reconftw venv for python-only helpers (e.g., getjswords)
@@ -1035,20 +1118,8 @@ function initial_setup() {
if ! retry 3 3 q_to 60 git -C "${dir}/massdns" pull; then true; fi
fi
- # gf patterns
- if [[ ! -d "$HOME/.gf" ]]; then
- #printf "${yellow}Installing gf patterns...\n"
- ensure_git_dir "${dir}/gf"
- if ! retry 3 3 q_to 120 git clone https://github.com/tomnomnom/gf.git "${dir}/gf"; then true; fi
- cp -r "${dir}/gf/examples" ~/.gf 2>/dev/null || true
- ensure_git_dir "${dir}/Gf-Patterns"
- if ! retry 3 3 q_to 120 git clone https://github.com/1ndianl33t/Gf-Patterns "${dir}/Gf-Patterns"; then true; fi
- cp "${dir}/Gf-Patterns"/*.json ~/.gf/ 2>/dev/null || true
- else
- #printf "${yellow}Updating gf patterns...\n"
- ensure_git_dir "${dir}/Gf-Patterns"
- if ! retry 3 3 q_to 60 git -C "${dir}/Gf-Patterns" pull; then true; fi
- fi
+ # gf patterns are already handled by install_tools() via repos array
+ # (gf, Gf-Patterns, sus_params repos clone/pull and copy patterns)
header "Downloading required files"
@@ -1063,23 +1134,26 @@ function initial_setup() {
["axiom_config"]="https://gist.githubusercontent.com/six2dez/6e2d9f4932fd38d84610eb851014b26e/raw ${tools}/axiom_config.sh"
)
+ local dl_step=0
+ local total_dl=${#downloads[@]}
for key in "${!downloads[@]}"; do
+ ((++dl_step))
url="${downloads[$key]% *}"
destination="${downloads[$key]#* }"
# Skip download if provider-config.yaml already exists
if [[ $key == "notify_provider_config" && -f $destination ]]; then
- printf "[%bSKIPPING%b] %s as it already exists at %s.\n" "$yellow" "$reset" "$key" "$destination"
+ msg_warn "[$dl_step/$total_dl] $key skipped (already exists)"
continue
fi
# Ensure destination directory exists
mkdir -p "$(dirname "$destination")" 2>/dev/null || true
- if with_spinner "Fetching $key" retry 3 3 q_to 120 wget -q -O "$destination" "$url"; then
- :
+ if with_spinner "[$dl_step/$total_dl] Fetching $key" retry 3 3 q_to 120 wget -q -O "$destination" "$url"; then
+ msg_ok "[$dl_step/$total_dl] $key fetched"
else
- msg_err "Failed to download $key from $url"
+ msg_err "[$dl_step/$total_dl] Failed to download $key from $url"
continue
fi
done
diff --git a/lib/common.sh b/lib/common.sh
index d66441e..45cbcc0 100644
--- a/lib/common.sh
+++ b/lib/common.sh
@@ -612,37 +612,6 @@ skip_notification() {
fi
}
-# Compatibility: map pt_msg_warn to new status model
-pt_msg_warn() {
- local msg="$*"
- if [[ "$msg" == *"already processed"* ]]; then
- _print_status CACHE "${FUNCNAME[1]:-module}" "0s"
- if [[ -n "${called_fn_dir:-}" ]]; then
- : >"${called_fn_dir}/.cache_${FUNCNAME[1]:-module}" 2>/dev/null || true
- fi
- elif [[ "$msg" == *"skipped"* ]]; then
- _print_status SKIP "${FUNCNAME[1]:-module}" "0s"
- if [[ -n "${called_fn_dir:-}" ]]; then
- : >"${called_fn_dir}/.skip_${FUNCNAME[1]:-module}" 2>/dev/null || true
- fi
- else
- _print_status WARN "${FUNCNAME[1]:-module}" "0s"
- _print_msg WARN "$msg"
- fi
-}
-
-# Wrapper for skip notification when function is disabled
-# Usage: skip_if_disabled && return
-skip_if_disabled() {
- skip_notification "disabled"
-}
-
-# Wrapper for skip notification when function was already processed
-# Usage: skip_if_processed && return
-skip_if_processed() {
- skip_notification "processed"
-}
-
###############################################################################
# Command Execution Helpers
###############################################################################
@@ -776,12 +745,20 @@ run_with_heartbeat_shell() {
run_with_heartbeat "$label" /bin/bash -lc "$shell_cmd"
}
-# Execute command and capture line count result with validation
-# Usage: NUMOFLINES=$(safe_count "command | pipeline")
+# Count non-empty lines in a file safely
+# Usage: NUMOFLINES=$(safe_count "file_path")
+# NUMOFLINES=$(safe_count "command | pipeline") # legacy: still supported via eval
# Always returns a valid number (0 on failure)
safe_count() {
local result
- result=$(eval "$1" 2>/dev/null | sed '/^$/d' | wc -l | tr -d ' ') || result=0
+ if [[ -f "$1" ]]; then
+ # Safe path: count lines in file directly, no eval
+ result=$(sed '/^$/d' "$1" 2>/dev/null | wc -l | tr -d ' ') || result=0
+ else
+ # Legacy fallback for callers passing pipeline strings
+ # TODO: migrate remaining callers to pass file paths
+ result=$(eval "$1" 2>/dev/null | sed '/^$/d' | wc -l | tr -d ' ') || result=0
+ fi
[[ "$result" =~ ^[0-9]+$ ]] || result=0
echo "$result"
}
diff --git a/lib/parallel.sh b/lib/parallel.sh
index 9d209af..f758ba2 100644
--- a/lib/parallel.sh
+++ b/lib/parallel.sh
@@ -324,31 +324,7 @@ _parallel_batch_summary() {
# Run multiple commands in parallel with a job limit
# Usage: parallel_run max_jobs "cmd1" "cmd2" "cmd3" ...
# Example: parallel_run 4 "subfinder -d $domain" "amass enum -d $domain"
-parallel_run() {
- local max_jobs
- max_jobs=$(_parallel_effective_max_jobs "${1:-$PARALLEL_MAX_JOBS}")
- shift
-
- local -a pids=()
- local cmd
- local running=0
-
- for cmd in "$@"; do
- # Start command in background (use bash -c to avoid eval injection)
- bash -c "$cmd" &
- pids+=($!)
- ((running++))
-
- # If we've reached max jobs, wait for one to finish
- if ((running >= max_jobs)); then
- wait -n 2>/dev/null || true
- ((running--))
- fi
- done
-
- # Wait for all remaining jobs
- wait "${pids[@]}" 2>/dev/null
-}
+# parallel_run() removed — was unused and had injection vector (bash -c "$cmd")
# Run multiple functions in parallel with a job limit
# Usage: parallel_funcs max_jobs func1 func2 func3 ...
@@ -362,7 +338,7 @@ parallel_funcs() {
if [[ -n "${dir:-}" ]]; then
parallel_log_root="${dir}/.tmp/parallel"
else
- parallel_log_root="/tmp/reconftw_parallel.$$"
+ parallel_log_root="$(mktemp -d /tmp/reconftw_parallel.XXXXXX)"
fi
mkdir -p "$parallel_log_root" 2>/dev/null || true
@@ -800,8 +776,6 @@ parallel_brute_enum() {
# Usage: parallel_web_vulns
parallel_web_vulns() {
local funcs=(
- "cors"
- "open_redirect"
"crlf_checks"
"xss"
)
@@ -836,8 +810,6 @@ parallel_injection_vulns() {
# Usage: parallel_server_vulns
parallel_server_vulns() {
local funcs=(
- "crlf_checks"
- "xss"
"ssrf_checks"
"lfi"
)
@@ -878,68 +850,4 @@ parallel_osint() {
###############################################################################
# Orchestrate full subdomain enumeration with parallelization
-# Usage: parallel_subdomains_full
-# This replaces the sequential execution in subdomains_full()
-parallel_subdomains_full() {
- if [[ "${OUTPUT_VERBOSITY:-1}" -ge 2 ]]; then
- printf "%b[*] Starting parallelized subdomain enumeration%b\n" \
- "${bblue:-}" "${reset:-}"
- fi
-
- # Phase 1: Passive enumeration (parallel - no dependencies)
- parallel_passive_enum
-
- # Merge passive results before active phase
- if [[ -s ".tmp/passive_subs.txt" ]]; then
- cat .tmp/passive_subs.txt | anew -q subdomains/subdomains.txt
- fi
- if [[ -s ".tmp/crtsh_subs.txt" ]]; then
- cat .tmp/crtsh_subs.txt | anew -q subdomains/subdomains.txt
- fi
-
- # Phase 2: Active enumeration (parallel - resolves subdomains)
- parallel_active_enum
-
- # Phase 3: Post-active (parallel - requires resolved subdomains)
- parallel_postactive_enum
-
- # Phase 4: Brute force (sequential due to resource usage and shared files)
- if [[ ${SUBBRUTE:-false} == true ]] || [[ ${SUBPERMUTE:-false} == true ]]; then
- parallel_brute_enum
- fi
-
- # Phase 5: Scraping and recursive (sequential - depends on previous results)
- if [[ ${SUBSCRAPING:-false} == true ]]; then
- sub_scraping
- fi
- if [[ ${SUB_RECURSIVE_BRUTE:-false} == true ]]; then
- sub_recursive_brute
- fi
-
- if [[ "${OUTPUT_VERBOSITY:-1}" -ge 2 ]]; then
- printf "%b[*] Parallelized subdomain enumeration complete%b\n" \
- "${bgreen:-}" "${reset:-}"
- fi
-}
-
-# Orchestrate full vulnerability scanning with parallelization
-# Usage: parallel_vulns_full
-parallel_vulns_full() {
- if [[ "${OUTPUT_VERBOSITY:-1}" -ge 2 ]]; then
- printf "%b[*] Starting parallelized vulnerability scanning%b\n" \
- "${bblue:-}" "${reset:-}"
- fi
-
- # Run nuclei first (it's comprehensive)
- nuclei_check
-
- # Then run other checks in parallel batches
- parallel_web_vulns
- parallel_injection_vulns
- parallel_server_vulns
-
- if [[ "${OUTPUT_VERBOSITY:-1}" -ge 2 ]]; then
- printf "%b[*] Parallelized vulnerability scanning complete%b\n" \
- "${bgreen:-}" "${reset:-}"
- fi
-}
+# parallel_subdomains_full() and parallel_vulns_full() removed — defined but never called
diff --git a/lib/ui.sh b/lib/ui.sh
index f360125..e0f5a54 100644
--- a/lib/ui.sh
+++ b/lib/ui.sh
@@ -221,10 +221,6 @@ ui_header() {
printf "%s\n\n" "$(ui_truncate_text "$line" "$width")"
}
-ui_section() {
- _print_section "$1"
-}
-
ui_progress() {
local step="$1" current="$2" total="$3" pct="$4" eta="$5"
local counters
diff --git a/modules/core.sh b/modules/core.sh
index c6f863c..dd56a4a 100644
--- a/modules/core.sh
+++ b/modules/core.sh
@@ -624,26 +624,26 @@ function log_json() {
local message="$3"
shift 3
- # Build JSON object
- local json_obj
- json_obj=$(jq -n \
- --arg ts "$(date -Iseconds)" \
- --arg lvl "$level" \
- --arg fn "$function" \
- --arg msg "$message" \
- --arg domain "${domain:-N/A}" \
- '{timestamp:$ts, level:$lvl, function:$fn, message:$msg, domain:$domain}')
-
- # Add extra key-value pairs if provided
+ # Build JSON object with all key-value pairs in a single jq invocation
+ local -a jq_args=(
+ --arg ts "$(date -Iseconds)"
+ --arg lvl "$level"
+ --arg fn "$function"
+ --arg msg "$message"
+ --arg domain "${domain:-N/A}"
+ )
+ local jq_expr='{timestamp:$ts, level:$lvl, function:$fn, message:$msg, domain:$domain'
+ local idx=0
for kv in "$@"; do
if [[ "$kv" =~ ^([^=]+)=(.+)$ ]]; then
- local key="${BASH_REMATCH[1]}"
- local val="${BASH_REMATCH[2]}"
- json_obj=$(echo "$json_obj" | jq --arg k "$key" --arg v "$val" '. + {($k): $v}')
+ jq_args+=(--arg "k${idx}" "${BASH_REMATCH[1]}" --arg "v${idx}" "${BASH_REMATCH[2]}")
+ jq_expr+=", (\$k${idx}): \$v${idx}"
+ ((idx++))
fi
done
+ jq_expr+='}'
- echo "$json_obj" >>"$STRUCTURED_LOG_FILE"
+ jq -n "${jq_args[@]}" "$jq_expr" >>"$STRUCTURED_LOG_FILE"
}
# Convenience wrappers for different log levels
@@ -690,47 +690,6 @@ function progress_adjust_total() {
fi
}
-# Advance progress and display ETA
-# Usage: progress_step <step_name>
-function progress_step() {
- ((_PROGRESS_CURRENT_STEP++)) || true
- local step_name="${1:-}"
- local now elapsed remaining_steps avg_per_step eta_seconds eta_display pct
-
- now=$(date +%s)
- elapsed=$((now - _PROGRESS_START_TIME))
- pct=0
- eta_display="calculating..."
-
- if [[ $_PROGRESS_TOTAL_STEPS -gt 0 ]]; then
- pct=$(( (_PROGRESS_CURRENT_STEP * 100) / _PROGRESS_TOTAL_STEPS ))
- remaining_steps=$((_PROGRESS_TOTAL_STEPS - _PROGRESS_CURRENT_STEP))
-
- if [[ $_PROGRESS_CURRENT_STEP -gt 0 ]] && [[ $elapsed -gt 0 ]]; then
- avg_per_step=$((elapsed / _PROGRESS_CURRENT_STEP))
- eta_seconds=$((remaining_steps * avg_per_step))
- if [[ $eta_seconds -ge 3600 ]]; then
- eta_display="~$((eta_seconds / 3600))h $((eta_seconds % 3600 / 60))m"
- elif [[ $eta_seconds -ge 60 ]]; then
- eta_display="~$((eta_seconds / 60))m"
- else
- eta_display="~${eta_seconds}s"
- fi
- fi
- fi
-
- if [[ "${OUTPUT_VERBOSITY:-1}" -ge 1 ]]; then
- if declare -F ui_progress >/dev/null 2>&1; then
- ui_progress "$step_name" "$_PROGRESS_CURRENT_STEP" "$_PROGRESS_TOTAL_STEPS" "$pct" "$eta_display"
- else
- printf "%b[%s] Progress: [%d/%d] %d%% | ETA: %s | %s%b\n" \
- "$bblue" "$(date +'%H:%M:%S')" \
- "$_PROGRESS_CURRENT_STEP" "$_PROGRESS_TOTAL_STEPS" \
- "$pct" "$eta_display" "$step_name" "$reset"
- fi
- fi
-}
-
# Module-level progress tracker
# Usage: progress_module "OSINT"
# Shows: [3/7] 43% | OSINT complete | OK:8 WARN:0 FAIL:0 SKIP:2
@@ -1226,11 +1185,11 @@ function incremental_should_skip() {
###############################################################################################################
-function zipSnedOutputFolder {
+function zipSendOutputFolder {
zip_name1=$(date +"%Y_%m_%d-%H.%M.%S")
zip_name="${zip_name1}_${domain}.zip" 2>>"$LOGFILE" >/dev/null
(cd "$dir" && zip -r "$zip_name" .) 2>>"$LOGFILE" >/dev/null
- echo "Sending zip file "${dir}/${zip_name}""
+ _print_msg INFO "Sending zip file ${dir}/${zip_name}"
if [[ -s "${dir}/$zip_name" ]]; then
sendToNotify "$dir/$zip_name"
rm -f "${dir}/$zip_name"
@@ -1337,22 +1296,30 @@ function notification() {
}
function transfer {
+ # WARNING: This uploads recon results to an external service (bashupload.com)
+ # Requires explicit opt-in via ALLOW_TRANSFER=true in config
+ if [[ "${ALLOW_TRANSFER:-false}" != "true" ]]; then
+ notification "transfer() disabled by default (uploads to external service). Set ALLOW_TRANSFER=true to enable." warn
+ return 1
+ fi
+
if [[ $# -eq 0 ]]; then
echo "No arguments specified.\nUsage:\n transfer <file|directory>\n ... | transfer <file_name>" >&2
return 1
fi
if tty -s; then
- file="$1"
+ local file="$1"
+ local file_name
file_name=$(basename "$file")
if [[ ! -e $file ]]; then
echo "$file: No such file or directory" >&2
return 1
fi
- run_command tar -czvf /tmp/$file_name $file >/dev/null 2>&1 && run_command curl -s https://bashupload.com/$file.tgz --data-binary @/tmp/$file_name | grep wget
+ run_command tar -czvf "/tmp/$file_name" "$file" >/dev/null 2>&1 && run_command curl -s "https://bashupload.com/${file_name}.tgz" --data-binary "@/tmp/$file_name" | grep wget
else
- file_name=$1
- run_command tar -czvf /tmp/$file_name $file >/dev/null 2>&1 && run_command curl -s https://bashupload.com/$file.tgz --data-binary @/tmp/$file_name | grep wget
+ local file_name="$1"
+ run_command tar -czvf "/tmp/$file_name" "$file" >/dev/null 2>&1 && run_command curl -s "https://bashupload.com/${file_name}.tgz" --data-binary "@/tmp/$file_name" | grep wget
fi
}
@@ -1364,7 +1331,7 @@ function sendToNotify {
NOTIFY_CONFIG=~/.config/notify/provider-config.yaml
fi
if [[ -n "$(find "${1}" -prune -size +8000000c)" ]]; then
- printf '%s is larger than 8MB, sending over external service\n' "${1}"
+ _print_msg WARN "${1} is larger than 8MB, sending over external service"
transfer "${1}" | notify -silent
return 0
fi
@@ -1387,8 +1354,13 @@ function sendToNotify {
}
function start_func() {
+ local current_date
current_date=$(date +'%Y-%m-%d %H:%M:%S')
echo "[$current_date] Start function: ${1} " >>"${LOGFILE}"
+ # Use per-function start time to avoid race conditions in parallel mode
+ local _fn_name="${1}"
+ printf -v "_start_time_${_fn_name//[^a-zA-Z0-9_]/_}" '%s' "$(date +%s)"
+ # Keep global $start for backward compat (serial mode)
start=$(date +%s)
log_json "INFO" "${1}" "Function started" "description=${2}"
if declare -F ui_log_jsonl >/dev/null 2>&1; then
@@ -1428,10 +1400,15 @@ function end_func() {
fi
touch "$called_fn_dir/.${fn}"
+ local end
end=$(date +%s)
- getElapsedTime "$start" "$end"
- record_func_timing "${fn}" "$((end - start))"
- local duration=$((end - start))
+ # Try per-function start time first (parallel-safe), fall back to global $start
+ local _start_var="_start_time_${fn//[^a-zA-Z0-9_]/_}"
+ local _fn_start="${!_start_var:-$start}"
+ local runtime=""
+ getElapsedTime "$_fn_start" "$end"
+ record_func_timing "${fn}" "$((end - _fn_start))"
+ local duration=$((end - _fn_start))
local end_date
end_date=$(date +'%Y-%m-%d %H:%M:%S')
echo "[$end_date] End function: ${fn} " >>"${LOGFILE}"
@@ -1618,16 +1595,21 @@ function process_in_chunks() {
local lines
lines=$(wc -l <"$infile" 2>/dev/null || echo 0)
if [[ $lines -le $chunksize ]]; then
- bash -lc "$*"
+ # Use the original file path, properly quoted via array
+ local cmd_str="${*//_chunk_/$infile}"
+ bash -lc "$cmd_str"
return $?
fi
mkdir -p .tmp/chunks
+ # Clean up old chunks to avoid stale data
+ rm -f .tmp/chunks/part_*
split -l "$chunksize" -d "$infile" .tmp/chunks/part_
for part in .tmp/chunks/part_*; do
- local cmd
- cmd="${*//_chunk_/\"$part\"}"
- bash -lc "$cmd"
+ # Replace placeholder with the chunk path (already safe — generated by split)
+ local cmd_str="${*//_chunk_/$part}"
+ bash -lc "$cmd_str"
done
+ rm -f .tmp/chunks/part_*
}
###############################################################################################################
@@ -1651,7 +1633,8 @@ function print_timing_summary() {
return 0
fi
- printf "\n%b#######################################################################%b\n" "$bgreen" "$reset"
+ printf "\n"
+ _print_rule
printf "%b[%s] Performance Timing Summary%b\n\n" "$bblue" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"
local total=0
@@ -1682,7 +1665,8 @@ function print_timing_summary() {
local total_mins=$((total / 60))
local total_secs=$((total % 60))
printf "\n %-35s %3dm %02ds\n" "TOTAL" "$total_mins" "$total_secs"
- printf "%b#######################################################################%b\n\n" "$bgreen" "$reset"
+ _print_rule
+ printf "\n"
}
# Write machine-readable performance summary for dashboards/automation.
@@ -1931,8 +1915,13 @@ function generate_consolidated_report() {
fi
# HTML renderer with inlined JSON payload.
+ # Sanitize JSON for safe embedding in <script> tags:
+ # - Escape </script> to prevent tag breakout (XSS)
+ # - Escape <!-- to prevent HTML comment injection
local report_payload
report_payload=$(jq -c '.' "$report_json" 2>/dev/null || echo '{}')
+ report_payload="${report_payload//</\u003c}"
+ report_payload="${report_payload//>/\u003e}"
cat >"$report_html" <<EOF
<!doctype html>
<html lang="en">
diff --git a/modules/modes.sh b/modules/modes.sh
index d32f5ce..0e60921 100644
--- a/modules/modes.sh
+++ b/modules/modes.sh
@@ -281,7 +281,7 @@ function end() {
fi
#Zip the output folder and send it via tg/discord/slack
if [[ $SENDZIPNOTIFY == true ]]; then
- zipSnedOutputFolder
+ zipSendOutputFolder
fi
# Screenshot diffs (hashing)
@@ -418,12 +418,20 @@ function passive() {
ip_info
emails
google_dorks
- #github_dorks
+ github_dorks
github_repos
github_leaks
metadata
apileaks
third_party_misconfigs
+
+ # Save original values before overriding for passive-only mode
+ local _saved_SUBNOERROR="${SUBNOERROR:-}" _saved_SUBANALYTICS="${SUBANALYTICS:-}"
+ local _saved_SUBBRUTE="${SUBBRUTE:-}" _saved_SUBSCRAPING="${SUBSCRAPING:-}"
+ local _saved_SUBPERMUTE="${SUBPERMUTE:-}" _saved_SUBREGEXPERMUTE="${SUBREGEXPERMUTE:-}"
+ local _saved_SUB_RECURSIVE_BRUTE="${SUB_RECURSIVE_BRUTE:-}"
+ local _saved_PORTSCAN_ACTIVE="${PORTSCAN_ACTIVE:-}"
+
# shellcheck disable=SC2034 # These globals are consumed by downstream module functions
SUBNOERROR=false
# shellcheck disable=SC2034
@@ -460,6 +468,16 @@ function passive() {
axiom_shutdown
fi
+ # Restore original values so subsequent modes (e.g. monitor) are not affected
+ SUBNOERROR="${_saved_SUBNOERROR}"
+ SUBANALYTICS="${_saved_SUBANALYTICS}"
+ SUBBRUTE="${_saved_SUBBRUTE}"
+ SUBSCRAPING="${_saved_SUBSCRAPING}"
+ SUBPERMUTE="${_saved_SUBPERMUTE}"
+ SUBREGEXPERMUTE="${_saved_SUBREGEXPERMUTE}"
+ SUB_RECURSIVE_BRUTE="${_saved_SUB_RECURSIVE_BRUTE}"
+ PORTSCAN_ACTIVE="${_saved_PORTSCAN_ACTIVE}"
+
end
}
@@ -471,19 +489,36 @@ function all() {
}
function osint() {
- domain_info
- ip_info
- emails
- google_dorks
- #github_dorks
- github_repos
- github_leaks
- metadata
- apileaks
- third_party_misconfigs
- zonetransfer
- mail_hygiene
- cloud_enum_scan
+ if [[ "${PARALLEL_MODE:-false}" != "false" ]]; then
+ # Group 1: Independent lookups (no shared state)
+ parallel_funcs "${PAR_OSINT_GROUP1_SIZE:-4}" \
+ domain_info ip_info emails google_dorks github_dorks
+ # Group 2: GitHub/API analysis
+ parallel_funcs "${PAR_OSINT_GROUP2_SIZE:-3}" \
+ github_repos github_leaks github_actions_audit
+ # Group 3: Metadata, API leaks, third-party checks
+ parallel_funcs "${PAR_OSINT_GROUP3_SIZE:-4}" \
+ metadata apileaks third_party_misconfigs zonetransfer
+ # Group 4: Mail/DNS/Cloud
+ parallel_funcs "${PAR_OSINT_GROUP4_SIZE:-3}" \
+ mail_hygiene spoof cloud_enum_scan
+ else
+ domain_info
+ ip_info
+ emails
+ google_dorks
+ github_dorks
+ github_repos
+ github_leaks
+ github_actions_audit
+ metadata
+ apileaks
+ third_party_misconfigs
+ zonetransfer
+ mail_hygiene
+ spoof
+ cloud_enum_scan
+ fi
}
run_module_with_axiom_failover() {
@@ -1059,7 +1094,14 @@ function multi_custom() {
print_errorf "Refusing to remove '%s' -- safety check failed" "$dir"
return 1
fi
- rm -rf -- "$dir"
+ if [[ -d "$dir" ]]; then
+ if [[ "${FORCE_RESCAN:-false}" == "true" ]]; then
+ rm -rf -- "$dir"
+ else
+ # Preserve existing results; use --force to wipe
+ notification "Directory $dir exists; use --force to overwrite" warn
+ fi
+ fi
mkdir -p "$dir" || {
print_errorf "Failed to create directory '%s' in %s @ line %s" "$dir" "${FUNCNAME[0]}" "${LINENO}"
exit 1
diff --git a/modules/osint.sh b/modules/osint.sh
index 45751d2..68f8483 100644
--- a/modules/osint.sh
+++ b/modules/osint.sh
@@ -79,9 +79,14 @@ function github_repos() {
GH_TOKEN=$(head -n 1 "$GITHUB_TOKENS")
echo "$domain" | unfurl format %r >.tmp/company_name.txt
- if ! run_command enumerepo -token-string "$GH_TOKEN" -usernames .tmp/company_name.txt -o .tmp/company_repos.txt 2>>"$LOGFILE" >/dev/null; then
+ # Use temp file for token to avoid exposing it in process list
+ local _token_file
+ _token_file=$(mktemp)
+ printf '%s' "$GH_TOKEN" > "$_token_file"
+ if ! run_command enumerepo -token-file "$_token_file" -usernames .tmp/company_name.txt -o .tmp/company_repos.txt 2>>"$LOGFILE" >/dev/null; then
_print_error "enumerepo command failed"
fi
+ rm -f "$_token_file"
if [[ -s ".tmp/company_repos.txt" ]]; then
if ! jq -r '.[].repos[]|.url' <.tmp/company_repos.txt >.tmp/company_repos_url.txt 2>>"$LOGFILE"; then
@@ -313,17 +318,12 @@ function metadata() {
start_func "${FUNCNAME[0]}" "Scanning metadata in public files"
ensure_dirs ".tmp/metagoofil_${domain}"
- pushd "${tools}/metagoofil" >/dev/null || {
- _print_error "Failed to change directory to ${tools}/metagoofil in ${FUNCNAME[0]} at line ${LINENO}"
- return 1
- }
- if ! run_command "${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; then
- log_note "metadata: metagoofil failed; skipping metadata extraction" "${FUNCNAME[0]}" "${LINENO}"
- fi
- popd >/dev/null || {
- _print_error "Failed to return to the previous directory in ${FUNCNAME[0]} at line ${LINENO}"
- return 1
- }
+ (
+ cd "${tools}/metagoofil" || exit 1
+ if ! run_command "${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; then
+ log_note "metadata: metagoofil failed; skipping metadata extraction" "${FUNCNAME[0]}" "${LINENO}"
+ fi
+ )
# Check if exiftool is installed before running
if command -v exiftool &>/dev/null; then
@@ -374,31 +374,22 @@ function apileaks() {
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
- _print_error "Failed to change directory to ${tools}/SwaggerSpy in ${FUNCNAME[0]} at line ${LINENO}"
- return 1
- fi
-
- # Run swaggerspy.py and handle errors
- local swag_cmd=("${tools}/SwaggerSpy/venv/bin/python3" "swaggerspy.py" "$domain")
- local swag_timeout="${SWAGGERSPY_TIMEOUT:-5m}"
- [[ -n ${TIMEOUT_CMD:-} ]] && swag_cmd=("$TIMEOUT_CMD" "$swag_timeout" "${swag_cmd[@]}")
- local swagger_rc=0
- {
- run_command "${swag_cmd[@]}" 2>>"$LOGFILE" | grep -i "[*]\|URL" >"${dir}/osint/swagger_leaks.txt"
- swagger_rc=${PIPESTATUS[0]:-0} # ignore grep exit code (no matches is fine)
- } || true
- if ((swagger_rc != 0)); then
- _print_msg WARN "SwaggerSpy failed (exit ${swagger_rc}), continuing without swagger results."
- log_note "SwaggerSpy failed (exit ${swagger_rc}), continuing without swagger results." "${FUNCNAME[0]}" "${LINENO}"
- fi
-
- # Return to the previous directory
- if ! popd >/dev/null; then
- _print_error "Failed to return to the previous directory in ${FUNCNAME[0]} at line ${LINENO}"
- return 1
- fi
+ # Run SwaggerSpy in a subshell to avoid CWD pollution
+ (
+ cd "${tools}/SwaggerSpy" || exit 1
+ local swag_cmd=("${tools}/SwaggerSpy/venv/bin/python3" "swaggerspy.py" "$domain")
+ local swag_timeout="${SWAGGERSPY_TIMEOUT:-5m}"
+ [[ -n ${TIMEOUT_CMD:-} ]] && swag_cmd=("$TIMEOUT_CMD" "$swag_timeout" "${swag_cmd[@]}")
+ local swagger_rc=0
+ {
+ run_command "${swag_cmd[@]}" 2>>"$LOGFILE" | grep -i "[*]\|URL" >"${dir}/osint/swagger_leaks.txt"
+ swagger_rc=${PIPESTATUS[0]:-0}
+ } || true
+ if ((swagger_rc != 0)); then
+ _print_msg WARN "SwaggerSpy failed (exit ${swagger_rc}), continuing without swagger results."
+ log_note "SwaggerSpy failed (exit ${swagger_rc}), continuing without swagger results." "${FUNCNAME[0]}" "${LINENO}"
+ fi
+ )
# Optional postleaksNg integration (Postman public library leaks)
if [[ ${API_LEAKS_POSTLEAKS:-true} == true ]]; then
@@ -476,20 +467,11 @@ function emails() {
grep "@" .tmp/EmailHarvester.txt | anew -q osint/emails.txt || true
fi
- # Change directory to LeakSearch
- if ! pushd "${tools}/LeakSearch" >/dev/null; then
- _print_error "Failed to change directory to ${tools}/LeakSearch in ${FUNCNAME[0]} at line ${LINENO}"
- return 1
- fi
-
- # Run LeakSearch.py and handle errors
- run_command "${tools}/LeakSearch/venv/bin/python3" LeakSearch.py -k "$domain" -o "${dir}/.tmp/passwords.txt" 1>>"$LOGFILE"
-
- # Return to the previous directory
- if ! popd >/dev/null; then
- _print_error "Failed to return to the previous directory in ${FUNCNAME[0]} at line ${LINENO}"
- return 1
- fi
+ # Run LeakSearch in a subshell to avoid CWD pollution
+ (
+ cd "${tools}/LeakSearch" || exit 1
+ run_command "${tools}/LeakSearch/venv/bin/python3" LeakSearch.py -k "$domain" -o "${dir}/.tmp/passwords.txt" 1>>"$LOGFILE"
+ )
# Process passwords.txt
if [[ -s "${dir}/.tmp/passwords.txt" ]]; then
@@ -568,25 +550,15 @@ function third_party_misconfigs() {
# Extract company name from domain
company_name=$(unfurl format %r <<<"$domain")
- # Change directory to Spoofy tool
- if ! pushd "${tools}/misconfig-mapper" >/dev/null; then
- print_warnf "Failed to change directory to %s in %s at line %s." \
- "${tools}/misconfig-mapper" "${FUNCNAME[0]}" "$LINENO"
- return 1
- fi
-
- run_command misconfig-mapper -update-templates 1>>"$LOGFILE"
- run_command misconfig-mapper -target "$domain" -as-domain true -permutations false -skip-ssl \
- -service "*" -verbose 0 | anew -q "${dir}/osint/3rdparts_misconfigurations.txt"
- run_command misconfig-mapper -target "$company_name" -skip-ssl -verbose 0 -service "*" \
- | anew -q "${dir}/osint/3rdparts_misconfigurations.txt"
-
- # Return to the previous directory
- if ! popd >/dev/null; then
- print_warnf "Failed to return to previous directory in %s at line %s." \
- "${FUNCNAME[0]}" "$LINENO"
- return 1
- fi
+ # Run misconfig-mapper in a subshell to avoid CWD pollution
+ (
+ cd "${tools}/misconfig-mapper" || exit 1
+ run_command misconfig-mapper -update-templates 1>>"$LOGFILE"
+ run_command misconfig-mapper -target "$domain" -as-domain true -permutations false -skip-ssl \
+ -service "*" -verbose 0 | anew -q "${dir}/osint/3rdparts_misconfigurations.txt"
+ run_command misconfig-mapper -target "$company_name" -skip-ssl -verbose 0 -service "*" \
+ | anew -q "${dir}/osint/3rdparts_misconfigurations.txt"
+ )
end_func "Results are saved in $domain/osint/3rdparts_misconfigurations.txt" "${FUNCNAME[0]}"
@@ -611,22 +583,11 @@ function spoof() {
start_func "${FUNCNAME[0]}" "Searching for spoofable domains"
- # Change directory to Spoofy tool
- if ! pushd "${tools}/Spoofy" >/dev/null; then
- print_warnf "Failed to change directory to %s in %s at line %s." \
- "${tools}/Spoofy" "${FUNCNAME[0]}" "$LINENO"
- return 1
- fi
-
- # Run spoofy.py and handle errors
- run_command "${tools}/Spoofy/venv/bin/python3" spoofy.py -d "$domain" >"${dir}/osint/spoof.txt"
-
- # Return to the previous directory
- if ! popd >/dev/null; then
- print_warnf "Failed to return to previous directory in %s at line %s." \
- "${FUNCNAME[0]}" "$LINENO"
- return 1
- fi
+ # Run Spoofy in a subshell to avoid CWD pollution
+ (
+ cd "${tools}/Spoofy" || exit 1
+ run_command "${tools}/Spoofy/venv/bin/python3" spoofy.py -d "$domain" >"${dir}/osint/spoof.txt"
+ )
end_func "Results are saved in $domain/osint/spoof.txt" "${FUNCNAME[0]}"
diff --git a/modules/subdomains.sh b/modules/subdomains.sh
index b72008b..c62bc4b 100644
--- a/modules/subdomains.sh
+++ b/modules/subdomains.sh
@@ -107,22 +107,11 @@ deep_wildcard_filter() {
rm -f ".tmp/dwf_new_wildcards.txt"
# Filter out subdomains under wildcard parents
- : > ".tmp/dwf_filtered.txt"
- while IFS= read -r subdomain; do
- local is_under_wildcard=false
- while IFS= read -r wildcard; do
- if [[ "$subdomain" == *".$wildcard" ]] || [[ "$subdomain" == "$wildcard" ]]; then
- is_under_wildcard=true
- break
- fi
- done < ".tmp/dwf_wildcards.txt"
-
- if [[ "$is_under_wildcard" == false ]]; then
- echo "$subdomain" >> ".tmp/dwf_filtered.txt"
- fi
- done < ".tmp/dwf_working.txt"
-
+ # Build grep pattern file: each wildcard becomes a suffix pattern
+ awk '{print "\\." $0 "$"; print "^" $0 "$"}' ".tmp/dwf_wildcards.txt" > ".tmp/dwf_grep_patterns.txt"
+ grep -vEf ".tmp/dwf_grep_patterns.txt" ".tmp/dwf_working.txt" > ".tmp/dwf_filtered.txt" || true
mv ".tmp/dwf_filtered.txt" ".tmp/dwf_working.txt"
+ rm -f ".tmp/dwf_grep_patterns.txt"
fi
fi
fi
@@ -210,7 +199,7 @@ _subdomains_init() {
if [[ -s "$sensitive_file" ]]; then
if _is_sensitive_domain "$domain" "$sensitive_file"; then
_print_status FAIL "Sensitive domain" "0s"
- printf " Domain '%s' matches sensitive pattern. Set EXCLUDE_SENSITIVE=false to override.\n" "$domain"
+ _print_msg WARN "Domain '${domain}' matches sensitive pattern. Set EXCLUDE_SENSITIVE=false to override."
return 1
fi
fi
@@ -589,8 +578,7 @@ function sub_crt() {
log_note "sub_crt: crt source returned no valid JSON; continuing with fallback sources" "${FUNCNAME[0]}" "${LINENO}"
fi
[[ "${OUTPUT_VERBOSITY:-1}" -ge 2 ]] && \
- 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"
+ _print_msg INFO "Time fencing enabled: filtering crt.sh results to last ${DNS_TIME_FENCE_DAYS} days (since ${cutoff_date})"
else
# Fallback if date calculation fails
if ! run_command crt -s -json -l "${CTR_LIMIT}" "$domain" 2>>"$LOGFILE" \
@@ -699,12 +687,13 @@ function sub_active() {
local matched_count=0
if [[ -s ".tmp/subdomains_tmp.txt" ]]; then
candidate_count=$(wc -l <.tmp/subdomains_tmp.txt 2>/dev/null | tr -d ' ')
- matched_count=$(grep -E "$DOMAIN_MATCH_REGEX" .tmp/subdomains_tmp.txt 2>>"$LOGFILE" \
- | grep -E '^([a-zA-Z0-9\.\-]+\.)+[a-zA-Z]{1,}$' \
- | sed '/^$/d' | wc -l | tr -d ' ' || true)
- NUMOFLINES=$(grep -E "$DOMAIN_MATCH_REGEX" .tmp/subdomains_tmp.txt 2>>"$LOGFILE" \
+ # Run the filtering pipeline ONCE, save matched results to temp file
+ grep -E "$DOMAIN_MATCH_REGEX" .tmp/subdomains_tmp.txt 2>>"$LOGFILE" \
| grep -E '^([a-zA-Z0-9\.\-]+\.)+[a-zA-Z]{1,}$' \
- | anew subdomains/subdomains.txt | sed '/^$/d' | wc -l | tr -d ' ' || true)
+ | sed '/^$/d' > .tmp/sub_active_matched.txt || true
+ matched_count=$(wc -l <.tmp/sub_active_matched.txt 2>/dev/null | tr -d ' ')
+ NUMOFLINES=$(anew subdomains/subdomains.txt <.tmp/sub_active_matched.txt | sed '/^$/d' | wc -l | tr -d ' ' || true)
+ rm -f .tmp/sub_active_matched.txt
[[ "$matched_count" =~ ^[0-9]+$ ]] || matched_count=0
[[ "$NUMOFLINES" =~ ^[0-9]+$ ]] || NUMOFLINES=0
else
@@ -755,9 +744,10 @@ function sub_tls() {
fi
if [[ -s ".tmp/subdomains_tlsx.txt" ]]; then
+ # tlsx outputs plain domain names (not URLs), so match domains directly
grep -E "$DOMAIN_MATCH_REGEX" .tmp/subdomains_tlsx.txt \
- | grep -aEo 'https?://[^ ]+' \
| sed "s/|__ //" \
+ | grep -aEo '[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}' \
| sed '/^$/d' \
| anew -q .tmp/subdomains_tlsx_clean.txt || true
fi
@@ -1420,26 +1410,17 @@ function sub_regex_permut() {
if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $SUBREGEXPERMUTE == true ]]; then
start_subfunc "${FUNCNAME[0]}" "Running: Permutations by regex analysis"
- # Change to the regulator directory
- if ! pushd "${tools}/regulator" >/dev/null; then
- print_warnf "Failed to change directory to %s." "${tools}/regulator"
- return 1
- fi
-
# If in multi mode and subdomains.txt doesn't exist, create it
if [[ -n $multi ]] && [[ ! -f "$dir/subdomains/subdomains.txt" ]]; then
printf "%b\n" "$domain" >"$dir/subdomains/subdomains.txt"
fi
- # Run the main.py script
- run_command "${tools}/regulator/venv/bin/python3" main.py -t "$domain" -f "${dir}/subdomains/subdomains.txt" -o "${dir}/.tmp/${domain}.brute" \
- 2>>"$LOGFILE" >/dev/null
-
- # Return to the previous directory
- if ! popd >/dev/null; then
- print_warnf "Failed to return to previous directory."
- return 1
- fi
+ # Run regulator in a subshell to avoid CWD pollution
+ (
+ cd "${tools}/regulator" || exit 1
+ run_command "${tools}/regulator/venv/bin/python3" main.py -t "$domain" -f "${dir}/subdomains/subdomains.txt" -o "${dir}/.tmp/${domain}.brute" \
+ 2>>"$LOGFILE" >/dev/null
+ )
# Resolve the generated domains
if [[ $AXIOM != true ]]; then
@@ -2180,9 +2161,8 @@ function geo_info() {
print_warnf "Failed to create ipinfo.txt."
fi
- while IFS= read -r ip; do
- run_command curl -s "https://ipinfo.io/widget/demo/$ip" >>"${dir}/hosts/ipinfo.txt"
- done <"$ips_file"
+ # Parallel geo lookups (limit to first 500 IPs and 10 concurrent requests)
+ head -n 500 "$ips_file" | xargs -P 10 -I {} curl -s "https://ipinfo.io/widget/demo/{}" >> "${dir}/hosts/ipinfo.txt" 2>/dev/null || true
fi
end_func "Results are saved in hosts/ipinfo.txt" "${FUNCNAME[0]}"
diff --git a/modules/utils.sh b/modules/utils.sh
index dbbd1f7..8d59ad9 100644
--- a/modules/utils.sh
+++ b/modules/utils.sh
@@ -17,11 +17,11 @@ function deleteOutScoped() {
if [[ -s "$1" ]]; then
while IFS= read -r outscoped; do
[[ -z "$outscoped" ]] && continue
- # Escape regex metacharacters to prevent injection
+ # Escape regex metacharacters including / to prevent sed delimiter injection
local escaped
- escaped=$(printf '%s' "$outscoped" | sed 's/[.[\*^$()+?{|\\]/\\&/g')
+ escaped=$(printf '%s' "$outscoped" | sed 's/[.[\*^$()+?{|/\\]/\\&/g')
if grep -q "^[*]" <<<"$outscoped"; then
- escaped=$(printf '%s' "${outscoped:1}" | sed 's/[.[\*^$()+?{|\\]/\\&/g')
+ escaped=$(printf '%s' "${outscoped:1}" | sed 's/[.[\*^$()+?{|/\\]/\\&/g')
sed_i "/${escaped}$/d" "$2"
else
sed_i "/${escaped}/d" "$2"
@@ -82,20 +82,7 @@ function rotate_logs() {
fi
}
-function sanitize_interlace_input() {
- # Remove lines containing shell metacharacters that could be exploited
- # via interlace template substitution (_target_, _output_, _cleantarget_)
- local infile="$1"
- local outfile="${2:-$1}"
- if [[ "$infile" == "$outfile" ]]; then
- local tmpfile
- tmpfile=$(mktemp)
- grep -v '[;|&$`\\(){}]' "$infile" >"$tmpfile" 2>/dev/null || true
- mv "$tmpfile" "$outfile"
- else
- grep -v '[;|&$`\\(){}]' "$infile" >"$outfile" 2>/dev/null || true
- fi
-}
+# sanitize_interlace_input() — canonical definition in lib/validation.sh
function validate_config() {
local warnings=0
@@ -241,16 +228,17 @@ function apply_performance_profile() {
}
function getElapsedTime {
+ # Sets $runtime (for backward compat) and also prints to stdout
runtime=""
- local T=$2-$1
+ local T=$(($2 - $1))
local D=$((T / 60 / 60 / 24))
local H=$((T / 60 / 60 % 24))
local M=$((T / 60 % 60))
local S=$((T % 60))
- ((D > 0)) && runtime="$runtime$D days, "
- ((H > 0)) && runtime="$runtime$H hours, "
- ((M > 0)) && runtime="$runtime$M minutes, "
- runtime="$runtime$S seconds."
+ ((D > 0)) && runtime="${runtime}${D} days, "
+ ((H > 0)) && runtime="${runtime}${H} hours, "
+ ((M > 0)) && runtime="${runtime}${M} minutes, "
+ runtime="${runtime}${S} seconds."
}
# Retry with exponential backoff
@@ -786,7 +774,7 @@ function should_run_deep2() {
###############################################################################################################
CACHE_DIR="${SCRIPTPATH}/.cache"
-CACHE_MAX_AGE_DAYS=30 # 1 month
+CACHE_MAX_AGE_DAYS="${CACHE_MAX_AGE_DAYS:-30}" # 1 month default, user-configurable
# Initialize cache directory
function cache_init() {
diff --git a/modules/vulns.sh b/modules/vulns.sh
index 71beb74..da590c5 100644
--- a/modules/vulns.sh
+++ b/modules/vulns.sh
@@ -104,6 +104,8 @@ function ssrf_checks() {
if [[ -z $COLLAB_SERVER ]]; then
interactsh-client &>.tmp/ssrf_callback.txt &
INTERACTSH_PID=$!
+ # Ensure interactsh is killed on function exit (prevents orphan processes)
+ trap 'kill "$INTERACTSH_PID" 2>/dev/null; trap - RETURN' RETURN
sleep 2
# Extract FFUFHASH from interactsh_callback.txt
@@ -171,7 +173,6 @@ function ssrf_checks() {
end_func "Results are saved in vulns/ssrf_* (including alternate protocols)" "${FUNCNAME[0]}"
else
end_func "Skipping SSRF: Too many URLs to test, try with --deep flag." "${FUNCNAME[0]}"
- printf "${bgreen}#######################################################################${reset}\n"
fi
# Terminate interactsh-client if it was started
@@ -422,7 +423,11 @@ function sqli() {
# Check if GHAURI is enabled and run Ghauri
if [[ $GHAURI == true ]]; then
_print_msg INFO "Running: Ghauri for SQLi Checks"
- run_command interlace -tL ".tmp/tmp_sqli.txt" -threads "$INTERLACE_THREADS" -c "ghauri -u _target_ --batch -H \"${HEADER}\" --force-ssl >> vulns/ghauri_log.txt" 2>>"$LOGFILE" >/dev/null
+ mkdir -p .tmp/ghauri_parts
+ run_command interlace -tL ".tmp/tmp_sqli.txt" -threads "$INTERLACE_THREADS" -c "ghauri -u _target_ --batch -H \"${HEADER}\" --force-ssl >> .tmp/ghauri_parts/_cleantarget_.txt" 2>>"$LOGFILE" >/dev/null
+ # Merge per-target outputs to avoid concurrent write corruption
+ cat .tmp/ghauri_parts/*.txt 2>/dev/null | anew -q vulns/ghauri_log.txt || true
+ rm -rf .tmp/ghauri_parts
fi
end_func "Results are saved in vulns/sqlmap folder" "${FUNCNAME[0]}"
@@ -460,9 +465,13 @@ function test_ssl() {
echo "$domain" >"$dir/hosts/ips.txt"
fi
- # Run testssl.sh
+ # Run testssl.sh — prefer non-CDN IPs to avoid testing CDN TLS configs
+ local testssl_input="$dir/hosts/ips.txt"
+ if [[ -s "$dir/.tmp/ips_nocdn.txt" ]]; then
+ testssl_input="$dir/.tmp/ips_nocdn.txt"
+ fi
_print_msg INFO "Running: SSL Test with testssl.sh"
- run_command "${tools}/testssl.sh/testssl.sh" --quiet --color 0 -U -iL "$dir/hosts/ips.txt" 2>>"$LOGFILE" >"vulns/testssl.txt"
+ run_command "${tools}/testssl.sh/testssl.sh" --quiet --color 0 -U -iL "$testssl_input" 2>>"$LOGFILE" >"vulns/testssl.txt"
end_func "Results are saved in vulns/testssl.txt" "${FUNCNAME[0]}"
@@ -625,20 +634,14 @@ function 4xxbypass() {
if [[ $DEEP == true ]] || [[ $URL_COUNT -le $DEEP_LIMIT ]]; then
- # Navigate to nomore403 tool directory
- if ! pushd "${tools}/nomore403" >/dev/null; then
- print_warnf "Failed to navigate to nomore403 directory."
- end_func "Failed to navigate to nomore403 directory during 403 Bypass." "${FUNCNAME[0]}"
- return 1
- fi
-
- # Run nomore403 on the processed URLs
- ./nomore403 <"$dir/.tmp/403test.txt" >"$dir/.tmp/4xxbypass.txt" 2>>"$LOGFILE"
-
- # Return to the original directory
- if ! popd >/dev/null; then
- print_warnf "Failed to return to the original directory."
- end_func "Failed to return to the original directory during 403 Bypass." "${FUNCNAME[0]}"
+ # Run nomore403 in a subshell to avoid CWD pollution
+ (
+ cd "${tools}/nomore403" || exit 1
+ ./nomore403 <"$dir/.tmp/403test.txt" >"$dir/.tmp/4xxbypass.txt" 2>>"$LOGFILE"
+ )
+ if [[ $? -ne 0 ]]; then
+ print_warnf "nomore403 failed or directory not found."
+ end_func "Failed during 403 Bypass." "${FUNCNAME[0]}"
return 1
fi
@@ -651,7 +654,7 @@ function 4xxbypass() {
else
notification "Too many URLs to bypass, skipping" warn
- end_func "Skipping Command Injection: Too many URLs to test, try with --deep flag." "${FUNCNAME[0]}"
+ end_func "Skipping 403 Bypass: Too many URLs to test, try with --deep flag." "${FUNCNAME[0]}"
fi
else
@@ -745,22 +748,14 @@ function webcache() {
_print_msg INFO "Running: Web Cache Poisoning Checks"
- # Navigate to Web-Cache-Vulnerability-Scanner tool directory
- if ! pushd "${tools}/Web-Cache-Vulnerability-Scanner" >/dev/null; then
- print_warnf "Failed to navigate to Web-Cache-Vulnerability-Scanner directory."
- end_func "Failed to navigate to Web-Cache-Vulnerability-Scanner directory during Web Cache Poisoning Checks." "${FUNCNAME[0]}"
- return 1
- fi
-
- # Run the Web-Cache-Vulnerability-Scanner
- Web-Cache-Vulnerability-Scanner -u "file:$dir/webs/webs_all.txt" -v 0 2>>"$LOGFILE" \
- | anew -q "$dir/.tmp/webcache.txt"
-
- # Return to the original directory
- if ! popd >/dev/null; then
- print_warnf "Failed to return to the original directory."
- end_func "Failed to return to the original directory during Web Cache Poisoning Checks." "${FUNCNAME[0]}"
- return 1
+ # Run Web-Cache-Vulnerability-Scanner in a subshell to avoid CWD pollution
+ (
+ cd "${tools}/Web-Cache-Vulnerability-Scanner" || exit 1
+ Web-Cache-Vulnerability-Scanner -u "file:$dir/webs/webs_all.txt" -v 0 2>>"$LOGFILE" \
+ | anew -q "$dir/.tmp/webcache.txt"
+ )
+ if [[ $? -ne 0 ]]; then
+ print_warnf "Web-Cache-Vulnerability-Scanner failed or directory not found."
fi
# Append unique findings to vulns/webcache.txt
diff --git a/modules/web.sh b/modules/web.sh
index 0dfa4c5..40ce7a6 100644
--- a/modules/web.sh
+++ b/modules/web.sh
@@ -517,7 +517,6 @@ function portscan() {
else
_print_msg INFO "Resolved IP addresses (No CDN): none"
fi
- printf "\n"
_print_msg INFO "Scanning ports..."
@@ -884,13 +883,15 @@ _nuclei_prepare_waf_lists() {
if [[ -s webs/webs_wafs.txt ]]; then
cut -d';' -f1 webs/webs_wafs.txt | sed 's/https\?:\/\///' | sed 's/\/$//' | sort -u >.tmp/waf_hosts.txt
- awk -F/ '{print $3}' .tmp/webs_subs.txt | sed 's/\:$//' | while read -r host; do
- if grep -Fxq "$host" .tmp/waf_hosts.txt; then
- awk -v h="$host" -F/ '{u=$3; sub(/:.*/,"",u); if (u==h) print $0}' .tmp/webs_subs.txt | anew -q "$WAF_LIST"
- else
- awk -v h="$host" -F/ '{u=$3; sub(/:.*/,"",u); if (u==h) print $0}' .tmp/webs_subs.txt | anew -q "$NOWAF_LIST"
- fi
- done
+ # Single-pass classification: NR==FNR loads WAF hosts, then classifies URLs
+ awk -F/ '
+ NR==FNR { waf[$1]=1; next }
+ {
+ host=$3; sub(/:.*/, "", host)
+ if (host in waf) print $0 > waf_out
+ else print $0 > nowaf_out
+ }
+ ' waf_out="$WAF_LIST" nowaf_out="$NOWAF_LIST" .tmp/waf_hosts.txt .tmp/webs_subs.txt
else
cp .tmp/webs_subs.txt "$NOWAF_LIST"
fi
@@ -946,7 +947,6 @@ _nuclei_scan_local() {
fi
_nuclei_parse_results "$crit"
done
- printf "\n\n"
}
# Run nuclei scan via Axiom distributed fleet
@@ -963,7 +963,6 @@ _nuclei_scan_axiom() {
-silent -retries 2 $NUCLEI_EXTRA_ARGS -j -o "nuclei_output/${crit}_json.txt" "$AXIOM_EXTRA_ARGS"
_nuclei_parse_results "$crit"
done
- printf "\n\n"
}
function nuclei_check() {
@@ -1525,16 +1524,24 @@ function urlchecks() {
fi
if [[ $diff_webs != "0" ]] || [[ ! -s ".tmp/katana.txt" ]]; then
if [[ $URL_CHECK_ACTIVE == true ]]; then
+ # Only crawl NEW URLs when previous results exist (incremental)
+ local katana_input_file="webs/webs_all.txt"
+ if [[ -s ".tmp/katana.txt" ]] && [[ -s ".tmp/probed_tmp.txt" ]] && [[ -s "webs/webs_all.txt" ]]; then
+ comm -23 <(sort -u webs/webs_all.txt) <(sort -u .tmp/probed_tmp.txt) > .tmp/katana_new_webs.txt 2>/dev/null || true
+ if [[ -s ".tmp/katana_new_webs.txt" ]]; then
+ katana_input_file=".tmp/katana_new_webs.txt"
+ fi
+ fi
# Split slow vs normal targets based on httpx status (403/429)
: >.tmp/katana_targets_slow.txt
: >.tmp/katana_targets_normal.txt
if [[ -s .tmp/slow_hosts.txt ]]; then
while read -r host; do
- grep "://${host}[:/\n]" webs/webs_all.txt | anew -q .tmp/katana_targets_slow.txt
+ grep "://${host}[:/\n]" "$katana_input_file" | anew -q .tmp/katana_targets_slow.txt
done <.tmp/slow_hosts.txt
- comm -23 <(sort -u webs/webs_all.txt) <(sort -u .tmp/katana_targets_slow.txt) >.tmp/katana_targets_normal.txt
+ comm -23 <(sort -u "$katana_input_file") <(sort -u .tmp/katana_targets_slow.txt) >.tmp/katana_targets_normal.txt
else
- cp webs/webs_all.txt .tmp/katana_targets_normal.txt
+ cp "$katana_input_file" .tmp/katana_targets_normal.txt
fi
: >.tmp/katana.txt
@@ -1756,21 +1763,38 @@ function url_ext() {
print_warnf "Failed to initialize webs/urls_by_ext.txt."
fi
- # Iterate over extensions and extract matching URLs
- for t in "${ext[@]}"; do
-
- # Extract unique matching URLs
- grep -aEi "\.(${t})($|/|\?)" ".tmp/url_extract_tmp.txt" 2>>"$LOGFILE" \
- | sort -u \
- | sed '/^$/d' >".tmp/urls_by_ext_${t}.tmp" || true
-
- NUMOFLINES=$(wc -l <".tmp/urls_by_ext_${t}.tmp" 2>/dev/null || echo 0)
-
- if [[ $NUMOFLINES -gt 0 ]]; then
+ # Build a single regex pattern for all extensions (single-pass extraction)
+ local ext_pattern
+ ext_pattern=$(printf '%s|' "${ext[@]}")
+ ext_pattern="${ext_pattern%|}" # remove trailing pipe
+
+ # Single grep pass to classify URLs by extension using awk
+ awk -v exts="${ext_pattern}" '
+ BEGIN { split(exts, ea, "|"); for (i in ea) ext_map[ea[i]] = 1 }
+ {
+ url = $0
+ # Extract extension from URL
+ gsub(/[?#].*/, "", url)
+ gsub(/\/$/, "", url)
+ n = split(url, parts, ".")
+ if (n > 0) {
+ ext = tolower(parts[n])
+ if (ext in ext_map) {
+ print ext "\t" $0
+ }
+ }
+ }' ".tmp/url_extract_tmp.txt" 2>>"$LOGFILE" | sort -t$'\t' -k1,1 -k2,2 -u > ".tmp/urls_by_ext_all.tmp" || true
+
+ # Group by extension and write output
+ local current_ext=""
+ while IFS=$'\t' read -r t url; do
+ if [[ "$t" != "$current_ext" ]]; then
+ current_ext="$t"
printf "\n############################\n + %s + \n############################\n" "$t" >>webs/urls_by_ext.txt
- cat ".tmp/urls_by_ext_${t}.tmp" >>webs/urls_by_ext.txt
fi
- done
+ printf "%s\n" "$url" >>webs/urls_by_ext.txt
+ done < ".tmp/urls_by_ext_all.tmp"
+ rm -f ".tmp/urls_by_ext_all.tmp"
# Append ssrf.txt to redirect.txt if ssrf.txt exists and is not empty
if [[ -s "gf/ssrf.txt" ]]; then
@@ -1890,10 +1914,8 @@ function jschecks() {
fi
mkdir -p .tmp/sourcemapper/secrets
if [[ -s "js/js_secrets.txt" ]]; then
- while IFS= read -r i; do
- [[ -z "$i" ]] && continue
- run_command wget -q -P .tmp/sourcemapper/secrets -- "$i" || true
- done < <(cut -d' ' -f2 js/js_secrets.txt)
+ # Parallel downloads instead of serial wget loop
+ cut -d' ' -f2 js/js_secrets.txt | xargs -P 10 -I {} wget -q -P .tmp/sourcemapper/secrets -- {} 2>/dev/null || true
fi
run_command trufflehog filesystem .tmp/sourcemapper/ -j 2>/dev/null | jq -c | anew -q js/js_secrets_jsmap.txt
find .tmp/sourcemapper/ -type f -name "*.js" | run_command jsluice secrets -j --patterns="${PATTERNS_DIR}/jsluice_patterns.json" | anew -q js/js_secrets_jsmap_jsluice.txt
diff --git a/reconftw.cfg b/reconftw.cfg
index 1643eb6..335e458 100644
--- a/reconftw.cfg
+++ b/reconftw.cfg
@@ -36,7 +36,7 @@ upgrade_tools=true
upgrade_before_running=false # Upgrade tools before running
#dir_output=/custom/output/path
SHOW_COMMANDS=false # Set true to log every executed command to the per-target log (verbose; may include sensitive data)
-MIN_DISK_SPACE_GB=0 # Minimum required disk space in GB before starting reconnaissance (0 to disable check)
+MIN_DISK_SPACE_GB=2 # Minimum required disk space in GB before starting reconnaissance (0 to disable check)
# Incremental mode configuration
INCREMENTAL_MODE=false # Only scan new findings since last run (use --incremental flag to enable)
@@ -328,10 +328,10 @@ HTTPX_THREADS=$((AVAILABLE_CORES * 12))
HTTPX_UNCOMMONPORTS_THREADS=$((AVAILABLE_CORES * 25))
KATANA_THREADS=$((AVAILABLE_CORES * 5))
BRUTESPRAY_CONCURRENCE=$((AVAILABLE_CORES * 2))
-DNSTAKE_THREADS=$((AVAILABLE_CORES * 25))
-DALFOX_THREADS=$((AVAILABLE_CORES * 50))
+DNSTAKE_THREADS=$((AVAILABLE_CORES * 10)) # Reduced from 25x to avoid rate limiting
+DALFOX_THREADS=$((AVAILABLE_CORES * 15)) # Reduced from 50x to avoid triggering WAFs
DNS_RESOLVER=auto # auto|puredns|dnsx (auto: detects NAT/CGNAT → dnsx for home, puredns for VPS)
-PUREDNS_PUBLIC_LIMIT=0 # Set between 2000 - 10000 if your router blows up, 0 means unlimited
+PUREDNS_PUBLIC_LIMIT=5000 # Safe default; set 0 for unlimited on VPS with dedicated resolver
PUREDNS_TRUSTED_LIMIT=400
PUREDNS_WILDCARDTEST_LIMIT=30
PUREDNS_WILDCARDBATCH_LIMIT=1500000
@@ -353,7 +353,7 @@ CMSSCAN_TIMEOUT=3600 # Seconds
FFUF_MAXTIME=900 # Seconds
HTTPX_TIMEOUT=10 # Seconds
HTTPX_UNCOMMONPORTS_TIMEOUT=10 # Seconds
-PERMUTATIONS_LIMIT=21474836480 # Bytes, default is 20 GB
+PERMUTATIONS_LIMIT=2147483648 # Bytes, default is 2 GB (prevents accidental disk exhaustion)
DNS_BRUTE_TIMEOUT=0 # timeout/gtimeout duration for DNS bruteforce (0 disables hard-timeout, e.g. 4h)
DNS_RESOLVE_TIMEOUT=0 # timeout/gtimeout duration for DNS resolve (0 disables hard-timeout, e.g. 6h)
DNS_HEARTBEAT_INTERVAL_SECONDS=20 # Progress heartbeat interval for long DNS jobs
diff --git a/reconftw.sh b/reconftw.sh
index 13c9ef1..20ef12e 100755
--- a/reconftw.sh
+++ b/reconftw.sh
@@ -120,22 +120,24 @@ if [[ $OSTYPE == "darwin"* ]]; then
_print_error "Brew is not installed or not in the PATH"
exit 1
fi
- if [[ ! -x "$(brew --prefix gnu-getopt)/bin/getopt" ]]; then
+ # 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 coreutils)/libexec/gnubin" ]]; then
+ if [[ ! -d "${_brew_prefix}/opt/coreutils/libexec/gnubin" ]]; then
_print_error "Brew formula coreutils is not installed"
exit 1
fi
- if [[ ! -d "$(brew --prefix gnu-sed)/libexec/gnubin" ]]; then
+ if [[ ! -d "${_brew_prefix}/opt/gnu-sed/libexec/gnubin" ]]; then
_print_error "Brew formula gnu-sed is not installed"
exit 1
fi
- # Prefix is different depending on Intel vs Apple Silicon
- PATH="$(brew --prefix gnu-getopt)/bin:$PATH"
- PATH="$(brew --prefix coreutils)/libexec/gnubin:$PATH"
- PATH="$(brew --prefix gnu-sed)/libexec/gnubin:$PATH"
+ 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=()
@@ -347,22 +349,22 @@ while true; do
continue
;;
'--quick-rescan')
- QUICK_RESCAN=true
+ CLI_QUICK_RESCAN=true
shift
continue
;;
'--incremental')
- INCREMENTAL_MODE=true
+ CLI_INCREMENTAL_MODE=true
shift
continue
;;
'--adaptive-rate')
- ADAPTIVE_RATE_LIMIT=true
+ CLI_ADAPTIVE_RATE_LIMIT=true
shift
continue
;;
'--dry-run')
- DRY_RUN=true
+ CLI_DRY_RUN=true
shift
continue
;;
@@ -404,7 +406,7 @@ while true; do
continue
;;
'--force')
- FORCE_RESCAN=true
+ CLI_FORCE_RESCAN=true
shift
continue
;;
@@ -423,7 +425,7 @@ while true; do
continue
;;
'--no-report')
- NO_REPORT=true
+ CLI_NO_REPORT=true
shift
continue
;;
@@ -538,6 +540,24 @@ if [[ -n "${CLI_AXIOM_FLEET_COUNT:-}" ]]; then
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
@@ -578,7 +598,7 @@ 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
+ exit $E_INVALID_INPUT
fi
fi
@@ -586,7 +606,7 @@ if [[ -n $inScope_file ]]; then
isAsciiText "$inScope_file"
if [[ "False" == "$IS_ASCII" ]]; then
_print_error "In Scope file is not a text file"
- exit
+ exit $E_INVALID_INPUT
fi
fi
@@ -743,10 +763,10 @@ case $opt_mode in
fi
else
_print_error "Web mode needs a website list file as target (./reconftw.sh -l target.txt -w)"
- exit
+ exit $E_INVALID_INPUT
fi
webs_menu
- exit
+ exit 0
;;
'n')
PRESERVE=true
diff --git a/tests/unit/test_parallel.bats b/tests/unit/test_parallel.bats
index 3e2f3d4..318e853 100644
--- a/tests/unit/test_parallel.bats
+++ b/tests/unit/test_parallel.bats
@@ -30,33 +30,9 @@ teardown() {
}
###############################################################################
-# parallel_run tests
+# parallel_run tests (function removed — was unused dead code with injection vector)
###############################################################################
-@test "parallel_run executes single command" {
- run parallel_run 2 "echo hello > out1.txt"
- [ "$status" -eq 0 ]
- [ -f "out1.txt" ]
- [ "$(cat out1.txt)" = "hello" ]
-}
-
-@test "parallel_run executes multiple commands" {
- run parallel_run 2 "echo a > a.txt" "echo b > b.txt" "echo c > c.txt"
- [ "$status" -eq 0 ]
- [ -f "a.txt" ]
- [ -f "b.txt" ]
- [ -f "c.txt" ]
-}
-
-@test "parallel_run respects job limit" {
- # This test verifies commands complete (timing would be flaky)
- run parallel_run 2 "sleep 0.1 && echo 1 > 1.txt" "sleep 0.1 && echo 2 > 2.txt" "sleep 0.1 && echo 3 > 3.txt"
- [ "$status" -eq 0 ]
- [ -f "1.txt" ]
- [ -f "2.txt" ]
- [ -f "3.txt" ]
-}
-
###############################################################################
# parallel_funcs tests
###############################################################################
@@ -174,11 +150,6 @@ teardown() {
[ "$(wc -l < shared.txt | tr -d ' ')" -eq 3 ]
}
-@test "parallel_run handles empty command list" {
- run parallel_run 2
- [ "$status" -eq 0 ]
-}
-
@test "parallel_funcs handles empty function list" {
run parallel_funcs 2
[ "$status" -eq 0 ]
diff --git a/tests/unit/test_verbosity.bats b/tests/unit/test_verbosity.bats
index e896f7e..8e300ed 100644
--- a/tests/unit/test_verbosity.bats
+++ b/tests/unit/test_verbosity.bats
@@ -44,8 +44,6 @@ setup() {
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() {
@@ -138,26 +136,3 @@ teardown() {
[[ "$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" == "" ]]
-}