Skip to content

Repository files navigation

subfinder

Fast passive subdomain enumeration tool.

FeaturesInstallUsageAPI SetupLibraryJoin Discord


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. subfinder is built for doing one thing only - passive subdomain enumeration, and it does that very well.

We have designed subfinder 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

subfinder

  • Fast and powerful resolution and wildcard elimination module
  • Curated passive sources to maximize results
  • Multiple Output formats supported (Json, File, Stdout)
  • Optimized for speed, very fast and lightweight on resources
  • STDIN/OUT support for integrating in workflows

Usage

subfinder -h

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

Flags:
INPUT:
-d, -domain string[] domains to find subdomains for-dL, -list string file containing list of domains for subdomain discoverySOURCE:
-s, -sources string[] sources to use for discovery (-s crtsh,github)-recursive use only recursive sources-all Use all sources (slow) for enumeration-es, -exclude-sources string[] sources to exclude from enumeration (-es archiveis,zoomeye)RATE-LIMIT:
-rl, -rate-limit int maximum number of http requests to send per second-t int number of concurrent goroutines for resolving (-active only) (default 10)OUTPUT:
-o, -output string file to write output to-oJ, -json write output in JSONL(ines) format-oD, -output-dir string directory to write output (-dL only)-cs, -collect-sources include all sources in the output (-json only)-oI, -ip include host IP in output (-active only)CONFIGURATION:
-config string flag config file (default "$HOME/.config/subfinder/config.yaml")-pc, -provider-config string provider config file (default "$HOME/.config/subfinder/provider-config.yaml")-r string[] comma separated list of resolvers to use-rL, -rlist string file containing list of resolvers to use-nW, -active display active subdomains only-proxy string http proxy to use with subfinderDEBUG:
-ls list all available sources-silent show only subdomains in output-version show version of subfinder-v show verbose output-nc, -no-color disable color in outputOPTIMIZATION:
-timeout int seconds to wait before timing out (default 30)-max-time int minutes to wait for enumeration results (default 10)

Installation

Subfinder requires go1.17 to install successfully. Run the following command to get the repo -

go install -v github.com/projectdiscovery/subfinder/v2/cmd/subfinder@latest

Post Installation Instructions

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

Binaryedge, C99, Certspotter, Chinaz, Censys, Chaos, DnsDB, Fofa, Github, Intelx, Passivetotal, Robtex, SecurityTrails, Shodan, Spyse, Threatbook, Virustotal, Zoomeye

Theses values are stored in the $HOME/.config/subfinder/provider-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 provider config file -

binaryedge:
- 0bf8919b-aab9-42e4-9574-d3b639324597
- ac244e2f-b635-4581-878a-33f4e79a2c13censys:
- ac244e2f-b635-4581-878a-33f4e79a2c13:dd510d6e-1b6e-4655-83f6-f347b363def9certspotter: []passivetotal:
- sample-email@user.com:sample_passwordsecuritytrails: []shodan:
- AAAAClP1bJJSRMEYJazgwhJKrggRwKAgithub:
- ghp_lkyJGU3jv1xmwk4SDXavrLDJ4dl2pSJMzj4X
- ghp_gkUuhkIYdQPj13ifH4KA3cXRn8JD2lqir2d4

Running Subfinder

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

subfinder -d hackerone.com __ _____ __  _______ __/ /_ / __(_)___ ____/ /__ _____ / ___/ / / / __ \/ /_/ / __ \/ __ / _ \/ ___/ (__ ) /_/ / /_/ / __/ / / / / /_/ / __/ / /____/\__,_/_.___/_/ /_/_/ /_/\__,_/\___/_/ v2.4.9 projectdiscovery.ioUse with caution. You are responsible for your actionsDevelopers assume no liability and are not responsible for any misuse or damage.By using subfinder, you also agree to the terms of the APIs used.[INF] Enumerating subdomains for hackerone.comwww.hackerone.comsupport.hackerone.comlinks.hackerone.comapi.hackerone.como1.email.hackerone.comgo.hackerone.com3d.hackerone.comresources.hackerone.coma.ns.hackerone.comb.ns.hackerone.commta-sts.hackerone.comdocs.hackerone.commta-sts.forwarding.hackerone.comgslink.hackerone.comhackerone.cominfo.hackerone.commta-sts.managed.hackerone.comevents.hackerone.com[INF] Found 18 subdomains for hackerone.com in 3 seconds 672 milliseconds

The subdomains discovered can be piped to other tools too. For example, you can pipe the subdomains discovered by subfinder to httpx httpx which will then find running http servers on the host.

echo hackerone.com | subfinder -silent | httpx -silenthttp://hackerone.comhttp://www.hackerone.comhttp://docs.hackerone.comhttp://api.hackerone.comhttps://docs.hackerone.comhttp://mta-sts.managed.hackerone.com

Subfinder with docker

Pull the latest tagged subfinder docker image:

docker pull projectdiscovery/subfinder:latest

Running subfinder using docker image:

docker -t projectdiscovery/subfinder:latest -d hackerone.com

Running subfinder using docker image with local config file:

docker run -v $HOME/.config/subfinder:/root/.config/subfinder -t projectdiscovery/subfinder -d hackerone.com

Subfinder Go library

Usage example:

package main
import (
"bytes""context""fmt""io""log""github.com/projectdiscovery/subfinder/v2/pkg/passive""github.com/projectdiscovery/subfinder/v2/pkg/resolve""github.com/projectdiscovery/subfinder/v2/pkg/runner"
)
funcmain() {
runnerInstance, err:=runner.NewRunner(&runner.Options{
Threads: 10, // Thread controls the number of threads to use for active enumerationsTimeout: 30, // Timeout is the seconds to wait for sources to respondMaxEnumerationTime: 10, // MaxEnumerationTime is the maximum amount of time in mins to wait for enumerationResolvers: resolve.DefaultResolvers, // Use the default list of resolvers by marshaling it to the configSources: passive.DefaultSources, // Use the default list of passive sourcesAllSources: passive.DefaultAllSources, // Use the default list of all passive sourcesRecursive: passive.DefaultRecursiveSources,	// Use the default list of recursive sourcesProviders: &runner.Providers{}, // Use empty api keys for all providers
})
buf:= bytes.Buffer{}
err=runnerInstance.EnumerateSingleDomain(context.Background(), "projectdiscovery.io", []io.Writer{&buf})
iferr!=nil {
log.Fatal(err)
}
data, err:=io.ReadAll(&buf)
iferr!=nil {
log.Fatal(err)
}
fmt.Printf("%s", data)
}

Resources

License

subfinder is made with 🖤 by the projectdiscovery team. Community contributions have made the project what it is. See the Thanks.md file for more details.

Read the disclaimer for usage at DISCLAIMER.md and contact us for any API removal.

About

Subfinder is a subdomain discovery tool that discovers valid subdomains for websites. Designed as a passive framework to be useful for bug bounties and safe for penetration testing.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages