Subdomain Enumeration: Finding Hidden Attack Surface
Master subdomain enumeration techniques using passive and active methods to discover hidden subdomains and expand attack surface mapping.
Attack Surface Discovery
Subdomain enumeration is a methodology for discovering hidden attack surfaces within a target's domain infrastructure. Organizations host different services on separate subdomains — development servers, staging environments, API endpoints, admin panels — many of which are less monitored and secured than the primary site. Identifying these subdomains maps the full extent of a target's online presence and reveals potential entry points overlooked by defenders.
Main domain: company.com (well-secured, behind WAF)
Hidden: dev-api.company.com (no WAF, default credentials)
Hidden: test.company.com (staging, outdated software)
Hidden: admin.company.com (internal panel, weak auth)
Prerequisites
Before studying subdomain enumeration, you should understand:
Passive Subdomain Enumeration
Certificate Transparency Logs
# Using crt.sh
curl -s "https://crt.sh/?q=%25.target.com&output=json" | jq -r '.[].name_value' | sort -u
# Using certspotter
curl -s "https://certspotter.com/api/v0/certs?domain=target.com" | jq -r '.[].dns_names[]' | sort -u
Search Engines
# Google dork
site:target.com -www -mail
DNS Datasets
# SecurityTrails
curl -s "https://api.securitytrails.com/v1/domain/target.com/subdomains" -H "APIKEY: YOUR_KEY" | jq -r '.subdomains[]' | awk '{print $0".target.com"}'
# AlienVault OTX
curl -s "https://otx.alienvault.com/api/v1/indicators/domain/target.com/passive_dns" | jq -r '.passive_dns[].hostname' | sort -u
Active Subdomain Enumeration
DNS Brute Forcing
# Using dnsrecon
dnsrecon -d target.com -D /usr/share/wordlists/dns/subdomains-top1million-20000.txt -t brt
# Using gobuster
gobuster dns -d target.com -w /usr/share/wordlists/dns/subdomains-top1million-110000.txt
# Using ffuf for virtual host discovery
ffuf -w subdomains.txt:HOST -u https://target.com -H "Host: HOST.target.com" -fc 400,403,404,301
# Using massdns (fastest)
massdns -r /usr/share/seclists/Discovery/DNS/resolvers.txt -t A -o S -w results.txt subdomains.txt
DNS Zone Transfer
for ns in $(dig target.com NS +short); do
echo "Trying $ns..."
dig @$ns target.com AXFR +short 2>/dev/null
done
Web Scraping
# Extract links from main site
curl -s https://target.com | grep -oP 'https?://[a-zA-Z0-9.-]*.target.com' | sort -u
# Check robots.txt and sitemap.xml
curl -s https://target.com/robots.txt
curl -s https://target.com/sitemap.xml | grep -oP 'https?://[^/]+'
Subdomain Takeover Detection
When a subdomain's DNS points to a third-party service that has been deprovisioned, anyone can claim it:
# Check for dangling CNAME records
dig subdomain.target.com CNAME +short
# Automated detection
subjack -w subdomains.txt -t 100 -timeout 30 -o results.txt
# Using Nuclei
nuclei -t nuclei-templates/subdomain-takeover/ -l subdomains.txt
Vulnerable Services
| CNAME Target | Service | Check |
|--------------|---------|-------|
| cloudfront.net | AWS CloudFront | NXDOMAIN |
| s3.amazonaws.com | AWS S3 | NoSuchBucket |
| github.io | GitHub Pages | 404 |
| herokuapp.com | Heroku | No such app |
| azurewebsites.net | Azure | 404 |
| firebaseio.com | Firebase | Not found |
Real-World Examples
Uber Subdomain Takeover (2016): A researcher found multiple Uber subdomains vulnerable to takeover through CloudFront, earning critical bounties.
Samsung (2020): Several Samsung subdomains were taken over by pointing CNAME records to unclaimed AWS S3 buckets.
Common Mistakes
Only using one source: Combining passive and active sources yields the best results.
Not checking for wildcard records: *.target.com causes false positives in brute forcing.
Ignoring subdomain takeovers: Dangling CNAME records are high-severity findings.
Best Practices
Related Tools
Related Articles
Summary
Subdomain enumeration combines passive sources (certificate logs, search engines, DNS datasets) with active techniques (brute forcing, zone transfers, web scraping). Discovering hidden subdomains reveals additional attack surface and potential takeover opportunities.