COMP-221 · Lesson 3 of 12 · 20 min

DNS, domain and certificate research

▶ Video coming soon A video version of this lesson is on the way.

By the end of September, Tobias had a page of hostnames scribbled from job postings, archived pages and code. Dario looked at it and said it was a good start and almost certainly incomplete. Organizations rarely know every name they have registered, every record they have published or every certificate they have been issued. The way to find out, he said, is to ask the systems that have to know: domain registries, the DNS itself and the certificate transparency logs.

This lesson covers domain registration data, DNS records and enumeration, and certificate transparency. It maps to objective 2.1 (DNS lookups and certificate transparency logs as information sources), objective 2.2 (DNS enumeration) and objective 2.4, which names WHOIS, nslookup and dig, DNSdumpster, Amass and Censys.io.

A seed box, prairiefold.example, with arrows to five sources: WHOIS or RDAP giving registrar, dates and name servers; DNS records giving A, AAAA, MX, NS, TXT, CNAME and SOA; certificate transparency logs giving every name on issued certificates; passive DNS and search engines giving names seen over time; and a zone transfer attempt, where refused is the expected result. All five feed a box labeled candidate names: resolve, dedupe, map to IPs, check against scope. A note says out-of-scope IPs are recorded, not tested.
Several independent sources feed one inventory of names, which is then resolved and checked against scope.

Registration data: WHOIS and RDAP

Every registered domain has registration data held by its registry and registrar: the registrar, creation and expiry dates, status codes, the authoritative name servers and, sometimes, contact details. WHOIS is the traditional protocol and command for looking this up. For generic top-level domains such as .com and .org, ICANN made the Registration Data Access Protocol (RDAP) the definitive source on January 28, 2025, and registries and registrars are no longer required to run the old WHOIS service. RDAP returns structured JSON over HTTPS, supports access controls and works better with internationalized names. Many tools and websites still call the lookup WHOIS even when they query RDAP behind the scenes, and the exam objective still lists WHOIS.

Contact details are now usually redacted for privacy, so registration data is less useful for finding people than it once was. It is still useful for organizations. The name servers show who hosts DNS. Creation and expiry dates distinguish an established domain from a recent registration. The registrar and registrant organization, where shown, can link several domains to the same owner. Look-alike domains registered recently by someone else can be reported to the client as possible phishing infrastructure.

Address space has registration data too. Regional internet registries, such as ARIN for Canada and the United States, record who holds each block of IP addresses. A lookup on Prairiefold's public addresses confirmed the block was assigned to the credit union, while the addresses hosting online banking were registered to the processor. That second lookup was the documentary evidence for keeping those addresses out of scope.

Useful fields in domain registration data.
Registration fieldWhat it tells a tester
RegistrarWhere the domain is managed; a target for account security recommendations
Creation and expiry datesAge of the domain; an expiring domain could be lost and re-registered by someone else
Name serversWho answers DNS for the domain: in-house, a hosting provider or a DNS service
Status codesWhether transfer and update locks are set
Registrant organization (if shown)Links between domains owned by the same organization

DNS records

The Domain Name System maps names to addresses and stores other information about a domain. Querying public DNS records through a public resolver is normally passive under the rules of engagement, because it is the same thing every visitor's browser does. Querying the client's own name servers directly with unusual requests, such as zone transfers, is active.

DNS record types used in reconnaissance.
Record typeHoldsWhy testers care
A and AAAAIPv4 and IPv6 addresses for a nameMaps names to addresses to check against scope; IPv6 hosts are often forgotten
CNAMEAn alias pointing to another nameReveals hosting providers and third-party services; dangling aliases are a risk
MXMail servers for the domainShows whether mail is in-house or with a cloud provider
NSAuthoritative name serversWhere to test zone transfer refusal
TXTFree text, including SPF, DMARC and domain verification tokensReveals email policy and which cloud services the domain is verified with
SOAStart of authority: primary server, administrator mailbox, serial numberPrimary name server and zone change patterns
PTRReverse mapping from address to nameNames for addresses discovered by scanning
SRVService locations, such as directory or VoIP servicesExposed service endpoints
CAAWhich certificate authorities may issue for the domainShows certificate policy; absence is a hardening recommendation

TXT records deserve a close read. Prairiefold's domain carried an SPF record listing Microsoft's mail service and one marketing email platform, a DMARC record in monitoring mode only (a policy of none), and verification tokens for Microsoft 365 and two other software services. The DMARC setting was a finding: it meant receiving servers were asked to report on, but not reject, mail that failed authentication, which makes spoofing the credit union's domain easier. Ironwhistle recommended moving to quarantine and then reject once reports showed legitimate senders were aligned.

Querying DNS: nslookup and dig

Two command-line tools are named in the objectives. nslookup is available on Windows and most other systems and works interactively or with arguments. dig (domain information groper), standard on Linux and macOS, gives more detailed output and is preferred by most testers because it shows the whole response: the question, answer, authority and additional sections, flags, and the time to live.

Common dig and nslookup queries. All names and addresses are documentation placeholders.
# Address records through the default resolver
dig prairiefold.example A +short

