How to Map Your External Attack Surface (Step by Step)
To map your external attack surface, start from the domains you know, expand through public sources (certificate transparency logs, passive DNS and web archives), resolve and probe what you find, and record each asset with an owner in one inventory. The whole attack surface discovery process below uses free, read-only tools and takes an afternoon for a typical startup. Each step lists the exact commands, what to look for in the output, and the mistakes that cause gaps.
Before you start: only run active steps (resolving, HTTP probing, port checks) against domains and IPs your organization owns or is explicitly authorized to test. Passive lookups touch third-party data sources, not your targets, but anything that sends traffic to a host needs authorization.
What you need for attack surface discovery
- A Unix shell with
curl,digandjq - subfinder, dnsx and httpx from ProjectDiscovery (all Go binaries)
- A spreadsheet or CSV for the inventory
One gotcha: Python's httpx HTTP library also installs a command called httpx. If httpx -h shows a Python client instead of ProjectDiscovery's flags, call the Go binary by its full path (for example ~/go/bin/httpx).
Step 1: Write down your seeds
Discovery is only as good as its starting points. List:
- Every registered root domain, including old brand names, country domains, marketing campaign domains and acquired companies.
- Cloud accounts (AWS, GCP, Azure), plus hosting providers like Vercel, Netlify, Heroku and Fly.
- Known IP ranges or static IPs.
- Third-party services on your domains: status pages, help desks, docs platforms, email senders.
Your DNS records reveal more of this than you'd expect:
dig +short NS example.com
dig +short MX example.com
dig +short TXT example.com
SPF include: entries and domain-verification TXT records often list SaaS providers you forgot you signed up for. Each one is a vendor holding some piece of your surface.
Step 2: Pull every hostname from certificate transparency logs
Publicly trusted TLS certificates are logged in certificate transparency (CT) logs, so any hostname that ever got a certificate is searchable, even if it was never linked anywhere. crt.sh exposes this as JSON with the output=json parameter:
curl -s 'https://crt.sh/?q=%25.example.com&output=json' \
| jq -r '.[].name_value' \
| tr 'A-Z' 'a-z' \
| sed 's/^\*\.//' \
| sort -u > ct.txt
wc -l ct.txt
%25 is a URL-encoded %, crt.sh's wildcard. The sed strips wildcard prefixes so *.app.example.com becomes app.example.com. crt.sh is a free public service and frequently returns errors or times out on large domains, so retry, or let a tool like subfinder query it for you.
What to look for: environment names (staging, dev, uat, preview), vendor names, and anything you don't recognize. CT logs also include long-dead hostnames, which matter because their DNS records may still exist.
Step 3: Run passive subdomain enumeration
subfinder queries many passive sources (CT logs, passive DNS, search engines and threat intel APIs) in one pass. It's built for "passive subdomain enumeration" and doesn't touch your hosts:
subfinder -d example.com -all -silent -o subfinder.txt
-all uses every source (slower, more complete). Adding free API keys for the sources that support them, in subfinder's provider config, noticeably increases results. For several root domains, put them in a file and use -dL domains.txt.
Merge everything:
cat ct.txt subfinder.txt | sort -u > all-subs.txt
Step 4: Check historical URLs
Web archives preserve endpoints that may still be live: old API versions, admin paths, file uploads. The Wayback Machine's CDX API can return every archived URL for a domain and its subdomains:
curl -s 'https://web.archive.org/cdx/search/cdx?url=example.com&matchType=domain&fl=original&collapse=urlkey' \
> archive-urls.txt
grep -Ei '/api/|/v[0-9]+/|admin|\.env|\.bak|swagger|graphql' archive-urls.txt | sort -u
Pull any new hostnames from this output into all-subs.txt too. For deeper API-focused discovery, see how to find shadow and undocumented APIs.
Step 5: Resolve everything with DNS
From here on you're sending queries about your own hosts. Plain dig works for spot checks:
dig +short A staging.example.com
dig +short CNAME docs.example.com
For the whole list, dnsx is faster:
dnsx -l all-subs.txt -a -cname -resp -silent -o resolved.txt
Sort results into three buckets:
| DNS result | Meaning | Action |
|---|---|---|
| A/AAAA record to an IP you recognize | Live asset in your infrastructure | Continue to Step 6 |
| CNAME to a cloud or SaaS provider | Hosted elsewhere | Confirm the target resource still exists |
| No answer / NXDOMAIN | Dead name (for now) | Keep in inventory as historical; watch for reappearance |
Step 6: Hunt for dangling CNAMEs
A CNAME that points at a deleted cloud resource is the classic subdomain takeover setup: someone else creates a resource with the same name and serves content on your subdomain. Find CNAMEs whose targets no longer resolve:
while read -r h; do
cname=$(dig +short CNAME "$h" @1.1.1.1)
[ -z "$cname" ] && continue
status=$(dig "$h" A @1.1.1.1 +noall +comments | grep -o 'status: [A-Z]*')
echo "$h -> $cname ($status)"
done < all-subs.txt | grep NXDOMAIN
Querying a public resolver (@1.1.1.1) avoids ISP resolvers that rewrite NXDOMAIN responses. This only catches one pattern, though. Some providers keep resolving and return a provider-specific error page instead. The community-maintained can-i-take-over-xyz list documents these fingerprints, such as S3's "The specified bucket does not exist", along with which services are actually claimable. Our subdomain takeover checker guide walks through verifying them, and the subdomain takeover scanner checks them automatically.
Fix: delete the DNS record, or recreate the resource you own. Then make "delete DNS before deleting the resource" part of your decommissioning process.
Step 7: Probe live web services
Find out what's actually serving HTTP and what it's running:
httpx -l all-subs.txt -sc -title -td -server -fr -silent -o web.txt
Flags: -sc status code, -title page title, -td technology detection, -server web server header, -fr follow redirects.
What to look for:
- Login pages for internal tools (Jenkins, Grafana, Kibana, phpMyAdmin) on public hostnames
- Default pages like "Welcome to nginx" or "It works!", which usually mean forgotten or half-configured servers
- Old framework or CMS versions (look them up against public CVEs)
- 401/403 responses on interesting hostnames, which mean something is there even if it's protected
- Staging sites with the same title as production
Step 8: Check exposed ports without scanning
You can see much of your port exposure through internet scan databases without sending a single packet. CISA's exposure reduction guidance recommends routinely searching tools like Shodan and Censys for your IP ranges, using queries like net:X.X.X.X/Y (Shodan) or host.ip: "X.X.X.X/Y" (Censys). It lists, at minimum, ports such as 22 (SSH), 23 (Telnet), 3389 (RDP), 5900 (VNC) and 5938 (TeamViewer) to check.
Anything beyond 80/443 on a web host deserves a question: does this need to be reachable from the internet? Databases (5432, 3306, 27017, 6379) should essentially never be. For a direct check of hosts you own, a network audit runs port scanning with service fingerprinting.
Step 9: Look past DNS
Some exposure never gets a hostname:
- Cloud storage: list your buckets and check public access directly in the console or CLI. A cloud misconfiguration audit flags public resources across AWS, Azure and GCP.
- JavaScript bundles: your production JS often references internal API hosts and sometimes ships keys.
- Direct cloud IPs: load balancers and VMs with public IPs but no DNS name. Pull these from your cloud provider's API, not from DNS.
Step 10: Build the inventory
Put everything into one table. Minimum columns:
| Column | Example |
|---|---|
| Asset | staging-api.example.com |
| Type | Subdomain / IP / bucket / SaaS |
| Resolves to | 203.0.113.10 or CNAME target |
| Technology | nginx, Next.js |
| Environment | prod / staging / dev / unknown |
| Owner | A named person |
| Should be public? | Yes / No / Unsure |
| Last seen | Date |
| Open issues | Link to ticket |
Every row marked "No" or "Unsure" under Should be public? is a remediation candidate. Every row with no owner gets one this week or gets scheduled for shutdown. That's the core of attack surface management: the map is only useful if someone keeps it current.
Keep your attack surface map current
A manual map is out of date the next time someone deploys. Re-run Steps 2 to 7 on a schedule (weekly is reasonable) and diff the results against last week's files. New lines are your alerts. Or automate it: EASM tooling exists to run this pipeline continuously.
SecurityInfinity's recon agents run this discovery automatically on domains you've verified via DNS TXT record or work email. They pivot from discovered hosts into read-only web, network and secrets checks, and attach evidence and exact remediation to each finding. Start a free scan on one verified domain to compare its results against your manual map.
Frequently asked questions
What is attack surface mapping?
Attack surface mapping is building a complete inventory of everything your organization exposes to the internet: domains, subdomains, IPs, web apps, APIs, cloud storage and third-party services. It combines passive discovery from public data with active checks of what's actually live. The output is an asset list with owners and exposure notes.
Is subdomain enumeration legal?
Passive enumeration, such as querying certificate transparency logs or passive DNS databases, reads public data and doesn't touch the target. Active steps like probing hosts or scanning ports send traffic to systems, so only run them against assets you own or are explicitly authorized to test. When in doubt, get written authorization first.
What is the best free tool for attack surface discovery?
There isn't a single best tool. crt.sh for certificate transparency, subfinder for passive enumeration, dnsx for resolution and httpx for HTTP probing are a strong free stack. Combining sources matters more than picking one tool, because each source finds hostnames the others miss.
How do I find all subdomains of my domain?
Combine certificate transparency results (crt.sh), passive enumeration (subfinder with API keys), historical archives and your own DNS zone files, then deduplicate. Your DNS provider's zone export is the ground truth for current records. Public sources add the names that aren't there anymore but may still matter.
How often should I re-map my attack surface?
Re-run discovery at least weekly and diff the results, or automate it so new subdomains and certificates trigger alerts. Teams that deploy several times a day benefit from continuous monitoring, since a forgotten preview environment can appear and be exposed within hours.