githubEdit

Subdomain Takeover

Active discovery

  • Sublistr

  • DNSRecon

  • Amass

  • Ffuf

ffuf -u <target> -w /path/to/wordlist.txt -H "Host: FUZZ.target.com" -fs <size-filter>

Explanation

  1. Domain name (sub.example.com) uses a CNAME record for another domain (sub.example.com CNAME anotherdomain.com).

  2. At some point, anotherdomain.com expires and is available for anyone's registration.

  3. Since the CNAME record is not removed from the DNS zone of example.com, anyone who records anotherdomain.com has full control over sub.example.com until the DNS record is present.

Subdomain Takeover is a malicious activity that the victim’s subdomain allows attackers to control and impersonate.

Automation

First we need to enumerate subdomains. See Subdomain Discoveryarrow-up-right for doing that. Then we can httpx for checking HTTP response status for each subdomain.

httpx

https://github.com/projectdiscovery/httpxarrow-up-right

Can I Take Over XYZ?

See https://github.com/EdOverflow/can-i-take-over-xyzarrow-up-right to check if the provider allows us to register subdomains.

CNAME Subdomain Takeover

1. Identify Misconfigurations for Subdomains

Check DNS records for identifying what’s on the destination of the subdomain.

If the HEADER status is NXDOMAIN error in the result, subdomain takeover might be possible. Also we can try to access them with web browser or command-line:

2. Spoof with the Subdomain

If a certain subdomain can be accessible but the error page of the specific provider (e.g. GitHub, Google Cloud, Wix, etc.) appeared, it means that the subdomain of the settings in the service provider was removed but the DNS record (e.g. A, CNAME) remains yet.

In short, attackers can spoof as a legitimate site by claiming this subdomain in the provider.

Here’s an abstract example:

  1. Login the target provider.

  2. Create a malicious website.

  3. Add the target subdomain (e.g. app.example.com) as custom domain in the setting page.

  4. If users visit app.example.com, they have now visited a malicious website created by an attacker.

NS Subdomain Takeover

It’s more dangerous If NS record is vulnerable because if the nameserver is taken over, an attacker can take full control of victim’s domains.

To gather NS records for the target domain, use dig command.

Next, check if the gathered domains can be purchased with domain name registrar like GoDaddy, NameCheap.

For example, search [abcde.org](http://abcde.org) in the domain search page of NameCheap. If this domain can be purchased, attackers can buy this domain then take control the name resolution of a victim by creating the custom nameserver which pointed to this domain.

References

Resources

Last updated