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

Pass postman urls , js endpoint checks urls into webs for more subdomains/urls to check , goes through scope checks to clear out irrelevant hosts.

kleozzy9503a846b691
diff --git a/modules/osint.sh b/modules/osint.sh
index 09db9ec..7230494 100644
--- a/modules/osint.sh
+++ b/modules/osint.sh
@@ -451,6 +451,9 @@ function apileaks() {
return
fi
+ merge_scoped_urls_into_url_extract "${dir}/osint/postman_leaks.txt" "apileaks_postman"
+ merge_scoped_urls_into_url_extract "${dir}/osint/swagger_leaks.txt" "apileaks_swagger"
+
# Analyze leaks with trufflehog
if [[ -s "${dir}/osint/postman_leaks.txt" ]]; then
run_command trufflehog filesystem "${dir}/osint/postman_leaks.txt" -j 2>/dev/null | jq -c | anew -q "${dir}/osint/postman_leaks_trufflehog.json"
diff --git a/modules/utils.sh b/modules/utils.sh
index 8d59ad9..808b419 100644
--- a/modules/utils.sh
+++ b/modules/utils.sh
@@ -30,6 +30,85 @@ function deleteOutScoped() {
fi
}
+merge_scoped_urls_into_url_extract() {
+ local source_file="$1"
+ local source_label="${2:-url source}"
+ local raw_file=".tmp/${source_label}_urls_raw.txt"
+ local scoped_file=".tmp/${source_label}_urls_scoped.txt"
+ local normalized_file=".tmp/${source_label}_urls_normalized.txt"
+ local query_file=".tmp/${source_label}_urls_query.txt"
+ local plain_file=".tmp/${source_label}_urls_plain.txt"
+ local domain_regex
+ local added_count=0
+
+ [[ ! -s "$source_file" ]] && return 0
+
+ ensure_dirs .tmp webs || return 1
+ domain_regex=$(domain_match_regex "$domain")
+ : >"$raw_file"
+ : >"$scoped_file"
+ : >"$normalized_file"
+ : >"$query_file"
+ : >"$plain_file"
+
+ grep -aEo 'https?://[^ ]+' "$source_file" \
+ | sed -E 's/[[:space:]]+$//' \
+ | sed -E 's/[),;]$//' \
+ | sed 's/"$//' \
+ | sed "s/'$//" \
+ | sort -u >"$raw_file" 2>/dev/null || true
+
+ if [[ -s "$raw_file" ]]; then
+ awk -v re="$domain_regex" -F/ '
+ /^https?:\/\// {
+ h=$3
+ sub(/:.*/, "", h)
+ if (h ~ re) print
+ }
+ ' "$raw_file" >"$scoped_file" 2>/dev/null || true
+ fi
+
+ if [[ -n "${outOfScope_file:-}" ]] && [[ -s "$outOfScope_file" ]] && [[ -s "$scoped_file" ]]; then
+ deleteOutScoped "$outOfScope_file" "$scoped_file" || true
+ fi
+
+ if [[ "${INSCOPE:-false}" == true ]] && [[ -s "$scoped_file" ]]; then
+ if ! check_inscope "$scoped_file" 2>>"$LOGFILE" >/dev/null; then
+ print_warnf "check_inscope command failed."
+ fi
+ fi
+
+ [[ ! -s "$scoped_file" ]] && return 0
+
+ awk '/\?/{print > q} !/\?/{print > p}' q="$query_file" p="$plain_file" "$scoped_file"
+ if command -v urless >/dev/null 2>&1 && [[ -s "$query_file" ]]; then
+ urless <"$query_file" >"$normalized_file" 2>>"$LOGFILE" || true
+ else
+ cat "$query_file" >"$normalized_file" 2>/dev/null || true
+ fi
+ [[ -s "$plain_file" ]] && cat "$plain_file" >>"$normalized_file"
+ sort -u "$normalized_file" -o "$normalized_file" 2>/dev/null || true
+
+ if [[ -s "$normalized_file" ]]; then
+ if ! added_count=$(anew webs/url_extract.txt <"$normalized_file" | sed '/^$/d' | wc -l | tr -d ' '); then
+ added_count=0
+ fi
+ [[ "$added_count" =~ ^[0-9]+$ ]] || added_count=0
+
+ if [[ "$added_count" -gt 0 ]]; then
+ if [[ "${ASSET_STORE:-false}" == "true" ]]; then
+ append_assets_from_file url value webs/url_extract.txt
+ fi
+ if command -v p1radup >/dev/null 2>&1; then
+ p1radup -i webs/url_extract.txt -o webs/url_extract_nodupes.txt -s 2>>"$LOGFILE" >/dev/null || true
+ else
+ sort -u webs/url_extract.txt >webs/url_extract_nodupes.txt 2>>"$LOGFILE" || true
+ fi
+ notification "${source_label}: ${added_count} scoped URLs merged" "info"
+ fi
+ fi
+}
+
function cleanup_on_exit() {
local exit_code="${1:-130}"
printf "\n%b[%s] Interrupted. Cleaning up...%b\n" "$bred" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"
diff --git a/modules/web.sh b/modules/web.sh
index 0b81bec..966b3a6 100644
--- a/modules/web.sh
+++ b/modules/web.sh
@@ -2164,6 +2164,9 @@ function jschecks() {
cat .tmp/js_endpoints.txt | anew -q js/js_endpoints.txt || true
fi
+ merge_scoped_urls_into_url_extract "js/nojs_links.txt" "js_nojs"
+ merge_scoped_urls_into_url_extract "js/js_endpoints.txt" "js_endpoints"
+
[[ "${OUTPUT_VERBOSITY:-1}" -ge 2 ]] && printf "%bRunning: Gathering secrets 5/6%b\n" "$yellow" "$reset"
if [[ -s "js/js_livelinks.txt" ]]; then
if [[ $AXIOM != true ]]; then
@@ -2387,6 +2390,16 @@ function well_known_pivots() {
if [[ -s ".tmp/wellknown_hosts_resolved.txt" ]]; then
NUMOFLINES=$(anew subdomains/subdomains.txt <.tmp/wellknown_hosts_resolved.txt | sed '/^$/d' | wc -l | tr -d ' ' || true)
[[ "$NUMOFLINES" =~ ^[0-9]+$ ]] || NUMOFLINES=0
+
+ if [[ $NUMOFLINES -gt 0 ]]; then
+ _print_msg INFO "Well-known pivots: delta-probing ${NUMOFLINES} new subdomains"
+ run_command httpx -follow-host-redirects -random-agent -silent \
+ -status-code -p "${WEBPROBE_PORTS:-80,443}" \
+ -threads "${HTTPX_THREADS:-50}" -rl "${HTTPX_RATELIMIT:-0}" \
+ -timeout "${HTTPX_TIMEOUT:-10}" -retries 2 -no-color \
+ <.tmp/wellknown_hosts_resolved.txt \
+ | awk '{print $1}' | anew -q webs/webs.txt 2>/dev/null || true
+ fi
fi
fi
fi
diff --git a/tests/unit/test_new_tool_integrations.bats b/tests/unit/test_new_tool_integrations.bats
index 5565d75..87fbd0b 100644
--- a/tests/unit/test_new_tool_integrations.bats
+++ b/tests/unit/test_new_tool_integrations.bats
@@ -135,20 +135,50 @@ SH
grep -q "GitLab" "webs/favirecon.txt"
}
-@test "apileaks integrates postleaksNg output" {
+@test "apileaks merges scoped leak URLs into url_extract" {
mkdir -p osint
export tools="$TEST_DIR/tools"
mkdir -p "$tools/SwaggerSpy/venv/bin" "$tools/SwaggerSpy"
+ export outOfScope_file="$TEST_DIR/out_of_scope.txt"
+ printf '%s\n' 'swagger.target.example.com' > "$outOfScope_file"
+
+ cat > "$MOCK_BIN/anew" <<'SH'
+#!/usr/bin/env bash
+quiet=false
+if [[ "${1:-}" == "-q" ]]; then
+ quiet=true
+ shift
+fi
+outfile="$1"
+mkdir -p "$(dirname "$outfile")"
+touch "$outfile"
+while IFS= read -r line; do
+ [[ -z "$line" ]] && continue
+ if ! grep -Fxq -- "$line" "$outfile"; then
+ printf '%s\n' "$line" >> "$outfile"
+ if [[ "$quiet" != true ]]; then
+ printf '%s\n' "$line"
+ fi
+ fi
+done
+SH
+ chmod +x "$MOCK_BIN/anew"
+
+ cat > "$MOCK_BIN/urless" <<'SH'
+#!/usr/bin/env bash
+cat
+SH
+ chmod +x "$MOCK_BIN/urless"
cat > "$MOCK_BIN/porch-pirate" <<'SH'
#!/usr/bin/env bash
-printf '%s\n' 'https://postman.initial.example.com/api'
+printf '%s\n' 'https://api.target.example.com/v1/users?first=1'
SH
chmod +x "$MOCK_BIN/porch-pirate"
cat > "$tools/SwaggerSpy/venv/bin/python3" <<'SH'
#!/usr/bin/env bash
-printf '%s\n' 'URL https://swagger.example.com/openapi.json'
+printf '%s\n' 'URL https://swagger.target.example.com/openapi.json'
SH
chmod +x "$tools/SwaggerSpy/venv/bin/python3"
printf '%s\n' 'print("mock")' > "$tools/SwaggerSpy/swaggerspy.py"
@@ -168,7 +198,8 @@ while [[ $# -gt 0 ]]; do
esac
done
mkdir -p "$out"
-printf '%s\n' '{"url":"https://postman.new.example.com/path"}' > "$out/postleaks.json"
+printf '%s\n' '{"url":"https://postman.target.example.com/path?token=1"}' > "$out/postleaks.json"
+printf '%s\n' '{"url":"https://outside.example.net/path?next=target.example.com"}' > "$out/postleaks-outside.json"
SH
chmod +x "$MOCK_BIN/postleaksNg"
@@ -186,7 +217,124 @@ SH
run apileaks
[ "$status" -eq 0 ]
[ -s "osint/postman_leaks.txt" ]
- grep -q "postman.new.example.com" "osint/postman_leaks.txt"
+ grep -q "postman.target.example.com" "osint/postman_leaks.txt"
+ [ -s "webs/url_extract.txt" ]
+ grep -q '^https://api.target.example.com/v1/users?first=1$' "webs/url_extract.txt"
+ grep -q '^https://postman.target.example.com/path?token=1$' "webs/url_extract.txt"
+ ! grep -q 'outside.example.net' "webs/url_extract.txt"
+ ! grep -q 'swagger.target.example.com' "webs/url_extract.txt"
+}
+
+@test "jschecks merges only scoped JS-discovered URLs into url_extract" {
+ mkdir -p js webs .tmp subdomains
+ printf '%s\n' 'https://target.example.com/app.js' > .tmp/url_extract_js.txt
+ printf '%s\n' 'target.example.com' > subdomains/subdomains.txt
+ export outOfScope_file="$TEST_DIR/out_of_scope_js.txt"
+ printf '%s\n' 'graphql.target.example.com' > "$outOfScope_file"
+
+ cat > "$MOCK_BIN/anew" <<'SH'
+#!/usr/bin/env bash
+quiet=false
+if [[ "${1:-}" == "-q" ]]; then
+ quiet=true
+ shift
+fi
+outfile="$1"
+mkdir -p "$(dirname "$outfile")"
+touch "$outfile"
+while IFS= read -r line; do
+ [[ -z "$line" ]] && continue
+ if ! grep -Fxq -- "$line" "$outfile"; then
+ printf '%s\n' "$line" >> "$outfile"
+ if [[ "$quiet" != true ]]; then
+ printf '%s\n' "$line"
+ fi
+ fi
+done
+SH
+ chmod +x "$MOCK_BIN/anew"
+
+ cat > "$MOCK_BIN/urless" <<'SH'
+#!/usr/bin/env bash
+cat
+SH
+ chmod +x "$MOCK_BIN/urless"
+
+ cat > "$MOCK_BIN/subjs" <<'SH'
+#!/usr/bin/env bash
+printf '%s\n' 'https://api.target.example.com/v1/users?id=1'
+printf '%s\n' 'https://outside.example.net/relay?next=target.example.com'
+printf '%s\n' 'https://target.example.com/logo.png'
+printf '%s\n' 'https://target.example.com/app2.js'
+SH
+ chmod +x "$MOCK_BIN/subjs"
+
+ cat > "$MOCK_BIN/httpx" <<'SH'
+#!/usr/bin/env bash
+while IFS= read -r url; do
+ [[ -z "$url" ]] && continue
+ printf '%s [200] [text/javascript]\n' "$url"
+done
+SH
+ chmod +x "$MOCK_BIN/httpx"
+
+ cat > "$MOCK_BIN/interlace" <<'SH'
+#!/usr/bin/env bash
+exit 0
+SH
+ chmod +x "$MOCK_BIN/interlace"
+
+ cat > "$MOCK_BIN/xnLinkFinder" <<'SH'
+#!/usr/bin/env bash
+outfile=""
+while [[ $# -gt 0 ]]; do
+ case "$1" in
+ -o)
+ outfile="$2"
+ shift 2
+ ;;
+ *)
+ shift
+ ;;
+ esac
+done
+printf '%s\n' 'https://graphql.target.example.com/query' > "$outfile"
+printf '%s\n' 'https://evil.example.org/path?host=target.example.com' >> "$outfile"
+SH
+ chmod +x "$MOCK_BIN/xnLinkFinder"
+
+ cat > "$MOCK_BIN/jsluice" <<'SH'
+#!/usr/bin/env bash
+exit 0
+SH
+ chmod +x "$MOCK_BIN/jsluice"
+
+ cat > "$MOCK_BIN/mantra" <<'SH'
+#!/usr/bin/env bash
+exit 0
+SH
+ chmod +x "$MOCK_BIN/mantra"
+
+ cat > "$MOCK_BIN/trufflehog" <<'SH'
+#!/usr/bin/env bash
+exit 0
+SH
+ chmod +x "$MOCK_BIN/trufflehog"
+
+ export JSCHECKS=true
+ export AXIOM=false
+ export HTTPX_TIMEOUT=5
+ export HTTPX_THREADS=5
+ export HTTPX_RATELIMIT=0
+ export INTERLACE_THREADS=2
+ export XNLINKFINDER_DEPTH=1
+
+ run jschecks
+ [ "$status" -eq 0 ]
+ [ -s "webs/url_extract.txt" ]
+ grep -q '^https://api.target.example.com/v1/users?id=1$' "webs/url_extract.txt"
+ ! grep -q 'outside.example.net' "webs/url_extract.txt"
+ ! grep -q 'graphql.target.example.com' "webs/url_extract.txt"
}
@test "s3buckets uses cloud_enum and writes cloud_enum artifacts" {
@@ -1132,6 +1280,50 @@ SH
grep -q "PARAM: token" "webs/params_discovered.txt"
}
+@test "well_known_pivots probes newly discovered subdomains into webs.txt" {
+ mkdir -p webs .tmp subdomains
+ printf '%s\n' 'https://target.example.com' > webs/webs_all.txt
+
+ _resolve_domains() {
+ cat "$1" > "$2"
+ }
+
+ cat > "$MOCK_BIN/curl" <<'SH'
+#!/usr/bin/env bash
+url="${@: -1}"
+case "$url" in
+ *"/.well-known/security.txt"|*"/security.txt")
+ printf '%s\n' 'Contact: [email protected]'
+ ;;
+ *)
+ printf '%s\n' ''
+ ;;
+esac
+SH
+ chmod +x "$MOCK_BIN/curl"
+
+ cat > "$MOCK_BIN/httpx" <<'SH'
+#!/usr/bin/env bash
+while IFS= read -r host; do
+ [[ -z "$host" ]] && continue
+ printf '%s 200\n' "https://${host}"
+done
+SH
+ chmod +x "$MOCK_BIN/httpx"
+
+ export WELLKNOWN_PIVOTS=true
+ export HTTPX_THREADS=5
+ export HTTPX_RATELIMIT=0
+ export HTTPX_TIMEOUT=5
+
+ run well_known_pivots
+ [ "$status" -eq 0 ]
+ [ -s "subdomains/subdomains.txt" ]
+ [ -s "webs/webs.txt" ]
+ grep -q '^auth.target.example.com$' "subdomains/subdomains.txt"
+ grep -q '^https://auth.target.example.com$' "webs/webs.txt"
+}
+
@test "wordlist_gen_roboxtractor skips in non-DEEP mode with explicit mode reason" {
mkdir -p webs .tmp gf
printf '%s\n' 'https://target.example.com' > webs/webs_all.txt