Let's Talk

List Subdomains From Google By Recursive Negation

Karthik Devan   |   20261203

Listing subdomains for a given domain is a routine part of the security analysis and attack surface mapping. There are several ways to do it, and one of them is to simply check a search engine’s index. But how does one get all the unique subdomains a search engine (say Google) knows? That’s exactly what I’ll show you in this blog. I also made a command line tool to do this.

The Method

I’ll use the domain netflix.com for demonstration. The core idea is to use the site: filter in a search, to include a wildcard subdomain (*.netflix.com) and iteratively keep excluding specific subdomains that you discover as you go. You iterate until Google runs out of results. First, let me illustrate in plain English.

Hey Google, what pages do you have from <something>.netflix.com?

Google shows me 10 pages from 4 different subdomains

Alright, what pages do you have from <something>.netflix.com that are not from these 4 subdomains?

Google shows me 10 pages from 4 more different subdomains

Alright, what pages do you have from <something>.netflix.com that are not from these 8 subdomains?

Google shows me 7 pages from 3 more different subdomains

Alright, what pages do you have from <something>.netflix.com that are not from these 11 subdomains?

Google says my search did not match any documents

We’ve hit the end. We now have 11 subdomains, apart from the root netflix.com itself. Now, the actual queries used:

site:*.netflix.com

site:*.netflix.com -site:www.netflix.com -site:about.netflix.com -site:help.netflix.com -site:jobs.netflix.com

site:*.netflix.com -site:www.netflix.com -site:about.netflix.com -site:help.netflix.com -site:jobs.netflix.com -site:ir.netflix.com -site:www3.stage.netflix.com -site:www2.stage.netflix.com -site:media.netflix.com

site:*.netflix.com -site:www.netflix.com -site:about.netflix.com -site:help.netflix.com -site:jobs.netflix.com -site:ir.netflix.com -site:www3.stage.netflix.com -site:www2.stage.netflix.com -site:media.netflix.com -site:techblog.netflix.com -site:research.netflix.com -site:qr.netflix.com

The Tool

I made subrng to semi-automate this using Playwright. The only thing you have to do is solve CAPTCHAs, if they show up.

Install it with uv:

uv tool install subrng

Use it:

subrng netflix.com

It’s free and open source!

Let's Talk!

What do you think about this blog? Mail me at krtdvn@gmail.com