# Mail servers, name servers and text records
dig prairiefold.example MX +short
dig prairiefold.example NS +short
dig prairiefold.example TXT

# Ask a specific server (here, one of the client's name servers)
dig @ns1.prairiefold.example prairiefold.example SOA

# Reverse lookup for an address found during scanning
dig -x 203.0.113.25 +short

# The same lookups with nslookup
nslookup -type=MX prairiefold.example
nslookup 203.0.113.25
Reading a TXT answer: status NOERROR, three answers with a one-hour TTL, an SPF policy naming two senders and ending in a hard fail, and two service verification tokens. Provider names are replaced with placeholders.
dig prairiefold.example TXT
Output
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 40112
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1

;; QUESTION SECTION:
;prairiefold.example.        IN  TXT

;; ANSWER SECTION:
prairiefold.example.  3600  IN  TXT  "v=spf1 include:spf.mail-provider.example include:mktg-mailer.example -all"
prairiefold.example.  3600  IN  TXT  "ms-verification-token-placeholder"
prairiefold.example.  3600  IN  TXT  "saas-site-verification=placeholder"

;; Query time: 21 msec

Reading dig output well means checking the status first. NOERROR with answers means the name exists and has records of that type. NOERROR with no answers means the name exists but has no record of that type. NXDOMAIN means the name does not exist at all, which is itself useful when testing guesses. SERVFAIL means the resolver could not get an answer, often a configuration problem worth noting. The flags matter too: aa in a response means the answer came from an authoritative server, not a cache.

Zone transfers

A zone transfer (AXFR) copies an entire DNS zone from a primary name server to a secondary. If a name server allows transfers to anyone, a single request reveals every name in the zone, including internal names that were never meant to be public. Testing whether transfers are refused is a standard check, and an active one.

The expected result: the transfer is refused. Any server that returns the zone is a finding.
# Request a full zone transfer from each authoritative name server (active: in window only)
dig @ns1.prairiefold.example prairiefold.example AXFR
dig @ns2.prairiefold.example prairiefold.example AXFR
Output
; <<>> DiG <<>> @ns1.prairiefold.example prairiefold.example AXFR
;; global options: +cmd
; Transfer failed.

Both Prairiefold name servers refused. That was recorded as a positive observation; good reports say what was done well as well as what failed. The defense is to allow transfers only to named secondary servers, ideally authenticated with transaction signatures (TSIG), and to keep internal names in a separate internal zone rather than the public one.

Finding subdomains

Because zone transfers are usually refused, testers build the list of subdomains from many other sources and combine them.

Sources and techniques for subdomain enumeration.
TechniquePassive or activeNotes
Certificate transparency logsPassiveOften the single richest source; covered below
Passive DNS databasesPassiveHistorical resolutions collected by third parties; show names and past addresses
Search engines and archivesPassivesite: searches and archived links
DNSdumpsterPassiveA free web service that maps a domain's hosts, records and providers from collected data
Censys.ioPassiveSearch of internet-wide scan data, including certificates and hosts
AmassPassive by default, active modes availableCombines many data sources and can resolve, brute force and map relationships
Wordlist brute force against the client's DNSActiveResolves guessed names such as vpn, mail, test; noisy at scale
DNSSEC zone walkingActiveSigned zones using NSEC records can reveal adjacent names; NSEC3 makes this harder

Amass, maintained under the OWASP project, is the tool most often used to bring these together. Its enumeration mode queries many data sources passively and can optionally resolve names and try brute-force guesses. Its output is a list of names and, when resolution is enabled, their addresses and the networks they belong to. Like any multi-source tool, its results depend on which sources are configured, some of which need API keys.

Amass in passive and active modes. Option names have changed between major versions; check the current help.
# Passive enumeration only: no resolution or brute force against client servers
amass enum -passive -d prairiefold.example -o pf-amass-passive.txt

# In the testing window, active enumeration with resolution
amass enum -active -d prairiefold.example -o pf-amass-active.txt

Certificate transparency

Certificate transparency (CT) is a system of public, append-only logs in which certificate authorities record every publicly trusted TLS certificate they issue. Major browsers require certificates to appear in CT logs before trusting them, so almost every certificate a public website has used is logged. The original specification is RFC 6962. Because certificates list the names they cover, CT logs are a near-complete history of an organization's public hostnames, including ones for staging systems, VPNs and services nobody remembers.

Search services index the logs and let anyone search by domain. Querying them is entirely passive: the client's systems are never contacted. For Prairiefold, CT logs listed 38 distinct names. Most were expected. Several were not.

Selected names from Prairiefold's CT log results, with the documentation addresses used in this course.
Name from CT logsResolved toAssessment
www, mail, autodiscover203.0.113.25 and provider addressesExpected public services
staging-portal203.0.113.30In scope: the web app test target
vpn and vpn-old203.0.113.20 and 203.0.113.21vpn-old still resolves: hypothesis of a legacy VPN portal
sftp-statements203.0.113.40Matches the archived job posting: legacy file transfer server
banking198.51.100.40 (CNAME to processor)Out of scope; recorded, not tested
dev-reportsNXDOMAINCertificate issued in 2023; name no longer exists
A wildcard certificate covering every subdomainNot applicableUsed on several hosts; noted for key management review

