Resolution, IP mapping and CDN filtering
- Noise
- Light active
- Reads
subs/all.txtorg/cidrs.txt- Writes
dns/resolved.txtdns/dnsx.jsondns/ips.txtdns/ips-origin.txt
Scope checkActive phase. Check the program policy first. Send traffic only to in-scope assets, at the rate the program allows.
Scanning the wrong IP wastes your time and can break program rules, so answer three questions for every name:
- Does it resolve at all?
- What does it point at: an A record, a CNAME to a vendor, or nothing?
- Is the IP the target’s own server, or a content delivery network (CDN) edge shared with thousands of other sites?
The answers decide what you scan in phase 5 and what you check for takeover in phase 7.
| Tool | Noise | Role |
|---|---|---|
| dnsx | Light active | Resolves lists fast, prints records, filters by response code, outputs JSON |
| mapcidr | Passive | Expands CIDRs to IPs, aggregates IPs to CIDRs. Local only |
| cdncheck | Passive | Flags IPs belonging to CDN, cloud and web application firewall (WAF) providers from published ranges |
| tlsx | Light active | Connects to TLS ports and reads certificate names (the Subject Alternative Name and Common Name fields) |
What these records prove
Section titled “What these records prove”CNAME to a vendor
Section titled “CNAME to a vendor”{ "host": "support.example.com", "cname": ["customer-care.zendesk.com"], "a": ["192.0.2.45"], "status_code": "NOERROR"}support.example.com is delegated to customer-care.zendesk.com. The record does not mean Zendesk still has a tenant for this name. If the account was closed and the CNAME was left behind, the name points at nothing you can use. The A record is Zendesk’s address, not Example Inc’s.
Anycast CDN address
Section titled “Anycast CDN address”{ "host": "store.example.com", "a": ["104.16.123.96", "104.16.124.96"], "status_code": "NOERROR"}Those addresses are a Cloudflare edge. The application is somewhere else. A port scan of 104.16.123.96 scans Cloudflare.
Certificate read straight from an origin IP
Section titled “Certificate read straight from an origin IP”IP: 203.0.113.45:443Subject: CN=example.comSubject Alternative Names: - example.com - origin-admin.example.com - internal-vpn.example.comIssuer: Let's EncryptThe host on 203.0.113.45:443 presented a certificate covering those names. It does not mean public DNS sends origin-admin.example.com to that address. The name can exist only on an internal resolver.
Trade-offs
Section titled “Trade-offs”tlsx across every address in an owned prefix finds hostnames that never appeared in public DNS. It also opens TCP/443 to every address in that prefix. On a narrow program, mine dns/ips-origin.txt and leave the empty parts of the prefix alone.
Convincing duds
Section titled “Convincing duds”CDN edge mistaken for an origin
Section titled “CDN edge mistaken for an origin”dev-assets.example.com resolves to 151.101.65.140. A full port scan finds 80 and 443 answering and everything else silent:
HTTP/1.1 503 Backend unavailableX-Served-By: cache-iad-kiad7000020-IADThat address is Fastly. The scan never reached the company.
Stale PTR
Section titled “Stale PTR”Reverse DNS on 203.0.113.0/24 prints:
203.0.113.88.in-addr.arpa. IN PTR legacy-payroll.example.com.Forward resolution of legacy-payroll.example.com is NXDOMAIN. The host is gone. The provider left the PTR in the reverse zone.
Dangling CNAME the vendor will not let you claim
Section titled “Dangling CNAME the vendor will not let you claim”status.example.com CNAMEs to example-status.freshstatus.io and the target name is NXDOMAIN. Freshstatus will not route a custom domain until a TXT record proves you control it. The dangling name is not a takeover.
Cloud IP that was given to someone else
Section titled “Cloud IP that was given to someone else”Old passive DNS says api-test.example.com pointed at 203.0.113.210. tlsx on that address now returns a certificate for a medical company. The VM was destroyed, the provider reused the address, and the DNS data is stale.
Step by step
Section titled “Step by step”-
Resolve and record. One pass, JSON output, A and CNAME records together.
Terminal window # Resolve every name, keep A, AAAA and CNAME answers as JSON linesdnsx -l subs/all.txt -a -aaaa -cname -resp -json -r ~/wordlists/resolvers-trusted.txt -silent -o dns/dnsx.jsonTerminal window # List names that resolvedjq -r '.host' dns/dnsx.json | sort -u > dns/resolved.txtTerminal window # List unique IPv4 addressesjq -r '.a[]?' dns/dnsx.json | sort -u > dns/ips.txtTerminal window # List unique IPv6 addressesjq -r '.aaaa[]?' dns/dnsx.json | sort -u > dns/ips6.txtA host that answers only on AAAA is easy to miss, and an IPv6 address often sits in front of a less guarded service than its IPv4 sibling. Keep
dns/ips6.txt, but scan it only if your scanning host and the program both allow IPv6. -
Find CNAMEs that point off-site. These feed the takeover checks.
Terminal window # Print host and CNAME target pairsjq -r 'select(.cname) | "\(.host) \(.cname | join(","))"' dns/dnsx.json > dns/cnames.txt -
Split CDN IPs from origin IPs. A Cloudflare or Akamai IP is the CDN’s server. Port scanning it scans the CDN, wastes time, and can break the program rules.
Terminal window # Show which IPs belong to a CDN, cloud or WAF, with the provider namecdncheck -i dns/ips.txt -resp -silent > dns/ips-providers.txtTerminal window # Keep only IPs that cdncheck does not recognize as CDN or WAFcdncheck -i dns/ips.txt -e -silent -o dns/ips-origin.txtCloud providers such as AWS show up as
cloudrather thancdn. An EC2 IP serving the target’s app is a real origin. Readdns/ips-providers.txtbefore you throw cloud IPs away.Terminal window # Drop RFC 1918, loopback and link-local addresses before scanninggrep -vE '^(10\.|127\.|169\.254\.|192\.168\.|172\.(1[6-9]|2[0-9]|3[01])\.)' dns/ips-origin.txt | sort -u -o dns/ips-origin.txtA private or loopback IP in your resolved set leaks internal addressing. Log it in your notes for later SSRF or pivot work, then strip it from your scan list because you cannot reach it from the internet.
-
Mine certificates on origin IPs and owned ranges. A server’s certificate often names hosts that DNS enumeration never found.
Terminal window # Read SAN and CN names from TLS on port 443 of every origin IPtlsx -l dns/ips-origin.txt -p 443 -san -cn -silent -resp-only | sort -u > dns/tls-names.txtTerminal window # Expand owned CIDRs to single IPs and mine their certificates toomapcidr -cl org/cidrs.txt -silent | tlsx -p 443 -san -cn -silent -resp-only | sort -u >> dns/tls-names.txtTerminal window # Add certificate names under the target domain to the master listgrep -E '(^|\.)example\.com$' dns/tls-names.txt | sed 's/^\*\.//' | anew subs/all.txt -
Find dead names that are still interesting. NXDOMAIN with a CNAME and SERVFAIL both deserve a look in phase 7.
Terminal window # Names whose lookup returns NXDOMAIN or SERVFAILdnsx -l subs/all.txt -rcode nxdomain,servfail -silent -o dns/dead.txt -
Summarize IPs by range. Helpful when you want to see which netblocks the target really uses.
Terminal window # Aggregate origin IPs into the smallest set of CIDRsmapcidr -cl dns/ips-origin.txt -aggregate -silent > dns/origin-cidrs.txt
Finding the origin behind a CDN
Section titled “Finding the origin behind a CDN”A site behind a CDN sometimes leaks its real IP. Reach the origin directly and a WAF that only sits on the CDN edge does nothing. Three leaks are worth checking on any host that resolves only to CDN addresses.
-
Old DNS records. The name may have pointed at the origin before the CDN was added. SecurityTrails keeps that history.
Terminal window # Historical A records for the host (needs a SecurityTrails key)curl -s -H "APIKEY: $SECURITYTRAILS_KEY" \"https://api.securitytrails.com/v1/history/app.example.com/dns/a" | jq -r '.records[].values[].ip' | sort -u -
Mail server IPs. Mail rarely goes through the web CDN, so the MX host often sits on the same network as the origin, or on the origin itself.
Terminal window # Resolve the mail servers; their IPs point at the target's real networkdig +short MX example.com | awk '{print $2}' | dnsx -a -resp-only -silent -
Certificate on the raw IP. Scan the owned ranges and read certificates. An origin that serves the site’s certificate on its bare IP gives itself away.
Terminal window # Find owned-range IPs whose certificate names the target domainmapcidr -cl org/cidrs.txt -silent | tlsx -san -cn -silent -resp-only | grep -i example.com
When a candidate origin turns up, confirm it serves the target before you trust it: request the site with the real Host header and compare the body.
# Ask the candidate origin for the site directly, bypassing the CDNcurl -sk -H "Host: app.example.com" https://203.0.113.45/ | headA body that matches the real site, from an IP the CDN does not own, is the origin. Test it the same way you test the main host.
How the output feeds the next phase
Section titled “How the output feeds the next phase”dns/ips-origin.txtis the port scan target list for phase 5.dns/resolved.txtis the HTTP probe list for phase 6.dns/cnames.txtanddns/dead.txtfeed takeover checks in phase 7.
Common mistakes
Section titled “Common mistakes”- Resolving with untrusted public resolvers in the final pass, which brings back poisoned answers.
- Port scanning CDN IPs.
- Dropping cloud IPs along with CDN IPs. Cloud VMs are often the most interesting hosts.
- Throwing away names that do not resolve. They are takeover candidates.
- CNAMEs to services such as
*.herokuapp.com,*.azurewebsites.net,*.s3.amazonaws.com,*.github.io - A records in private ranges (
10.,172.16.to172.31.,192.168.) that leak internal addressing - Certificate names for hosts you have not seen anywhere else
- Several names on one origin IP, suggesting virtual hosts worth fuzzing in phase 11
- Origin IPs for a site that otherwise sits behind a WAF
Next, scan the origin IPs in dns/ips-origin.txt for non-web services in phase 5.
Open local graph around this page
Linked from here
- CDN-detected hostnamesRecon Atlas
- Hostnames found only in crt.shRecon Atlas
- Wildcard DNS FilteringRecon Atlas
- Organization and asset discoveryRecon Atlas
- Subdomain enumeration, passiveRecon Atlas
- Subdomain enumeration, activeRecon Atlas
- Subdomain takeover checksRecon Atlas
- JavaScript analysisRecon Atlas
- Technology fingerprintingRecon Atlas
- OSINT and leaksRecon Atlas
Recon AtlasFor authorized testing only. Your scope is the map edge.