Skip to content
Tutorials Center
My learning

Topics

Lesson 12 of 38 ยท Reconnaissance

DNS and Subdomain Reconnaissance

Learn how testers enumerate subdomains with certificate logs, brute-force wordlists and DNS records, how to read dig output and how defenders find dangling DNS entries.

DNS maps names to addresses, so it is the phone book of an organization's internet presence. For a tester, a subdomain list is often the best map of the attack surface: www is well protected, but jenkins, old-portal or test-api might not be. This lesson covers how subdomains are discovered, how to read DNS answers, and how to turn the results into a clean, scoped target list. For a first look at record types and certificate transparency, see DNS, WHOIS and Certificate Intelligence; this lesson focuses on the enumeration workflow.

Where subdomain names come from

Technique Passive or active How it works
Certificate transparency logs Passive Search every certificate issued for the domain
Passive DNS databases Passive Historical records collected by third parties
Search engines and archives Passive site: queries and old pages
Linked pages and JavaScript Active (light) Names appear in the site's own source
Dictionary brute force Active Try thousands of likely names, such as dev, vpn, mail
Zone transfer (AXFR) Active Ask a name server to hand over the zone; works only on misconfigured servers
Reverse DNS sweeps Active Ask for the name of each address in a range

Passive sources return names that existed at some point. Active methods confirm what resolves right now. Good recon uses both: passive to build the candidate list, active to confirm.

Find, resolve, verify

Collect Logs, archives, wordlists.
Resolve Does the name answer?
Verify scope Does the client own it?

Three steps, in this order.

1 / 2

Reading DNS answers

A lookup returns records. Read-only example with the real dig format and invented data:

Terminal
dig app.example.test
TEXT
;; ANSWER SECTION:
app.example.test.     300   IN   CNAME   app-prod.cloudhost.test.
app-prod.cloudhost.test. 60 IN   A       198.51.100.20

;; Query time: 24 msec
;; SERVER: 192.0.2.53#53(192.0.2.53)

Here app is an alias. The final address belongs to a hosting provider, which raises a scope question: the name is the client's, but the server may be shared. A name that returns NXDOMAIN does not exist; SERVFAIL means the lookup failed, often because of a broken delegation.

Wildcards and false positives

Some domains answer every name with the same address: anything.example.test resolves. Brute force then reports thousands of false hits. Test first with a random nonsense name such as zq81xk93.example.test. If it resolves, treat that address as the wildcard and discard matches that return it.

Subdomain takeover candidates

A dangling alias points at a service that no longer exists: a deleted cloud storage bucket, an unpublished hosting page, a cancelled SaaS account. Someone else could register that target and serve content under the client's domain. When you see an alias to a cloud provider, check whether the destination still answers with an "unclaimed" or "not found" page. Report it with high priority, because takeovers enable phishing and cookie theft on a trusted name.

Stand-in: resolve candidates against a fake zone

Real brute force needs a network. The first example simulates it: a wordlist is tested against an invented zone, and wildcard behavior is detected first.

Python Brute-force subdomains against a simulated zone

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The second example scans a set of CNAME records for takeover risk. A real check would query the destination; here a set of known-dead provider names plays that role.

Python Find dangling aliases

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Mapping names to scope

When you have a list, group it by address and owner. Ask who owns each address block: use WHOIS or the regional internet registry to see whether it belongs to the client, a cloud provider or a third party. Names pointing into a provider's range are in scope only if the client's account controls the resource. Keep the two lists described in Reconnaissance: Passive and Active.

Defender takeaways

  • Keep a DNS inventory and delete records when services are retired.
  • Restrict zone transfers to your own secondary name servers.
  • Monitor certificate transparency for certificates you did not request.
  • Avoid wildcard records unless needed, and avoid revealing internal names in public DNS (split-horizon DNS keeps internal names inside).
  • Enable DNSSEC where your operations can support it, to protect against forged answers.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Why test a random nonsense subdomain before brute forcing?

    If a nonsense name resolves, the domain has a wildcard, and every guessed name will appear to exist.
  2. 2. What is a dangling CNAME?

    The alias remains while its destination is gone, so someone else may claim the destination.
  3. 3. Which source provides subdomain names without contacting the target?

    Certificate logs are third-party data. The other methods send queries to the target's infrastructure.
  4. 4. A found subdomain resolves into a cloud provider's address range. What should you check?

    Provider infrastructure is shared. Only the client's own resources are in scope.

Summary

  • Subdomains come from passive sources (certificate logs, archives) and active ones (brute force, zone transfer, reverse DNS).
  • Detect wildcard DNS first, and discard results that match the wildcard address.
  • Dangling aliases to deleted cloud resources are takeover risks and deserve high priority.
  • Group results by address and owner, and keep unconfirmed names out of active testing.
  • Defenders keep DNS inventories, restrict zone transfers and watch certificate logs.

Next: Web Fingerprinting and Technology Discovery