Subdomain Takeover Recon with Amass, Subfinder and Nuclei
A subdomain takeover happens when a DNS record, usually a CNAME, still points to a cloud service the organisation no longer controls, such as a deleted S3 bucket, Azure app or GitHub Pages site. Anyone who claims that resource can then serve content on the organisation's subdomain.
Topic: Security Tools, Authorized Labs & CTFs in Cybersecurity & Ethical Hacking · Tutorial
Also covers: Cloud & Container Security
Quick answer: A subdomain takeover happens when a DNS record, usually a CNAME, still points to a cloud service the organisation no longer controls, such as a deleted S3 bucket, Azure app or GitHub Pages site. Anyone who claims that resource can then serve content on the organisation's subdomain. To find these at scale, enumerate subdomains with Subfinder and Amass, resolve them with dnsx, probe live hosts with httpx, and match known takeover fingerprints with Nuclei's takeover templates. Only test domains you own or that are in an authorised bug bounty scope.
Key takeaways
- The root cause is a dangling DNS record left after a cloud resource was deleted.
- Passive enumeration is quiet; active brute forcing should stay within programme rules.
- Fingerprints from can-i-take-over-xyz and Nuclei templates tell you which services are claimable.
- Prove impact with minimal, harmless content, or just report the evidence, as the programme allows.
- Defenders prevent takeovers by deleting DNS records before deleting cloud resources.
Table of Contents
- What Is a Subdomain Takeover?
- What Should You Check Before Running Anything?
- What Does the Recon Pipeline Look Like?
- How Do You Confirm a Dangling CNAME by Hand?
- How Do You Run It on a Schedule?
- How Do You Verify and Report Safely?
- How Do Defenders Prevent Takeovers?
- How Do the Tools Compare?
- References
What Is a Subdomain Takeover?
Suppose shop.example.com has a CNAME to example-shop.azurewebsites.net. The team deletes the Azure app but forgets the DNS record. An attacker creates a new Azure app with the same name, and visitors to shop.example.com now see the attacker's page. That can be used for phishing, stealing cookies scoped to the parent domain, or bypassing content security policies. Microsoft's guidance on dangling DNS explains the risk for Azure, and the same applies to AWS, GitHub Pages, Heroku and many SaaS platforms.
What Should You Check Before Running Anything?
- The domain is yours, or listed in scope in a bug bounty or penetration test agreement.
- The programme allows automated scanning and states rate limits.
- The programme's rules on proving a takeover: some want only evidence, others allow a harmless proof page.
- In India, unauthorised access to computer resources can fall under the IT Act 2000, Sections 43 and 66.
What Does the Recon Pipeline Look Like?
Install the tools (Go 1.22 or later), following the ProjectDiscovery documentation and the OWASP Amass project:
go install -v github.com/projectdiscovery/subfinder/v2/cmd/subfinder@latest
go install -v github.com/projectdiscovery/dnsx/cmd/dnsx@latest
go install -v github.com/projectdiscovery/httpx/cmd/httpx@latest
go install -v github.com/projectdiscovery/nuclei/v3/cmd/nuclei@latest
go install -v github.com/owasp-amass/amass/v4/...@master
Then run the pipeline for one in-scope domain:
D=example.com
# 1. Passive enumeration from many sources
subfinder -d $D -all -silent -o subs_subfinder.txt
amass enum -passive -d $D -o subs_amass.txt
cat subs_*.txt | sort -u > subs.txt
# 2. Resolve, keeping CNAME targets
dnsx -l subs.txt -cname -resp -silent -o cnames.txt
# 3. Find live web hosts
httpx -l subs.txt -silent -status-code -title -o live.txt
# 4. Match takeover fingerprints
nuclei -update-templates
nuclei -l subs.txt -t http/takeovers/ -rate-limit 50 -o takeovers.txt
Feed all subdomains, not only live ones, to the takeover templates, because a dangling record often returns an error page that httpx may not treat as interesting.
How Do You Confirm a Dangling CNAME by Hand?
dig +short CNAME shop.example.com
# example-shop.azurewebsites.net.
dig +short example-shop.azurewebsites.net
# (no answer, or NXDOMAIN) -> the target no longer exists
curl -sI https://shop.example.com | head -1
Compare the response with the fingerprint for that service in can-i-take-over-xyz, which also records whether each service is currently claimable. Some providers now verify domain ownership, so a matching error page does not always mean a takeover is possible.
How Do You Run It on a Schedule?
New subdomains appear constantly, so repeat the scan and alert on new findings only:
#!/usr/bin/env bash
# recon.sh <domain> ; run daily from cron: 0 3 * * * /opt/recon/recon.sh example.com
D="$1"; OUT="/opt/recon/$D"; mkdir -p "$OUT"; cd "$OUT"
subfinder -d "$D" -all -silent > new_subs.txt
sort -u new_subs.txt -o new_subs.txt
touch seen_subs.txt
comm -13 seen_subs.txt new_subs.txt > fresh.txt
cat fresh.txt >> seen_subs.txt; sort -u seen_subs.txt -o seen_subs.txt
nuclei -l new_subs.txt -t http/takeovers/ -silent -rate-limit 50 > findings.txt
[ -s findings.txt ] && mail -s "Takeover findings for $D" [email protected] < findings.txt
How Do You Verify and Report Safely?
- Confirm the CNAME, the missing target and the service fingerprint.
- If the programme allows a proof, claim the resource and publish a plain page with a random string, nothing else. Never collect visitor data.
- Report the subdomain, DNS evidence, the service, steps to reproduce and the impact (for example, cookies scoped to
.example.com). - Release the claimed resource when the programme asks.
The OWASP testing guide describes the test in more detail.
How Do Defenders Prevent Takeovers?
- Remove the DNS record first, then delete the cloud resource.
- Keep a DNS inventory and scan your own zones with the same tools.
- Use provider protections such as Azure's domain verification and alias records.
- Avoid wildcard CNAMEs pointing at third-party platforms.
How Do the Tools Compare?
| Tool | Role | Notes |
|---|---|---|
| Subfinder | Passive subdomain discovery | Fast; add API keys for more sources |
| Amass | Discovery and mapping | Deeper, slower; graph database |
| dnsx | Bulk DNS resolution | Extracts CNAMEs |
| httpx | HTTP probing | Status, title, technology |
| Nuclei | Template scanning | http/takeovers templates |
Related: bug bounty tools and Recon-ng for OSINT. For guided practice, see WebAsha's ethical hacking courses.
References
Frequently Asked Questions
What's Your Reaction?
Like
0
Dislike
0
Love
0
Funny
0
Wow
0
Sad
0
Angry
0