Subdomain Enumeration
Attack Chain Position
graph LR
A[Reconnaissance] --> B[Passive Recon]
B --> C[Subdomain Enumeration]
C --> D[Active Recon]
D --> E[Service Detection]
E --> F[Vulnerability Research]
F --> G[Exploitation]
style C fill:#f9d56e,stroke:#c79632,stroke-width:3px
Where we are: Subdomain enumeration discovers all subdomains associated with a target domain. Each subdomain represents a potential attack surface with its own services, vulnerabilities, and misconfigurations.
Why Subdomain Enumeration Matters
The Value of Subdomains
Subdomains are often overlooked but can provide significant attack opportunities:
| Subdomain Type | Example | Attack Value |
|---|---|---|
| Development | dev.example.com |
Often less secured, debug enabled, outdated software |
| Staging | staging.example.com |
May have test credentials, exposed databases |
| Testing | test.example.com |
Similar to staging, often misconfigured |
| Admin | admin.example.com |
Administrative interfaces, potential privilege escalation |
| API | api.example.com |
API endpoints, potential for API abuse |
mail.example.com |
Email servers, potential for email attacks | |
| VPN | vpn.example.com |
Remote access, potential for credential attacks |
| Git | git.example.com |
Source code exposure, credential leakage |
| Jenkins | jenkins.example.com |
CI/CD pipelines, potential RCE |
| Backup | backup.example.com |
Backup data, potential data exposure |
| Old/Legacy | old.example.com |
Outdated software, unpatched vulnerabilities |
| Internal | internal.example.com |
Internal tools, potential for lateral movement |
Real-World Examples
| Company | Subdomain | Vulnerability | Impact |
|---|---|---|---|
| Example Corp | dev.example.com |
Exposed Git repository | Source code disclosure |
| Example Inc | jenkins.example.com |
Jenkins RCE (CVE-2017-1000353) | Remote code execution |
| Example Ltd | mail.example.com |
Exchange vulnerability | Email compromise |
| Example Org | admin.example.com |
Default credentials | Administrative access |
| Example Co | api.example.com |
API misconfiguration | Data breach |
Subdomain Attack Surface Expansion
graph TD
A[example.com] --> B[www.example.com]
A --> C[mail.example.com]
A --> D[dev.example.com]
A --> E[api.example.com]
A --> F[admin.example.com]
A --> G[test.example.com]
A --> H[staging.example.com]
A --> I[vpn.example.com]
A --> J[git.example.com]
A --> K[jenkins.example.com]
A --> L[backup.example.com]
A --> M[old.example.com]
style A fill:#f9d56e,stroke:#c79632,stroke-width:3px
style D fill:#ff6b6b,stroke:#c92a2a,stroke-width:2px
style F fill:#ff6b6b,stroke:#c92a2a,stroke-width:2px
style K fill:#ff6b6b,stroke:#c92a2a,stroke-width:2px
Red nodes represent high-value targets that are commonly vulnerable.
Subdomain Enumeration Workflow
Complete Workflow Diagram
flowchart TD
A[Start Subdomain Enumeration] --> B[Passive Enumeration]
B --> C[subfinder]
B --> D[Amass Passive]
B --> E[assetfinder]
B --> F[crt.sh]
B --> G[Google Dorking]
B --> H[Shodan/Censys]
C --> I[Merge Results]
D --> I
E --> I
F --> I
G --> I
H --> I
I --> J[Remove Duplicates]
J --> K[Active Enumeration]
K --> L[ffuf Subdomain Bruteforce]
K --> M[gobuster DNS]
K --> N[massdns Resolution]
K --> O[nmap dns-brute]
L --> P[Merge Active Results]
M --> P
N --> P
O --> P
P --> Q[Validate Subdomains]
Q --> R[HTTP Status Checking]
R --> S[Virtual Host Discovery]
S --> T[Subdomain Takeover Check]
T --> U[Document Results]
U --> V[Proceed to Service Detection]
Phase Overview
| Phase | Tools | Time | Output |
|---|---|---|---|
| Passive Enumeration | subfinder, amass, assetfinder, crt.sh | 10-20 min | Raw subdomain list |
| Active Enumeration | ffuf, gobuster, massdns | 15-30 min | Resolved subdomains |
| Validation | curl, httpx, nuclei | 10-20 min | Valid subdomains |
| Analysis | Manual review, documentation | 10-15 min | Final report |
Passive Techniques
Passive enumeration gathers subdomains without directly querying the target. This is stealthy and fast.
subfinder
subfinder is a fast passive subdomain enumeration tool that queries multiple data sources.
Installation
# Install via go
go install -v github.com/projectdiscovery/subfinder/v2/cmd/subfinder@latest
# Install via package manager (Kali)
apt install subfinder
# Verify installation
subfinder version
Basic Usage
# Basic subdomain enumeration
subfinder -d example.com
# Save results to file
subfinder -d example.com -o subdomains.txt
# Verbose output
subfinder -d example.com -v
# JSON output
subfinder -d example.com -json -o subdomains.json
Advanced Options
# Use specific sources
subfinder -d example.com -sources "alienvault,anubis,certspotter,censys,chaos,crtsh,digitorus,github,hackertarget,hunterio,intelx,netlas,passivetotal,riddler,securitytrails,shodan,threatbook,virustotal,waybackarchive,zoomeye"
# Use all sources
subfinder -d example.com -all
# Rate limit requests
subfinder -d example.com -rate-limit 10
# Thread count
subfinder -d example.com -t 10
# Timeout
subfinder -d example.com -timeout 30
# Skip certificate transparency
subfinder -d example.com -no-cert
# Use provided API configs
subfinder -d example.com -config /path/to/config.yaml
# Domain list from file
subfinder -l domains.txt -o results.txt
# Recursive subdomain enumeration
subfinder -d example.com -recursive -depth 2
# Silent mode (only subdomains)
subfinder -d example.com -silent
All subfinder Options Reference
| Option | Description | Example |
|---|---|---|
-d, --domain |
Target domain | -d example.com |
-dL, --list |
List of domains | -dL domains.txt |
-o, --output |
Output file | -o subdomains.txt |
-oJ, --output-json |
JSON output file | -oJ subdomains.json |
-r, --resolvers |
Custom resolvers | -r resolvers.txt |
-config |
Configuration file | -config config.yaml |
-sources |
Specific sources | -sources "shodan,crtsh" |
-all |
Use all sources | -all |
-v, --verbose |
Verbose output | -v |
-silent |
Silent mode | -silent |
-json |
JSON output | -json |
-t, --threads |
Thread count | -t 10 |
-timeout |
Request timeout | -timeout 30 |
-rate-limit |
Rate limit | -rate-limit 10 |
-nW, --match-wordlist |
Match subdomains | -nW words.txt |
-fW, --filter-wordlist |
Filter subdomains | -fW filter.txt |
-no-color |
No color output | -no-color |
-version |
Show version | -version |
-recursive |
Recursive enumeration | -recursive |
-depth |
Recursive depth | -depth 2 |
-no-cert |
Skip CT sources | -no-cert |
-collect |
Collection mode | -collect |
API Configuration
subfinder can use API keys for enhanced results:
# config.yaml
shodan:
- api-key: YOUR_SHODAN_API_KEY
censys:
- api-id: YOUR_CENSYS_API_ID
api-secret: YOUR_CENSYS_API_SECRET
securitytrails:
- api-key: YOUR_SECURITYTRAILS_API_KEY
fullhunt:
- api-key: YOUR_FULLHUNT_API_KEY
hackertarget:
- api-key: YOUR_HACKERTARGET_API_KEY
virustotal:
- api-key: YOUR_VIRUSTOTAL_API_KEY
threatbook:
- api-key: YOUR_THREATBOOK_API_KEY
intelx:
- api-key: YOUR_INTELX_API_KEY
binaryedge:
- api-key: YOUR_BINARYEDGE_API_KEY
# Use the config
subfinder -d example.com -config config.yaml
Amass Passive Mode
Amass is a comprehensive subdomain enumeration tool by OWASP.
Installation
# Install via go
go install -v github.com/owasp-amass/amass/v3/...@latest
# Install via package manager (Kali)
apt install amass
# Verify installation
amass version
Passive Mode
# Basic passive enumeration
amass enum -passive -d example.com -o subdomains.txt
# Passive with specific sources
amass enum -passive -d example.com -src shodan,crt,alienvault -o subdomains.txt
# Passive with API keys
amass enum -passive -d example.com -df domains.txt -o subdomains.txt
# Passive with timeout
amass enum -passive -d example.com -timeout 30 -o subdomains.txt
All Amass Modes
# Passive mode only
amass enum -passive -d example.com -o passive.txt
# Active mode only (DNS brute force + resolution)
amass enum -active -d example.com -o active.txt
# Default mode (passive + active)
amass enum -d example.com -o all.txt
# Intel mode (gather intelligence about domain)
amass intel -d example.com -o intel.txt
# DNS resolution mode
amass resolve -d example.com -o resolved.txt
# Graph mode (visualize relationships)
amass graph -d example.com -o graph.csv
# Track mode (monitor changes over time)
amass track -d example.com -interval 3600
Advanced Amass Options
# With API configuration
amass enum -d example.com -config /path/to/config.yaml
# With data directory
amass enum -d example.com -dir /path/to/data
# With specific resolvers
amass enum -d example.com -r resolvers.txt
# With wordlist
amass enum -d example.com -w /path/to/wordlist.txt
# With rate limiting
amass enum -d example.com -max-dns-queries 1000
# With thread count
amass enum -d example.com -threads 10
# With timeout
amass enum -d example.com -timeout 30
# With domain list
amass enum -df domains.txt -o results.txt
# With output formats
amass enum -d example.com -json -o results.json
amass enum -d example.com -csv -o results.csv
# With interface specification
amass enum -d example.com -iface eth0
# With proxy
amass enum -d example.com -proxy http://127.0.0.1:8080
Amass Configuration File
# config.yaml
srcs:
alienvault: true
baidu: true
binaryedge: true
bufferover: true
builtwith: true
c99: true
censys: true
certspotter: true
chaos: true
chinaz: true
commoncrawl: true
crt: true
dnscommon: true
duckduckgo: true
fullhunt: true
github: true
gitlab: true
hacker_target: true
hunter: true
intelx: true
netlas: true
securitytrails: true
shodan: true
spyse: true
threatbook: true
virustotal: true
wayback_archive: true
whois: true
zoomeye: true
resolvers:
- 1.1.1.1
- 1.0.0.1
- 8.8.8.8
- 8.8.4.4
- 9.9.9.9
- 208.67.222.222
- 208.67.220.220
assetfinder
assetfinder is a simple tool for finding assets associated with a domain.
# Install
go install github.com/tomnomnom/assetfinder@latest
# Basic usage
assetfinder example.com
# Quiet mode
assetfinder --quiet example.com
# JSON output
assetfinder --json example.com
# Save to file
assetfinder example.com > assets.txt
sublist3r
sublist3r is a Python tool for enumerating subdomains.
# Install
pip3 install sublist3r
# Basic usage
sublist3r -d example.com
# Save results
sublist3r -d example.com -o subdomains.txt
# Use specific engines
sublist3r -d example.com -e Google,Bing,Yahoo
# Brute force mode
sublist3r -d example.com -b
# With wordlist
sublist3r -d example.com -w /path/to/wordlist.txt
# Threads
sublist3r -d example.com -t 10
# Port scan discovered subdomains
sublist3r -d example.com -p 80,443,8080
crt.sh (Certificate Transparency)
Certificate Transparency logs can reveal subdomains through SSL/TLS certificates.
# Using curl
curl -s "https://crt.sh/?q=%25.example.com&output=json" | jq -r '.[].name_value' | sort -u
# Using Python
python3 -c "
import requests
import json
domain = 'example.com'
url = f'https://crt.sh/?q=%25.{domain}&output=json'
response = requests.get(url)
data = response.json()
subdomains = set()
for entry in data:
name = entry.get('name_value', '')
if name:
subdomains.add(name.lower())
for sub in sorted(subdomains):
print(sub)
"
# Save to file
curl -s "https://crt.sh/?q=%25.example.com&output=json" | jq -r '.[].name_value' | sort -u > crt_subdomains.txt
Google Dorking for Subdomains
# Using Google site: operator
site:example.com
# Using Google inurl: operator
inurl:example.com
# Using Google intitle: operator
intitle:"example.com"
# Specific subdomain patterns
site:*.example.com
site:dev.example.com
site:admin.example.com
site:api.example.com
# Using Google with filetype
site:example.com filetype:pdf
site:example.com filetype:doc
site:example.com filetype:xls
# Using Google with intext
site:example.com intext:"password"
site:example.com intext:"admin"
site:example.com intext:"login"
SecurityTrails
# Using API
curl -H "APIKEY: YOUR_API_KEY" \
"https://api.securitytrails.com/v1/domain/example.com/subdomains" | \
jq -r '.subdomains[]' | \
while read sub; do echo "$sub.example.com"; done | \
sort -u
# Save to file
curl -H "APIKEY: YOUR_API_KEY" \
"https://api.securitytrails.com/v1/domain/example.com/subdomains" | \
jq -r '.subdomains[]' | \
while read sub; do echo "$sub.example.com"; done | \
sort -u > securitytrails_subdomains.txt
VirusTotal
# Using API
curl -s "https://www.virustotal.com/api/v3/domains/example.com/subdomains" \
-H "x-apikey: YOUR_API_KEY" | \
jq -r '.data[].id' | \
sort -u
# Save to file
curl -s "https://www.virustotal.com/api/v3/domains/example.com/subdomains" \
-H "x-apikey: YOUR_API_KEY" | \
jq -r '.data[].id' | \
sort -u > virustotal_subdomains.txt
Active Techniques
Active enumeration involves directly querying DNS servers to discover subdomains.
ffuf for Subdomains
ffuf is a fast web fuzzer that can also be used for subdomain enumeration.
# Basic subdomain enumeration
ffuf -u https://FUZZ.example.com -w /usr/share/seclists/Discovery/DNS/subdomains-top10000.txt -mc 200,301,302
# With wordlist
ffuf -u https://FUZZ.example.com -w /path/to/wordlist.txt -mc 200,301,302
# With rate limiting
ffuf -u https://FUZZ.example.com -w wordlist.txt -mc 200 -rate 10
# With threads
ffuf -u https://FUZZ.example.com -w wordlist.txt -mc 200 -t 10
# With timeout
ffuf -u https://FUZZ.example.com -w wordlist.txt -mc 200 -timeout 5
# Filter by size
ffuf -u https://FUZZ.example.com -w wordlist.txt -fs 0
# Filter by word count
ffuf -u https://FUZZ.example.com -w wordlist.txt -fw 0
# Save results
ffuf -u https://FUZZ.example.com -w wordlist.txt -mc 200 -o results.json -of json
# Recursion
ffuf -u https://FUZZ.example.com -w wordlist.txt -mc 200 -recursion -recursion-depth 2
# With headers
ffuf -u https://FUZZ.example.com -w wordlist.txt -mc 200 -H "User-Agent: Mozilla/5.0"
# DNS mode
ffuf -u https://FUZZ.example.com -w wordlist.txt -dns -mc 200
gobuster DNS Mode
gobuster has a dedicated DNS mode for subdomain enumeration.
# Basic DNS enumeration
gobuster dns -d example.com -w /usr/share/seclists/Discovery/DNS/subdomains-top10000.txt
# With threads
gobuster dns -d example.com -w wordlist.txt -t 10
# With timeout
gobuster dns -d example.com -w wordlist.txt -z
# With specific resolver
gobuster dns -d example.com -w wordlist.txt -r 8.8.8.8
# With multiple resolvers
gobuster dns -d example.com -w wordlist.txt -r 8.8.8.8,1.1.1.1,9.9.9.9
# Save results
gobuster dns -d example.com -w wordlist.txt -o results.txt
# JSON output
gobuster dns -d example.com -w wordlist.txt -o results.json -oJ
# With delay
gobuster dns -d example.com -w wordlist.txt -d 1s
# With max errors
gobuster dns -d example.com -w wordlist.txt -m 100
# Recursive mode
gobuster dns -d example.com -w wordlist.txt -r
# With wildcard handling
gobuster dns -d example.com -w wordlist.txt -w
massdns
massdns is a high-performance DNS stub resolver for massive DNS operations.
# Install
git clone https://github.com/blechschmidt/massdns.git
cd massdns
make
sudo make install
# Prepare input file
cat wordlist.txt | sed 's/$/.example.com/' > queries.txt
# Run massdns
./bin/massdns -r resolvers.txt -t A -o S -w results.txt queries.txt
# With specific options
./bin/massdns -r resolvers.txt -t A -o F -w results.txt -q queries.txt
# With timeout
./bin/massdns -r resolvers.txt -t A -o S -w results.txt -q queries.txt -T 10
# With retries
./bin/massdns -r resolvers.txt -t A -o S -w results.txt -q queries.txt -i 3
# Parse results
./bin/massdns -r resolvers.txt -t A -o S -w results.txt queries.txt
cat results.txt | grep '\(A\)' | awk '{print $1}' | sed 's/\.$//' | sort -u
# Save resolved subdomains
cat results.txt | grep '\(A\)' | awk '{print $1}' | sed 's/\.$//' | sort -u > resolved_subdomains.txt
nmap dns-brute
Nmap can also be used for DNS brute-forcing.
# Basic DNS brute force
nmap --script dns-brute -sL example.com
# With wordlist
nmap --script dns-brute --script-args "dns-brute.hostlist=/path/to/wordlist.txt" -sL example.com
# With Seclists
nmap --script dns-brute --script-args "dns-brute.hostlist=/usr/share/seclists/Discovery/DNS/subdomains-top10000.txt" -sL example.com
# With specific domain
nmap --script dns-brute --script-args "dns-brute.base=example.com" -sL example.com
# With output
nmap --script dns-brute -sL example.com -oN dns_brute_results.txt
Essential Tools Deep Dive
subfinder Complete Reference
# Installation methods
go install -v github.com/projectdiscovery/subfinder/v2/cmd/subfinder@latest
apt install subfinder # Kali
# All options
subfinder -h
# Basic enumeration
subfinder -d example.com
# With all sources
subfinder -d example.com -all
# With specific sources
subfinder -d example.com -sources "shodan,crtsh,virustotal"
# With API config
subfinder -d example.com -config config.yaml
# Recursive enumeration
subfinder -d example.com -recursive -depth 2
# With domain list
subfinder -l domains.txt -o results.txt
# JSON output
subfinder -d example.com -json -o results.json
# Silent mode
subfinder -d example.com -silent
# With rate limiting
subfinder -d example.com -rate-limit 10
# With threads
subfinder -d example.com -t 20
# With timeout
subfinder -d example.com -timeout 30
# Skip certificate transparency
subfinder -d example.com -no-cert
# Match wordlist
subfinder -d example.com -nW match.txt
# Filter wordlist
subfinder -d example.com -fW filter.txt
# No color output
subfinder -d example.com -no-color
# Verbose output
subfinder -d example.com -v
# Collection mode
subfinder -d example.com -collect
Amass Complete Reference
# Installation
go install -v github.com/owasp-amass/amass/v3/...@latest
apt install amass # Kali
# All modes
amass enum -d example.com # Default (passive + active)
amass enum -passive -d example.com # Passive only
amass enum -active -d example.com # Active only
amass intel -d example.com # Intelligence gathering
amass resolve -d example.com # DNS resolution
amass graph -d example.com # Graph visualization
amass track -d example.com # Change tracking
# With options
amass enum -d example.com -o results.txt
amass enum -d example.com -json -o results.json
amass enum -d example.com -csv -o results.csv
amass enum -d example.com -config config.yaml
amass enum -d example.com -dir /path/to/data
amass enum -d example.com -r resolvers.txt
amass enum -d example.com -w wordlist.txt
amass enum -d example.com -max-dns-queries 1000
amass enum -d example.com -threads 10
amass enum -d example.com -timeout 30
amass enum -df domains.txt -o results.txt
amass enum -d example.com -iface eth0
amass enum -d example.com -proxy http://127.0.0.1:8080
# Intel mode options
amass intel -d example.com -o intel.txt
amass intel -d example.com -df domains.txt
amass intel -d example.com -addr 1.2.3.4
amass intel -d example.com -asn 15169
amass intel -d example.com -cidr 1.2.3.0/24
# Track mode options
amass track -d example.com -interval 3600
amass track -d example.com -interval 3600 -dir /path/to/data
gobuster DNS Mode Complete Reference
# Installation
apt install gobuster # Kali
go install github.com/OJ/gobuster/v3@latest
# DNS mode options
gobuster dns -d example.com -w wordlist.txt
gobuster dns -d example.com -w wordlist.txt -t 10
gobuster dns -d example.com -w wordlist.txt -z
gobuster dns -d example.com -w wordlist.txt -r 8.8.8.8
gobuster dns -d example.com -w wordlist.txt -r 8.8.8.8,1.1.1.1
gobuster dns -d example.com -w wordlist.txt -o results.txt
gobuster dns -d example.com -w wordlist.txt -oJ
gobuster dns -d example.com -w wordlist.txt -d 1s
gobuster dns -d example.com -w wordlist.txt -m 100
gobuster dns -d example.com -w wordlist.txt -r
gobuster dns -d example.com -w wordlist.txt -w
# All gobuster modes
gobuster dir -u http://example.com -w wordlist.txt # Directory brute force
gobuster dns -d example.com -w wordlist.txt # DNS brute force
gobuster vhost -u http://example.com -w wordlist.txt # Virtual host discovery
gobuster s3 -w wordlist.txt # AWS S3 bucket enumeration
gobuster gcs -w wordlist.txt # GCS bucket enumeration
gobuster azure -w wordlist.txt # Azure blob enumeration
Subdomain Wordlists
Essential Wordlists
| Wordlist | Location | Size | Description |
|---|---|---|---|
| subdomains-top10000.txt | /usr/share/seclists/Discovery/DNS/ |
10,000 | Top 10,000 subdomains |
| subdomains-top100000.txt | /usr/share/seclists/Discovery/DNS/ |
100,000 | Top 100,000 subdomains |
| all.txt | /usr/share/seclists/Discovery/DNS/ |
73,000+ | Comprehensive list |
| combined.txt | /usr/share/seclists/Discovery/DNS/ |
50,000+ | Combined sources |
| norm.txt | /usr/share/seclists/Discovery/DNS/ |
40,000+ | Normalized list |
| full.txt | /usr/share/seclists/Discovery/DNS/ |
100,000+ | Full list |
Custom Wordlist Generation
# Generate custom wordlist from passive results
cat passive_results.txt | sort -u > custom_wordlist.txt
# Generate wordlist from permutations
cat base_words.txt | while read word; do
echo "$word"
echo "test-$word"
echo "dev-$word"
echo "staging-$word"
echo "old-$word"
echo "new-$word"
echo "$word-test"
echo "$word-dev"
echo "$word-staging"
echo "$word-old"
echo "$word-new"
echo "www-$word"
echo "api-$word"
echo "admin-$word"
echo "$word-api"
echo "$word-admin"
done > permutations.txt
# Using altdns for permutations
pip3 install altdns
# Generate permutations
altdns -i subdomains.txt -o permutations.txt -w /usr/share/seclists/Discovery/DNS/altdns-default-words.txt
# Resolve permutations
altdns -i permutations.txt -o resolved_permutations.txt -r -w /usr/share/seclists/Discovery/DNS/altdns-default-words.txt
altdns
altdns generates permutations of subdomains and resolves them.
# Install
pip3 install altdns
# Generate permutations
altdns -i subdomains.txt -o permutations.txt -w words.txt
# Resolve permutations
altdns -i permutations.txt -o resolved.txt -r
# With custom words
altdns -i subdomains.txt -o permutations.txt -w custom_words.txt -r
# With JSON output
altdns -i subdomains.txt -o permutations.json -json -w words.txt -r
# With specific resolvers
altdns -i subdomains.txt -o resolved.txt -r -w words.txt --resolver 8.8.8.8
# Default wordlist
altdns -i subdomains.txt -o permutations.txt -r
Validating Subdomains
HTTP Status Checking
# Using curl
for sub in $(cat subdomains.txt); do
status=$(curl -s -o /dev/null -w "%{http_code}" "http://$sub" --max-time 5 2>/dev/null)
if [ "$status" != "000" ]; then
echo "$sub - $status"
fi
done
# Using httpx
httpx -l subdomains.txt -o http_results.txt
# With status code filtering
httpx -l subdomains.txt -mc 200,301,302,403 -o valid_subdomains.txt
# With title extraction
httpx -l subdomains.txt -title -o http_results.txt
# With tech detection
httpx -l subdomains.txt -tech-detect -o http_results.txt
# With port scanning
httpx -l subdomains.txt -ports 80,443,8080,8443,3000,8000 -o http_results.txt
# With threads
httpx -l subdomains.txt -threads 100 -o http_results.txt
# With timeout
httpx -l subdomains.txt -timeout 5 -o http_results.txt
# With follow redirects
httpx -l subdomains.txt -follow-redirects -o http_results.txt
# With websocket check
httpx -l subdomains.txt -websocket -o http_results.txt
# With certificate info
httpx -l subdomains.txt -cdn -o http_results.txt
# With response body
httpx -l subdomains.txt -body -o http_results.txt
Virtual Host Discovery
# Using gobuster vhost
gobuster vhost -u http://example.com -w /usr/share/seclists/Discovery/DNS/subdomains-top10000.txt
# With threads
gobuster vhost -u http://example.com -w wordlist.txt -t 10
# With output
gobuster vhost -u http://example.com -w wordlist.txt -o vhost_results.txt
# Using ffuf
ffuf -u http://example.com -H "Host: FUZZ.example.com" -w wordlist.txt -mc 200
# With filter
ffuf -u http://example.com -H "Host: FUZZ.example.com" -w wordlist.txt -fs 0
# With threads
ffuf -u http://example.com -H "Host: FUZZ.example.com" -w wordlist.txt -mc 200 -t 10
Subdomain Takeover Detection
# Using subover
git clone https://github.com/Ice3man543/subover.git
cd subover
python3 subover.py -d example.com
# Using subdomain-takeover (ProjectDiscovery)
git clone https://github.com/projectdiscovery/subdomain-takeover.git
cd subdomain-takeover
go build
./subdomain-takeover -l subdomains.txt
# Using nucleii templates
nuclei -l subdomains.txt -t templates/mitre/techniques/T1190/ -tags takeover
# Manual check
for sub in $(cat subdomains.txt); do
echo "Checking $sub..."
curl -s -o /dev/null -w "%{http_code}" "http://$sub" --max-time 5 2>/dev/null
echo ""
done
OSCP-Specific Subdomain Strategies
OSCP Lab Considerations
| Consideration | Description |
|---|---|
| Internal Networks | OSCP labs use internal networks, subdomain enumeration may be limited |
| DNS Configuration | Lab DNS may not have all subdomains configured |
| Target Scope | Focus on the target IP/domain provided in the exam |
| Time Management | Don’t spend too much time on subdomain enumeration |
| Pro Labs | Pro Labs may have more complex subdomain structures |
OSCP Workflow
# Step 1: Quick passive enumeration
subfinder -d target.com -silent > passive_subdomains.txt
# Step 2: Active enumeration (if DNS allows)
gobuster dns -d target.com -w /usr/share/seclists/Discovery/DNS/subdomains-top10000.txt -o active_subdomains.txt
# Step 3: Merge and deduplicate
cat passive_subdomains.txt active_subdomains.txt | sort -u > all_subdomains.txt
# Step 4: Validate with HTTP
httpx -l all_subdomains.txt -mc 200,301,302,403 -o valid_subdomains.txt
# Step 5: Document results
echo "=== Subdomain Enumeration Results ===" > subdomain_report.txt
echo "Date: $(date)" >> subdomain_report.txt
echo "Target: target.com" >> subdomain_report.txt
echo "" >> subdomain_report.txt
echo "Total subdomains found: $(wc -l < all_subdomains.txt)" >> subdomain_report.txt
echo "Valid HTTP subdomains: $(wc -l < valid_subdomains.txt)" >> subdomain_report.txt
echo "" >> subdomain_report.txt
cat valid_subdomains.txt >> subdomain_report.txt
Common OSCP Subdomain Patterns
| Pattern | Example | Likelihood |
|---|---|---|
| www | www.target.com |
Very High |
mail.target.com |
High | |
| ftp | ftp.target.com |
High |
| dev | dev.target.com |
Medium |
| test | test.target.com |
Medium |
| staging | staging.target.com |
Medium |
| admin | admin.target.com |
Medium |
| api | api.target.com |
Medium |
| vpn | vpn.target.com |
Low |
| git | git.target.com |
Low |
| jenkins | jenkins.target.com |
Low |
| backup | backup.target.com |
Low |
OSCP Exam Tips
Subdomain Enumeration Tips
-
Start with passive tools: subfinder and assetfinder are fast and stealthy.
-
Use multiple sources: Different tools find different subdomains.
-
Don’t over-enumerate: In OSCP, focus on the target scope provided.
-
Validate findings: Not all discovered subdomains are valid or accessible.
-
Document everything: Record all subdomains and their status codes.
-
Check for takeover: Subdomain takeover can provide initial access.
-
Use httpx for validation: Fast and comprehensive HTTP checking.
-
Look for virtual hosts: Virtual host misconfigurations can expose internal services.
-
Check for old subdomains: Old/legacy subdomains often have outdated software.
-
Time management: Don’t spend more than 15-20 minutes on subdomain enumeration.
Time Management
| Activity | Recommended Time |
|---|---|
| Passive enumeration | 5-10 minutes |
| Active enumeration | 5-10 minutes |
| Validation | 5-10 minutes |
| Documentation | 2-5 minutes |
| Total | 17-35 minutes |
Common Pitfalls
- Spending too much time: Subdomain enumeration is just one part of recon
- Ignoring validation: Not all discovered subdomains are valid
- Missing takeover opportunities: Always check for subdomain takeover
- Not documenting: Record all findings for later reference
- Over-relying on one tool: Use multiple tools for comprehensive coverage
Summary
Subdomain enumeration is a critical reconnaissance technique that expands the attack surface by discovering all subdomains associated with a target. By combining:
- Passive techniques (subfinder, Amass, assetfinder, crt.sh)
- Active techniques (ffuf, gobuster DNS, massdns)
- Validation (httpx, curl, virtual host discovery)
- Advanced analysis (subdomain takeover, custom wordlists)
You can comprehensively discover and validate all subdomains, identifying potential attack vectors that might be missed by focusing on the main domain alone.