The defensive use of CT is just as valuable. Organizations can monitor CT logs for certificates issued for their domains, which detects mis-issuance and look-alike certificates quickly. CAA records restrict which authorities may issue in the first place. Ironwhistle recommended both, and noted that wildcard certificates hide individual names from CT, which is convenient but means one stolen private key works on every host that shares it.

From names to a scoped inventory

Names on their own are not targets. Each must be resolved to an address, the address checked against the scope workbook and the registry record, and the result recorded. Names that resolve to providers, such as a content delivery network or a software-as-a-service platform, need particular care: the client may own the configuration but not the infrastructure. Lesson 9 covers cloud and third-party hosting in more detail.

Two patterns in the inventory deserve attention because they lead to vulnerabilities later. A dangling CNAME points to a third-party resource that no longer exists, such as a deleted cloud application. If someone else can claim that resource name, they can serve content on the client's subdomain, a problem known as subdomain takeover. Reconnaissance identifies the candidate; confirming and reporting it belongs to vulnerability work in COMP-222. Stale A records point to addresses the organization no longer controls, for example after leaving a hosting provider; scanning them could mean scanning someone else's server, so they are recorded and raised with the client rather than tested.

Worked problem

Resolving the CT list against scope

The scope covers 203.0.113.0/26. The CT list includes vpn-old resolving to 203.0.113.21, a name helpdesk with a CNAME to a hosted service desk provider, and an old name archive resolving to 203.0.113.90. What should Tobias record for each?

Show solution
  1. vpn-old: 203.0.113.21 is inside 203.0.113.0/26 (addresses .0 to .63). In scope; add to the active confirmation list.
  2. helpdesk: the CNAME points to a provider platform. The client's tenant configuration may be in scope for a web test, but the provider's infrastructure is not. Record it and ask the sponsor whether the provider allows testing.
  3. archive: 203.0.113.90 is outside the /26. Check registry data and ask the client whether the address is still theirs. Until confirmed in writing, do not test it.

Answer: One in-scope target, one third-party service needing written permission, and one possibly stale record to raise with the client.

Felix confirmed two days later that 203.0.113.90 had been returned to the provider in 2024 and the record should have been deleted. It went into the report as a stale record, with the recommendation to review DNS zones against asset inventory each quarter.

Common mistakes

  • MistakeAssuming WHOIS is the only source of registration data.

    InsteadUse RDAP, the definitive source for generic top-level domains since January 2025, and registry data for address blocks.

  • MistakeTreating a refused zone transfer as a wasted test.

    InsteadRecord it as a positive control; the report should say what was done well.

  • MistakeTesting every name from CT logs because it carries the client's domain.

    InsteadResolve each name and check the address and owner against scope first.

  • MistakeRunning wordlist brute force against the client's DNS during the passive phase.

    InsteadUse passive sources first; brute force is active and belongs in the window.

  • MistakeIgnoring TXT records.

    InsteadRead SPF, DMARC and verification tokens for email policy and cloud services.

Summary and key terms

  • Registration data shows registrar, dates, status and name servers; RDAP replaced WHOIS as the definitive source for gTLDs in January 2025.
  • DNS record types, especially A, AAAA, CNAME, MX, NS, TXT and SOA, reveal hosts, providers and policies.
  • dig shows the full response; check status, flags and TTL as well as answers.
  • Zone transfers should be refused; a successful AXFR is a finding.
  • Subdomains come from CT logs, passive DNS, search engines, DNSdumpster, Censys and Amass, and from brute force in the active window.
  • CT logs are a passive, near-complete history of publicly trusted certificate names.
  • Every name is resolved and checked against scope; dangling CNAMEs and stale records are raised, not tested blindly.
RDAP
Registration Data Access Protocol, the structured successor to WHOIS for domain registration data.
Zone transfer (AXFR)
A DNS operation that copies a whole zone from one name server to another.
Certificate transparency
Public append-only logs of issued TLS certificates.
Passive DNS
Historical records of DNS resolutions collected by third parties.
CAA record
A DNS record that lists which certificate authorities may issue certificates for a domain.
Dangling CNAME
An alias pointing to a third-party resource that no longer exists, which may allow subdomain takeover.
NXDOMAIN
A DNS response meaning the queried name does not exist.
DMARC
An email authentication policy published in DNS that tells receivers how to handle mail failing SPF and DKIM alignment.

Practice problems

Work each problem on paper first, then reveal the answer to check.

  1. A dig query returns status NOERROR with an empty answer section for an MX lookup. What does that mean?

    Show answer

    The name exists but has no MX records.

  2. Why are CT logs especially useful for passive reconnaissance?

    Show answer

    They list names on nearly every publicly trusted certificate, are public, and are queried without contacting the client.

  3. What two defensive measures should accompany a recommendation about CT?

    Show answer

    Monitor CT logs for certificates issued for the organization's domains, and publish CAA records restricting which authorities may issue.

Lesson quiz · 5 questions

Score 60% or more to complete this lesson.

Take the quiz