Finding a domain's subdomains from four free sources (and why one isn't enough)
Every subdomain finder you've used gets its data from roughly the same few places. The catch is that each of those places is down a fair amount of the time, and each one only sees part of the picture. Where sub
Every subdomain finder you've used gets its data from roughly the same few places. The catch is that each of those places is down a fair amount of the time, and each one only sees part of the picture.
Where subdomain lists come from
There are four free, passive sources worth knowing:
- crt.sh, a search over Certificate Transparency logs. Every public TLS certificate is logged, and the names on it show up here.
- Cert Spotter, another CT log search with its own API.
- HackerTarget, which keeps passive DNS records.
- The Internet Archive, whose CDX index lists every host name it has ever archived a page from.
None of them touch the target's servers, which is the point. You're reading public records, not scanning anything.
Trying it by hand
crt.sh has a JSON endpoint you can call with curl:
curl -s "https://crt.sh/?q=%25.python.org&output=json" \
| python -c "import json,sys; print('\n'.join(sorted({n for r in json.load(sys.stdin) for n in r['name_value'].splitlines()})))"
On a good day that prints a clean list (for python.org it starts with africa.python.org, analytics.python.org, api.wiki.python.org, blog-stage.python.org). On a bad day it returns a 502 or hangs for a minute, which happened to us often enough while testing that we stopped trusting any single source. The Internet Archive's CDX API has its own 503 days.
Why you want all four
The sources overlap less than you'd think. Certificates catch names that never served a public web page. The Archive catches old marketing subdomains that never had their own certificate because they sat behind a wildcard. Passive DNS catches mail and API hosts that neither of the others saw.
Certificates also remember names that no longer exist. A list from crt.sh alone will include staging servers that were shut down years ago, so you want a DNS check at the end to see which names still resolve.
Doing it in bulk
I built a Subdomain Finder on Apify that asks all four sources at the same time, merges the answers and checks each name through Cloudflare's public DNS resolver. Full disclosure: it's mine. Each row says which sources saw the name:
{
"domain": "apify.com",
"subdomain": "console.apify.com",
"resolves": true,
"ips": ["104.18.0.1"],
"sources": ["crt.sh", "Cert Spotter", "HackerTarget"],
"sources_found": 3
}
If one source is down during the run, you still get what the other three found, and the status message tells you which one missed. Turn on onlyLive and the dead names are dropped (and not charged). It costs $0.50 per 1,000 subdomains, so a domain with 50 subdomains is about three cents. Up to 500 domains go in one run.
What it won't find
No passive list is complete. A subdomain that never had a public certificate, never got archived and never showed up in passive DNS is invisible to all four sources. Internal hosts on private DNS won't show up either, which is how it should be.
And use it on domains you own or are allowed to research. Reading public records is legal almost everywhere. What you do with the list afterwards might not be.
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.