subfinder/README.md

300 lines
12 KiB
Markdown
Raw Normal View History

2019-12-05 13:06:56 +00:00
<h1 align="left">
2019-12-05 13:09:09 +00:00
<img src="static/subfinder-logo.png" alt="subfinder" width="170px"></a>
2019-12-05 13:06:56 +00:00
<br>
</h1>
2018-04-06 23:45:23 +00:00
[![License](https://img.shields.io/badge/license-MIT-_red.svg)](https://opensource.org/licenses/MIT)
2019-12-05 10:41:06 +00:00
[![Go Report Card](https://goreportcard.com/badge/github.com/projectdiscovery/subfinder)](https://goreportcard.com/report/github.com/projectdiscovery/subfinder)
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/projectdiscovery/subfinder/issues)
2020-08-18 05:44:10 +00:00
[![GitHub Release](https://img.shields.io/github/release/projectdiscovery/subfinder)](https://github.com/projectdiscovery/subfinder/releases)
[![Follow on Twitter](https://img.shields.io/twitter/follow/pdiscoveryio.svg?logo=twitter)](https://twitter.com/pdiscoveryio)
[![Docker Images](https://img.shields.io/docker/pulls/projectdiscovery/subfinder.svg)](https://hub.docker.com/r/projectdiscovery/subfinder)
2020-08-11 21:27:45 +00:00
[![Chat on Discord](https://img.shields.io/discord/695645237418131507.svg?logo=discord)](https://discord.gg/KECAGdH)
2018-06-26 13:38:49 +00:00
2019-12-05 13:06:56 +00:00
2019-12-05 11:47:41 +00:00
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.
2018-06-26 13:38:49 +00:00
2019-12-05 11:47:41 +00:00
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.
2018-06-26 13:38:49 +00:00
2019-12-05 13:06:56 +00:00
2018-06-26 13:39:19 +00:00
# Resources
- [Features](#features)
- [Usage](#usage)
2020-10-28 08:49:04 +00:00
- [Installation Instructions (direct)](#direct-installation)
2020-07-12 11:35:25 +00:00
- [Installation Instructions](#installation-instructions)
- [From Binary](#from-binary)
- [From Source](#from-source)
- [From Github](#from-github)
2018-06-26 13:39:19 +00:00
- [Upgrading](#upgrading)
- [Post Installation Instructions](#post-installation-instructions)
2019-12-05 11:47:41 +00:00
- [Running subfinder](#running-subfinder)
2020-07-12 11:35:25 +00:00
- [Running in a Docker Container](#running-in-a-docker-container)
2018-06-26 13:38:49 +00:00
# Features
2019-12-05 13:06:56 +00:00
<h1 align="left">
<img src="static/subfinder-run.png" alt="subfinder" width="700px"></a>
<br>
</h1>
2018-06-26 13:38:49 +00:00
- Simple and modular code base making it easy to contribute.
2019-12-05 11:19:11 +00:00
- Fast And Powerful Resolution and wildcard elimination module
2020-09-21 19:53:10 +00:00
- **Curated** passive sources to maximize results (35 Sources as of now)
2019-12-05 11:19:11 +00:00
- Multiple Output formats supported (Json, File, Stdout)
2019-12-05 11:33:37 +00:00
- Optimized for speed, very fast and **lightweight** on resources
- **Stdin** and **stdout** support for integrating in workflows
2018-06-26 11:33:16 +00:00
2020-05-22 21:42:11 +00:00
2018-04-24 13:14:52 +00:00
# Usage
2018-04-14 07:17:42 +00:00
2020-08-18 01:05:46 +00:00
```sh
2019-12-05 11:19:11 +00:00
subfinder -h
2018-04-24 13:14:52 +00:00
```
This will display help for the tool. Here are all the switches it supports.
| Flag | Description | Example |
|------|-------------|---------|
2020-08-11 21:27:45 +00:00
| -all | Use all sources (slow) for enumeration | subfinder -d uber.com -all |
2020-08-10 15:59:15 +00:00
| -cd | Upload results to the Chaos API (api-key required) | subfinder -d uber.com -cd |
| -config string | Configuration file for API Keys, etc | subfinder -config config.yaml |
| -d | Domain to find subdomains for | subfinder -d uber.com |
| -dL | File containing list of domains to enumerate | subfinder -dL hackerone-hosts.txt |
| -exclude-sources | List of sources to exclude from enumeration | subfinder -exclude-sources archiveis |
| -max-time | Minutes to wait for enumeration results (default 10) | subfinder -max-time 1 |
| -nC | Don't Use colors in output | subfinder -nC |
| -nW | Remove Wildcard & Dead Subdomains from output | subfinder -nW |
| -ls | List all available sources | subfinder -ls |
| -o | File to write output to (optional) | subfinder -o output.txt |
| -oD | Directory to write enumeration results to (optional) | subfinder -oD ~/outputs |
2019-12-05 11:19:11 +00:00
| -oI | Write output in Host,IP format | subfinder -oI |
| -oJ | Write output in JSON lines Format | subfinder -oJ |
2020-08-10 15:59:15 +00:00
| -r | Comma-separated list of resolvers to use | subfinder -r 1.1.1.1,1.0.0.1 |
2019-12-05 11:19:11 +00:00
| -rL | Text file containing list of resolvers to use | subfinder -rL resolvers.txt
2020-08-11 21:27:45 +00:00
| -recursive | Enumeration recursive subdomains | subfinder -d news.yahoo.com -recursive
2020-08-10 15:59:15 +00:00
| -silent | Show only subdomains in output | subfinder -silent |
| -sources | Comma separated list of sources to use | subfinder -sources shodan,censys |
| -t | Number of concurrent goroutines for resolving (default 10) | subfinder -t 100 |
| -timeout | Seconds to wait before timing out (default 30) | subfinder -timeout 30 |
| -v | Show Verbose output | subfinder -v |
| -version | Show current program version | subfinder -version |
2018-04-24 13:14:52 +00:00
# Installation Instructions
2018-06-05 13:42:12 +00:00
2020-07-12 11:35:25 +00:00
### From Binary
2018-06-05 13:42:12 +00:00
2020-07-12 11:35:25 +00:00
The installation is easy. You can download the pre-built binaries for different platforms from the [releases](https://github.com/projectdiscovery/subfinder/releases/) page. Extract them using tar, move it to your `$PATH` and you're ready to go.
2019-12-06 08:28:07 +00:00
2020-08-18 01:05:46 +00:00
```sh
2020-09-21 19:53:10 +00:00
▶ # download release from https://github.com/projectdiscovery/subfinder/releases/
▶ tar -xzvf subfinder-linux-amd64.tar.gz
▶ mv subfinder /usr/local/bin/
▶ subfinder -h
2019-12-06 08:28:07 +00:00
```
2020-07-12 11:35:25 +00:00
### From Source
2020-09-25 11:17:11 +00:00
subfinder requires **go1.14+** to install successfully. Run the following command to get the repo -
2019-12-06 08:00:34 +00:00
2020-08-18 01:05:46 +00:00
```sh
2020-12-21 19:21:44 +00:00
GO111MODULE=on go get -v github.com/projectdiscovery/subfinder/v2/cmd/subfinder
2019-12-06 08:00:34 +00:00
```
2020-07-12 11:35:25 +00:00
### From Github
2020-08-18 01:05:46 +00:00
```sh
2020-07-12 11:35:25 +00:00
git clone https://github.com/projectdiscovery/subfinder.git
cd subfinder/v2/cmd/subfinder
2020-07-12 11:35:25 +00:00
go build .
mv subfinder /usr/local/bin/
subfinder -h
```
2018-04-24 13:14:52 +00:00
## Post Installation Instructions
2018-04-23 00:09:34 +00:00
2019-12-05 11:19:11 +00:00
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:
2018-04-23 00:09:34 +00:00
2019-12-05 11:19:11 +00:00
- [Binaryedge](https://binaryedge.io)
2020-09-21 19:53:10 +00:00
- [Certspotter](https://sslmate.com/certspotter/api/)
- [Censys](https://censys.io)
2020-05-22 21:42:11 +00:00
- [Chaos](https://chaos.projectdiscovery.io)
- [DnsDB](https://api.dnsdb.info)
2020-07-14 12:08:12 +00:00
- [Github](https://github.com)
- [Intelx](https://intelx.io)
2020-09-21 19:53:10 +00:00
- [Passivetotal](http://passivetotal.org)
- [Recon.dev](https://recon.dev)
- [Robtex](https://www.robtex.com/api/)
2020-09-21 19:53:10 +00:00
- [SecurityTrails](http://securitytrails.com)
- [Shodan](https://shodan.io)
- [Spyse](https://spyse.com)
- [Threatbook](https://x.threatbook.cn/en)
2020-09-21 19:53:10 +00:00
- [Virustotal](https://www.virustotal.com)
- [Zoomeye](https://www.zoomeye.org)
2019-12-05 11:19:11 +00:00
2020-06-08 10:23:59 +00:00
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.
2019-12-05 11:19:11 +00:00
For sources that require multiple keys, namely `Censys`, `Passivetotal`, they can be added by separating them via a colon (:).
2020-08-10 15:59:15 +00:00
An example config file -
2019-12-05 11:19:11 +00:00
```yaml
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: []
2020-08-10 15:59:15 +00:00
passivetotal:
2020-07-14 12:08:12 +00:00
- sample-email@user.com:sample_password
2019-12-05 11:19:11 +00:00
securitytrails: []
2020-07-14 12:08:12 +00:00
shodan:
- AAAAClP1bJJSRMEYJazgwhJKrggRwKA
2020-07-14 17:12:47 +00:00
github:
- d23a554bbc1aabb208c9acfbd2dd41ce7fc9db39
2020-07-18 11:18:26 +00:00
- asdsd54bbc1aabb208c9acfbd2dd41ce7fc9db39
2018-04-23 00:09:34 +00:00
```
2018-06-26 13:38:49 +00:00
# Running Subfinder
To run the tool on a target, just use the following command.
2020-08-18 01:05:46 +00:00
```sh
2020-09-21 19:53:10 +00:00
▶ subfinder -d freelancer.com
```
2019-12-05 11:33:37 +00:00
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.
2020-08-18 01:05:46 +00:00
```
2020-08-11 21:27:45 +00:00
[threatcrowd] ns1.hosting.freelancer.com
[threatcrowd] ns2.hosting.freelancer.com
[threatcrowd] flash.freelancer.com
[threatcrowd] auth.freelancer.com
[chaos] alertmanager.accounts.freelancer.com
[chaos] analytics01.freelancer.com
[chaos] apidocs.freelancer.com
[chaos] brains.freelancer.com
[chaos] consul.accounts.freelancer.com
```
2020-07-12 11:35:25 +00:00
The `-silent` switch can be used to show only subdomains found without any other info.
The `-o` command can be used to specify an output file.
2020-08-18 01:05:46 +00:00
```sh
2020-09-21 19:53:10 +00:00
▶ subfinder -d freelancer.com -o output.txt
2019-12-05 11:33:37 +00:00
```
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.
2020-08-18 01:05:46 +00:00
```sh
2020-09-21 19:53:10 +00:00
▶ cat domains.txt
2019-12-05 11:33:37 +00:00
hackerone.com
google.com
2019-12-05 11:47:41 +00:00
2020-09-21 19:53:10 +00:00
▶ subfinder -dL domains.txt -oD ~/path/to/output
▶ ls ~/path/to/output
2019-12-05 11:47:41 +00:00
2019-12-05 11:33:37 +00:00
hackerone.com.txt
google.com.txt
```
2020-08-10 15:59:15 +00:00
You can also get output in json format using `-oJ` switch. This switch saves the output in the JSON lines format.
2020-07-12 11:35:25 +00:00
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.
2018-05-11 09:09:24 +00:00
2020-08-18 01:05:46 +00:00
```sh
2020-09-21 19:53:10 +00:00
▶ subfinder -d hackerone.com -o output.json -oJ -nW
▶ cat output.json
2019-12-05 11:47:41 +00:00
2019-12-05 11:19:11 +00:00
{"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"}
2018-05-25 14:22:30 +00:00
```
2019-12-05 11:33:37 +00:00
2020-08-10 15:59:15 +00:00
**The new highlight of this release is the addition of stdin/stdout features.** Now, domains can be piped to subfinder and enumeration can be ran on them. For example -
2019-12-05 11:33:37 +00:00
2020-08-18 01:05:46 +00:00
```sh
2020-09-21 19:53:10 +00:00
▶ echo hackerone.com | subfinder
▶ cat targets.txt | subfinder
2019-12-05 11:33:37 +00:00
```
2020-07-12 11:35:25 +00:00
The subdomains discovered can be piped to other tools too. For example, you can pipe the subdomains discovered by subfinder to httpx [httpx](https://github.com/projectdiscovery/httpx) which will then find running http servers on the host.
2019-12-05 11:33:37 +00:00
2020-08-18 01:05:46 +00:00
```sh
2020-09-21 19:53:10 +00:00
▶ echo hackerone.com | subfinder -silent | httpx -silent
2019-12-05 11:47:41 +00:00
2019-12-05 11:33:37 +00:00
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
```
2018-07-06 04:05:46 +00:00
2020-07-12 11:35:25 +00:00
## Running in a Docker Container
2020-08-10 15:59:15 +00:00
You can use the official dockerhub image at [subfinder](https://hub.docker.com/r/projectdiscovery/subfinder). Simply run -
2020-07-12 11:35:25 +00:00
2020-08-18 01:05:46 +00:00
```sh
2020-09-21 19:53:10 +00:00
▶ docker pull projectdiscovery/subfinder
2020-07-12 11:35:25 +00:00
```
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
2020-08-18 01:05:46 +00:00
```sh
2020-07-12 11:35:25 +00:00
docker build -t projectdiscovery/subfinder .
```
2020-08-10 15:59:15 +00:00
- After building the container using either way, run the following -
2020-08-18 01:05:46 +00:00
```sh
2020-07-12 11:35:25 +00:00
docker run -it projectdiscovery/subfinder
```
2020-09-21 19:53:10 +00:00
▶ The above command is the same as running `-h`
2020-07-12 11:35:25 +00:00
2020-07-12 11:43:48 +00:00
If you are using docker, you need to first create your directory structure holding subfinder configuration file. After modifying the default config.yaml file, you can run:
2020-08-18 01:05:46 +00:00
```sh
2020-09-21 19:53:10 +00:00
▶ mkdir -p $HOME/.config/subfinder
▶ cp config.yaml $HOME/.config/subfinder/config.yaml
▶ nano $HOME/.config/subfinder/config.yaml
2020-07-12 11:43:48 +00:00
```
After that, you can pass it as a volume using the following sample command.
2020-08-18 01:05:46 +00:00
```sh
2020-09-21 19:53:10 +00:00
▶ docker run -v $HOME/.config/subfinder:/root/.config/subfinder -it projectdiscovery/subfinder -d freelancer.com
2020-07-12 11:43:48 +00:00
```
2020-07-12 11:35:25 +00:00
For example, this runs the tool against uber.com and output the results to your host file system:
2020-08-18 01:05:46 +00:00
```sh
2020-07-12 11:35:25 +00:00
docker run -v $HOME/.config/subfinder:/root/.config/subfinder -it projectdiscovery/subfinder -d uber.com > uber.com.txt
```
2021-02-06 08:12:47 +00:00
### Resources
- [Recon with Me !!!](https://dhiyaneshgeek.github.io/bug/bounty/2020/02/06/recon-with-me/)
2018-07-06 04:05:46 +00:00
# License
2019-12-05 11:33:37 +00:00
subfinder is made with 🖤 by the [projectdiscovery](https://projectdiscovery.io) team. Community contributions have made the project what it is. See the **[Thanks.md](https://github.com/projectdiscovery/subfinder/blob/master/THANKS.md)** file for more details.
2019-12-05 13:23:02 +00:00
2020-05-16 12:12:48 +00:00
Read the disclaimer for usage at [DISCLAIMER.md](https://github.com/projectdiscovery/subfinder/blob/master/DISCLAIMER.md) and [contact us](mailto:contact@projectdiscovery.io) for any API removal.