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.

Jul 26, 2025 - 17:22
Updated: 
108.3k

Security Tools, Authorized Labs & CTFs in Cybersecurity & Ethical Hacking · Tutorial

Cloud & Container Security

Subdomain Takeover Recon with Amass, Subfinder and Nuclei

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?

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?

  1. Confirm the CNAME, the missing target and the service fingerprint.
  2. If the programme allows a proof, claim the resource and publish a plain page with a random string, nothing else. Never collect visitor data.
  3. Report the subdomain, DNS evidence, the service, steps to reproduce and the impact (for example, cookies scoped to .example.com).
  4. 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?

ToolRoleNotes
SubfinderPassive subdomain discoveryFast; add API keys for more sources
AmassDiscovery and mappingDeeper, slower; graph database
dnsxBulk DNS resolutionExtracts CNAMEs
httpxHTTP probingStatus, title, technology
NucleiTemplate scanninghttp/takeovers templates

Related: bug bounty tools and Recon-ng for OSINT. For guided practice, see WebAsha's ethical hacking courses.

References

Frequently Asked Questions

A DNS record that still points to a deleted cloud resource, which anyone can then re-create and control.

Subfinder and Amass for discovery, dnsx and httpx for resolution and probing, and Nuclei takeover templates for fingerprints.

Only on domains you own or that are in an authorised bug bounty or testing scope, within the stated rules.

A CNAME record whose target no longer exists, such as a deleted storage bucket or app hostname.

No. Some providers now verify ownership, so check can-i-take-over-xyz for whether the service is still claimable.

Follow programme rules. If allowed, publish a harmless page with a random string and never collect visitor data.

Delete DNS records before cloud resources, keep a DNS inventory and scan their own zones regularly.

Daily or weekly for active scopes, alerting only on new subdomains and new findings.

What's Your Reaction?

Like Like 0
Dislike Dislike 0
Love Love 0
Funny Funny 0
Wow Wow 0
Sad Sad 0
Angry Angry 0
Vaishnavi

Vaishnavi is a skilled tech professional at the Ethical Hacking Training Institute in Pune, responsible for managing and optimizing the technical infrastructure that supports advanced cybersecurity education. With deep expertise in network security, backend operations, and system performance, she ensures that practical labs, online modules, and assessments run smoothly and securely. Her behind-the-scenes contributions play a vital role in delivering a seamless and secure learning experience for aspiring ethical hackers.