Subdomain Enumeration and Passive Recon: Tools, Methodology, and Automation

Subdomain enumeration is a cornerstone of passive reconnaissance in bug bounty hunting and external penetration testing. Finding forgotten development subdomains, staging environments, and legacy applications dramatically expands the attack surface. This guide covers passive and active subdomain discovery techniques, automation workflows, and how to process results effectively.

Why Subdomain Enumeration Matters

Target programs often have thousands of subdomains. The main domain may be heavily tested and hardened, while dev.target.com, staging.api.target.com, or legacy-app.target.com might run outdated software, expose internal admin panels, or have no security controls. Bug bounty hunters consistently report finding critical vulnerabilities on forgotten subdomains.

Passive Subdomain Discovery

Passive techniques query third-party data sources without touching the target’s infrastructure — no logs, no detection:

# subfinder - fastest passive tool, queries 50+ sources
subfinder -d target.com -all -recursive -o subfinder.txt

# amass (passive mode)
amass enum -passive -d target.com -o amass_passive.txt

# assetfinder
go install github.com/tomnomnom/assetfinder@latest
assetfinder --subs-only target.com >> results.txt

# crt.sh (Certificate Transparency logs)
curl -s 'https://crt.sh/?q=%25.target.com&output=json' | jq -r '.[].name_value' | sort -u

Certificate Transparency Logs

# Manual crt.sh query
site:crt.sh target.com  # In browser

# Using ct-exposer
python3 ct-exposer.py -d target.com

# Google Transparency Report
https://transparencyreport.google.com/https/certificates?domain=target.com

# Common sources:
# crt.sh, Censys, Facebook CT Monitor
# Note: wildcards (*.target.com) reveal the cert exists but not actual subdomains

Active DNS Brute Forcing

# puredns - fastest DNS resolver with wildcard detection
go install github.com/d3mondev/puredns/v2@latest
puredns bruteforce /usr/share/seclists/Discovery/DNS/subdomains-top1million-20000.txt target.com -r resolvers.txt

# shuffledns
shuffledns -d target.com -w subdomains.txt -r resolvers.txt -o active.txt

# gobuster DNS mode
gobuster dns -d target.com -w /usr/share/seclists/Discovery/DNS/dns-Jhaddix.txt -t 50

# feroxbuster for web discovery after DNS enum
feroxbuster -u https://subdomain.target.com -w /usr/share/wordlists/dirb/big.txt

Wildcard Detection

# Test for wildcard DNS (fake subdomain resolves)
dig A randomstring12345.target.com
# If it resolves to an IP, wildcards exist
# puredns and massdns handle wildcards automatically

# Manual wildcard check
for i in 1 2 3; do
  echo $(cat /dev/urandom | tr -dc 'a-z' | head -c 10).target.com
done | xargs -I{} dig A {} +short

Automated Recon Pipeline

#!/bin/bash
DOMAIN=$1
MKDIR=recon/$DOMAIN
mkdir -p $MKDIR

# Step 1: Passive collection
subfinder -d $DOMAIN -all -silent >> $MKDIR/passive.txt
amass enum -passive -d $DOMAIN -silent >> $MKDIR/passive.txt
assetfinder --subs-only $DOMAIN >> $MKDIR/passive.txt
curl -s 'https://crt.sh/?q=%25.'$DOMAIN'&output=json' | jq -r '.[].name_value' >> $MKDIR/passive.txt

# Step 2: Deduplicate
sort -u $MKDIR/passive.txt > $MKDIR/unique.txt

# Step 3: Resolve with puredns
puredns resolve $MKDIR/unique.txt -r resolvers.txt -o $MKDIR/resolved.txt

# Step 4: Active brute force
puredns bruteforce subdomains-top1million-20000.txt $DOMAIN -r resolvers.txt >> $MKDIR/resolved.txt
sort -u $MKDIR/resolved.txt -o $MKDIR/all_subs.txt

echo "Total subdomains: $(wc -l < $MKDIR/all_subs.txt)"

Web Probing and Screenshot

# httpx - probe for live web services
httpx -l all_subs.txt -ports 80,443,8080,8443 -o live_hosts.txt -title -status-code -tech-detect

# gowitness - screenshots of all live hosts
gowitness file -f live_hosts.txt --screenshot-path ./screens/
gowitness report generate  # Creates HTML report

# aquatone (alternative screenshotter)
cat live_hosts.txt | aquatone -out ./aquatone_output/

Finding Juicy Subdomains

# Filter for interesting patterns
grep -E 'dev|staging|test|admin|api|vpn|jenkins|gitlab|jira|backup|old|legacy|internal' all_subs.txt

# Check for subdomain takeover candidates
subjack -w all_subs.txt -t 100 -timeout 30 -o takeover.txt
nuclei -l all_subs.txt -t ~/nuclei-templates/takeovers/

# Check for exposed services
nmap -iL resolved_ips.txt -p 22,80,443,8080,8443,3000,5000 --open -oA nmap_web

DNS Record Types to Check

# For each discovered subdomain
dig A sub.target.com          # IPv4 address
dig AAAA sub.target.com       # IPv6 address
dig CNAME sub.target.com      # Canonical name (takeover candidates)
dig MX sub.target.com         # Mail servers
dig TXT sub.target.com        # SPF, DKIM, verification tokens
dig NS sub.target.com         # Nameservers
dig SRV _http._tcp.target.com # Service records

Conclusion

Effective subdomain enumeration combines passive CT log mining (crt.sh, subfinder) with active DNS brute forcing (puredns) and resolving results through valid resolvers. Automate the pipeline into a reusable script, probe live hosts with httpx, take screenshots with gowitness, and filter for interesting patterns like dev, staging, and admin. Subdomain takeover via dangling CNAME records is a consistently high-impact finding — always run subjack or nuclei takeover templates across your results.

Related Articles

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top