Subfinder : A Subdomain Discovery Tool To Find Valid Websites Subdomains

Subfinder is a subdomain discovery tool that discovers valid subdomains for websites by using passive online sources. It has a simple modular architecture and is optimized for speed. It is built for doing one thing only – passive subdomain enumeration, and it does that very well.

We have designed it to comply with all passive sources licenses, and usage restrictions, as well as maintained a consistently passive model to make it useful to both penetration testers and bug bounty hunters alike.

Features

  • Simple and modular code base making it easy to contribute.
  • Fast And Powerful Resolution and wildcard elimination module
  • Curated passive sources to maximize results (26 Sources as of now)
  • Multiple Output formats supported (Json, File, Stdout)
  • Optimized for speed, very fast and lightweight on resources
  • Stdin and stdout support for integrating in workflows

Also Read – MultiJuicer : Run Capture Flags & Security Trainings With OWASP Juice Shop

Usage

subfinder -h

This will display help for the tool. Here are all the switches it supports.

FlagDescriptionExample
-config stringConfiguration file for API Keys, etcsubfinder -config config.yaml
-dDomain to find subdomains forsubfinder -d uber.com
-dLFile containing list of domains to enumeratesubfinder -dL hackerone-hosts.txt
-exclude-sourcesList of sources to exclude from enumerationsubfinder -exclude-sources archiveis
-max-timeMinutes to wait for enumeration results (default 10)subfinder -max-time 1
-nCDon’t Use colors in outputsubfinder -nC
-nWRemove Wildcard & Dead Subdomains from outputsubfinder -nW
-oFile to write output to (optional)subfinder -o output.txt
-oDDirectory to write enumeration results to (optional)subfinder -oD ~/outputs
-oIWrite output in Host,IP formatsubfinder -oI
-oJWrite output in JSON lines Formatsubfinder -oJ
-rComma-separated list of resolvers to usesubfinder -r 1.1.1.1,1.0.0.1
-rLText file containing list of resolvers to usesubfinder -rL resolvers.txt
-silentShow only subdomains in outputsubfinder -silent
-sourcesComma separated list of sources to usesubfinder -sources shodan,censys
-tNumber of concurrent goroutines for resolving (default 10)subfinder -t 100
-timeoutSeconds to wait before timing out (default 30)subfinder -timeout 30
-vShow Verbose outputsubfinder -v
-versionShow current program versionsubfinder -version

Installation Instructions

Direct Installation

  • It requires go1.13+ to install successfully !

The installation is easy. You can download the pre-built binaries for different platforms from the Releases page. Extract them using tar, move it to your $PATH and you’re ready to go.

> tar -xzvf subfinder-linux-amd64.tar
> mv subfinder-linux-amd64 /usr/bin/subfinder
> subfinder

If you want to build it yourself, you can go get the repo

go get -v github.com/projectdiscovery/subfinder/cmd/subfinder

Upgrading

If you wish to upgrade the package you can use:

go get -u -v github.com/projectdiscovery/subfinder/cmd/subfinder

  • Running in a Docker Container

You can use the official dockerhub image at subfinder. Simply run –

> docker pull ice3man/subfinder

The above command will pull the latest tagged release from the dockerhub repository.

If you want to build the container yourself manually, git clone the repo, then build and run the following commands

  • Clone the repo using git clone https://github.com/projectdiscovery/subfinder.git
  • Build your docker container

docker build -t ice3man/subfinder

  • After building the container using either way, run the following –

docker run -it ice3man/subfinder

The above command is the same as running -h

For example, this runs the tool against uber.com and output the results to your host file system:

docker run -v $HOME/.config/subfinder:/root/.config/subfinder -it ice3man/subfinder -d uber.com > uber.com.txt

  • Post Installation Instructions

It will work after using the installation instructions however to configure it to work with certain services, you will need to have setup API keys. The following services do not work without an API key:

Theses values are stored in the $HOME/.config/subfinder/config.yaml file which will be created when you run the tool for the first time. The configuration file uses the YAML format. Multiple API keys can be specified for each of these services from which one of them will be used for enumeration.

For sources that require multiple keys, namely Censys, Passivetotal, they can be added by separating them via a colon (:).

An example config file –

resolvers:
– 1.1.1.1
– 1.0.0.1
sources:
– binaryedge
– bufferover
– censys
– passivetotal
– sitedossier
binaryedge:
– 0bf8919b-aab9-42e4-9574-d3b639324597
– ac244e2f-b635-4581-878a-33f4e79a2c13
censys:
– ac244e2f-b635-4581-878a-33f4e79a2c13:dd510d6e-1b6e-4655-83f6-f347b363def9
certspotter: []
passivetotal:

– sampleemail@user.com:sample_password
securitytrails: []
shodan: []

If you are using docker, you need to first create your directory structure holding the configuration file. After modifying the default config.yaml file, you can run:

> mkdir $HOME/.config/subfinder
> cp config.yaml $HOME/.config/subfinder/config.yaml
> nano $HOME/.config/subfinder/config.yaml

After that, you can pass it as a volume using the following sample command.

> docker run -v $HOME/.config/subfinder:/root/.config/subfinder -it ice3man/subfinder -d freelancer.com

Running

To run the tool on a target, just use the following command.

> subfinder -d freelancer.com

This will run the tool against freelancer.com. There are a number of configuration options that you can pass along with this command. The verbose switch (-v) can be used to display verbose information.

[CERTSPOTTER] www.fi.freelancer.com
[DNSDUMPSTER] hosting.freelancer.com
[DNSDUMPSTER] support.freelancer.com
[DNSDUMPSTER] accounts.freelancer.com
[DNSDUMPSTER] phabricator.freelancer.com
[DNSDUMPSTER] cdn1.freelancer.com
[DNSDUMPSTER] t1.freelancer.com
[DNSDUMPSTER] wdc.t1.freelancer.com
[DNSDUMPSTER] dal.t1.freelancer.com

The -o command can be used to specify an output file.

> subfinder -d freelancer.com -o output.txt

To run the tool on a list of domains, -dL option can be used. This requires a directory to write the output files. Subdomains for each domain from the list are written in a text file in the directory specified by the -oD flag with their name being the domain name.

> cat domains.txt
hackerone.com
google.com

>subfinder -dL domains.txt -oD ~/path/to/output
>ls ~/path/to/output

hackerone.com.txt
google.com.txt

If you want to save results to a single file while using a domain list, specify the -o flag with the name of the output file.

> cat domains.txt
hackerone.com
google.com

> subfinder -dL domains.txt -o ~/path/to/output.txt
> ls ~/path/to/

output.txt

You can also get output in json format using -oJ switch. This switch saves the output in the JSON lines format.

If you use the JSON format, or the Host:IP format, then it becomes mandatory for you to use the -nW format as resolving is essential for these output format. By default, resolving the found subdomains is disabled.

> subfinder -d hackerone.com -o output.json -oJ -nW
> cat output.json

{“host”:”www.hackerone.com”,”ip”:”104.16.99.52″}
{“host”:”mta-sts.hackerone.com”,”ip”:”185.199.108.153″} {“host”:”hackerone.com”,”ip”:”104.16.100.52″}
{“host”:”mta-sts.managed.hackerone.com”,”ip”:”185.199.110.153″}

The –silent switch can be used to show only subdomains found without any other info.

You can specify custom resolvers too.

> subfinder -d freelancer.com -o result.txt -nW -v -r 8.8.8.8,1.1.1.1
> subfinder -d freelancer.com -o result.txt -nW -v -rL resolvers.txt

The new highlight of this release is the addition of stdin/stdout features. Now, domains can be piped to it and enumeration can be ran on them. For example –

> echo “hackerone.com” | subfinder -v
> cat targets.txt | subfinder -v

The subdomains discovered can be piped to other tools too. For example, you can pipe the subdomains discovered by it to the awesome httprobe tool by @tomnomnom which will then find running http servers on the host.

> echo “hackerone.com” | subfinder -silent | httprobe

http://hackerone.com
http://www.hackerone.com
http://docs.hackerone.com
http://api.hackerone.com
https://docs.hackerone.com
http://mta-sts.managed.hackerone.com

R K

Recent Posts

Kali Linux 2024.4 Released, What’s New?

Kali Linux 2024.4, the final release of 2024, brings a wide range of updates and…

10 hours ago

Lifetime-Amsi-EtwPatch : Disabling PowerShell’s AMSI And ETW Protections

This Go program applies a lifetime patch to PowerShell to disable ETW (Event Tracing for…

11 hours ago

GPOHunter – Active Directory Group Policy Security Analyzer

GPOHunter is a comprehensive tool designed to analyze and identify security misconfigurations in Active Directory…

2 days ago

2024 MITRE ATT&CK Evaluation Results – Cynet Became a Leader With 100% Detection & Protection

Across small-to-medium enterprises (SMEs) and managed service providers (MSPs), the top priority for cybersecurity leaders…

5 days ago

SecHub : Streamlining Security Across Software Development Lifecycles

The free and open-source security platform SecHub, provides a central API to test software with…

1 week ago

Hawker : The Comprehensive OSINT Toolkit For Cybersecurity Professionals

Don't worry if there are any bugs in the tool, we will try to fix…

1 week ago