Skip to content

Commit

Permalink
Merge pull request #13 from hueristiq/dev
Browse files Browse the repository at this point in the history
Development v0.5.0
  • Loading branch information
enenumxela authored Nov 21, 2023
2 parents 485917d + 8385a26 commit 57bc303
Show file tree
Hide file tree
Showing 12 changed files with 440 additions and 111 deletions.
11 changes: 7 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,16 @@ update-deps:
$(GOGET) -f -t -u ./...
$(GOGET) -f -u ./...

.PHONY: format
format:
.PHONY: _gofmt
_gofmt:
$(GOFMT) ./...

.PHONY: _golangci-lint
_golangci-lint:
$(GOLANGCILINTRUN) $(GOLANGCILINT) ./...

.PHONY: lint
lint:
$(GOLANGCILINTRUN) ./...
lint: _gofmt _golangci-lint

.PHONY: test
test:
Expand Down
37 changes: 29 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# xsubfind3r

![made with go](https://img.shields.io/badge/made%20with-Go-0000FF.svg) [![release](https://img.shields.io/github/release/hueristiq/xsubfind3r?style=flat&color=0000FF)](https://github.com/hueristiq/xsubfind3r/releases) [![license](https://img.shields.io/badge/license-MIT-gray.svg?color=0000FF)](https://github.com/hueristiq/xsubfind3r/blob/master/LICENSE) ![maintenance](https://img.shields.io/badge/maintained%3F-yes-0000FF.svg) [![open issues](https://img.shields.io/github/issues-raw/hueristiq/xsubfind3r.svg?style=flat&color=0000FF)](https://github.com/hueristiq/xsubfind3r/issues?q=is:issue+is:open) [![closed issues](https://img.shields.io/github/issues-closed-raw/hueristiq/xsubfind3r.svg?style=flat&color=0000FF)](https://github.com/hueristiq/xsubfind3r/issues?q=is:issue+is:closed) [![contribution](https://img.shields.io/badge/contributions-welcome-0000FF.svg)](https://github.com/hueristiq/xsubfind3r/blob/master/CONTRIBUTING.md)
![made with go](https://img.shields.io/badge/made%20with-Go-1E90FF.svg) [![go report card](https://goreportcard.com/badge/github.com/hueristiq/xsubfind3r)](https://goreportcard.com/report/github.com/hueristiq/xsubfind3r) [![release](https://img.shields.io/github/release/hueristiq/xsubfind3r?style=flat&color=1E90FF)](https://github.com/hueristiq/xsubfind3r/releases) [![open issues](https://img.shields.io/github/issues-raw/hueristiq/xsubfind3r.svg?style=flat&color=1E90FF)](https://github.com/hueristiq/xsubfind3r/issues?q=is:issue+is:open) [![closed issues](https://img.shields.io/github/issues-closed-raw/hueristiq/xsubfind3r.svg?style=flat&color=1E90FF)](https://github.com/hueristiq/xsubfind3r/issues?q=is:issue+is:closed) [![license](https://img.shields.io/badge/license-MIT-gray.svg?color=1E90FF)](https://github.com/hueristiq/xsubfind3r/blob/master/LICENSE) ![maintenance](https://img.shields.io/badge/maintained%3F-yes-1E90FF.svg) [![contribution](https://img.shields.io/badge/contributions-welcome-1E90FF.svg)](https://github.com/hueristiq/xsubfind3r/blob/master/CONTRIBUTING.md)

`xsubfind3r` is a command-line interface (CLI) utility to find domain's known subdomains from curated, passive online sources.
`xsubfind3r` is a command-line interface (CLI) based passive subdomain discovery utility. It is designed to efficiently identify known subdomains of given domains by tapping into a multitude of curated online passive sources.

## Resource

Expand All @@ -16,11 +16,14 @@
* [Usage](#usage)
* [Contributing](#contributing)
* [Licensing](#licensing)
* [Credits](#credits)
* [Contributors](#contributors)
* [Similar Projects](#similar-projects)

## Features

* Fetches domains from curated passive sources to maximize results.
* `stdin` and `stdout` for easy integration into workflows.
* Fetches subdomains from curated passive sources to maximize results.
* Supports `stdin` and `stdout` for easy integration into workflows.
* Cross-Platform (Windows, Linux & macOS).

## Installation
Expand Down Expand Up @@ -101,19 +104,21 @@ go install -v github.com/hueristiq/xsubfind3r/cmd/xsubfind3r@latest

## Post Installation

`xsubfind3r` will work right after [installation](#installation). However, **[BeVigil](https://bevigil.com)**, **[BuiltWith](https://api.builtwith.com/domain-api)**, **[Chaos](https://chaos.projectdiscovery.io/#/)**, **[Fullhunt](https://fullhunt.io/)**, **[Github](https://github.com)**, **[Intelligence X](https://intelx.io)**, **[LeakIX](https://leakix.net)** and **[Shodan](https://shodan.io/)** require API keys to work, **[URLScan](https://urlscan.io)** supports API key but not required. The API keys are stored in the `$HOME/.config/xsubfind3r/config.yaml` file - created upon first run - and uses the YAML format. Multiple API keys can be specified for each of these source from which one of them will be used.
`xsubfind3r` will work right after [installation](#installation). However, **[BeVigil](https://bevigil.com)**, **[BufferOver](https://tls.bufferover.run/)**, **[BuiltWith](https://api.builtwith.com/domain-api)**, **[Certspotter](https://sslmate.com/ct_search_api/)**, **[Chaos](https://chaos.hueristiq.io/#/)**, **[Fullhunt](https://fullhunt.io/)**, **[Github](https://github.com)**, **[Intelligence X](https://intelx.io)**, **[LeakIX](https://leakix.net)** and **[Shodan](https://shodan.io/)** require API keys to work, **[URLScan](https://urlscan.io)** supports API key but not required. The API keys are stored in the `$HOME/.config/xsubfind3r/config.yaml` file - created upon first run - and uses the YAML format. Multiple API keys can be specified for each of these source from which one of them will be used.

Example `config.yaml`:

> **NOTE:** The keys/tokens below are invalid and used as examples, use your own keys/tokens!
```yaml
version: 0.4.0
version: 0.5.0
sources:
- alienvault
- anubis
- bevigil
- bufferover
- builtwith
- certspotter
- chaos
- commoncrawl
- crtsh
Expand All @@ -128,6 +133,8 @@ sources:
keys:
bevigil:
- awA5nvpKU3N8ygkZ
bufferover:
- COx9GBnhz63hcF1hlBtLb4KAdlzJly1d8xeovTjK
builtwith:
- 7fcbaec4-dc49-472c-b837-3896cb255823
chaos:
Expand Down Expand Up @@ -163,7 +170,7 @@ __ _____ _ _| |__ / _(_)_ __ __| |___ / _ __
\ \/ / __| | | | '_ \| |_| | '_ \ / _` | |_ \| '__|
> <\__ \ |_| | |_) | _| | | | | (_| |___) | |
/_/\_\___/\__,_|_.__/|_| |_|_| |_|\__,_|____/|_|
v0.4.0
v0.5.0

with <3 by Hueristiq Open Source

Expand Down Expand Up @@ -199,4 +206,18 @@ OUTPUT:

## Licensing

This utility is distributed under the [MIT license](https://github.com/hueristiq/xsubfind3r/blob/master/LICENSE).
This utility is distributed under the [MIT license](https://github.com/hueristiq/xsubfind3r/blob/master/LICENSE).

## Credits

### Contributors

Thanks to the amazing [contributors](https://github.com/hueristiq/xsubfind3r/graphs/contributors) for keeping this project alive.

[![contributors](https://contrib.rocks/image?repo=hueristiq/xsubfind3r&max=500)](https://github.com/hueristiq/xsubfind3r/graphs/contributors)

### Similar Projects

Thanks to similar open source projects - check them out, may fit in your workflow.

[subfinder](https://github.com/projectdiscovery/subfinder)[assetfinder](https://github.com/tomnomnom/assetfinder)
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ require (
require (
github.com/Mzack9999/go-http-digest-auth-client v0.6.1-0.20220414142836-eb8883508809 // indirect
github.com/hueristiq/hqgoutils v0.0.0-20231024005153-bd2c47932440 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/term v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/net v0.18.0 // indirect
golang.org/x/sys v0.14.0 // indirect
golang.org/x/term v0.14.0 // indirect
golang.org/x/text v0.14.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
)
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80 h1:nrZ3ySNYwJbSpD6ce9duiP+QkD3JuLCcWkdaehUS/3Y=
github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80/go.mod h1:iFyPdL66DjUD96XmzVL3ZntbzcflLnznH0fr99w5VqE=
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek=
golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U=
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/net v0.18.0 h1:mIYleuAkSbHh0tCv7RvjL3F6ZVbLjq4+R7zbOn3Kokg=
golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ=
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.14.0 h1:LGK9IlZ8T9jvdy6cTdfKUCltatMFOehAQo9SRC46UQ8=
golang.org/x/term v0.14.0/go.mod h1:TySc+nGkYR6qt8km8wUhuFRTVSMIX3XPR58y2lC8vww=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
Expand Down
2 changes: 1 addition & 1 deletion internal/configuration/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (cfg *Configuration) Write(path string) (err error) {

const (
NAME string = "xsubfind3r"
VERSION string = "0.4.0"
VERSION string = "0.5.0"
)

var (
Expand Down
6 changes: 6 additions & 0 deletions pkg/scraper/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import (
"github.com/hueristiq/xsubfind3r/pkg/scraper/sources"
"github.com/hueristiq/xsubfind3r/pkg/scraper/sources/anubis"
"github.com/hueristiq/xsubfind3r/pkg/scraper/sources/bevigil"
"github.com/hueristiq/xsubfind3r/pkg/scraper/sources/bufferover"
"github.com/hueristiq/xsubfind3r/pkg/scraper/sources/builtwith"
"github.com/hueristiq/xsubfind3r/pkg/scraper/sources/certspotter"
"github.com/hueristiq/xsubfind3r/pkg/scraper/sources/chaos"
"github.com/hueristiq/xsubfind3r/pkg/scraper/sources/commoncrawl"
"github.com/hueristiq/xsubfind3r/pkg/scraper/sources/crtsh"
Expand Down Expand Up @@ -87,8 +89,12 @@ func New(options *Options) (scraper *Scraper) {
scraper.Sources[source] = &anubis.Source{}
case "bevigil":
scraper.Sources[source] = &bevigil.Source{}
case "bufferover":
scraper.Sources[source] = &bufferover.Source{}
case "builtwith":
scraper.Sources[source] = &builtwith.Source{}
case "certspotter":
scraper.Sources[source] = &certspotter.Source{}
case "chaos":
scraper.Sources[source] = &chaos.Source{}
case "commoncrawl":
Expand Down
145 changes: 145 additions & 0 deletions pkg/scraper/sources/bufferover/bufferover.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
package bufferover

import (
"encoding/json"
"fmt"
"net/http"
"regexp"
"strings"

"github.com/hueristiq/xsubfind3r/pkg/extractor"
"github.com/hueristiq/xsubfind3r/pkg/httpclient"
"github.com/hueristiq/xsubfind3r/pkg/scraper/sources"
)

type getTLSLogsSearchResponse struct {
Meta struct {
Errors []string `json:"Errors"`
} `json:"Meta"`
FDNSA []string `json:"FDNS_A"`
RDNS []string `json:"RDNS"`
Results []string `json:"Results"`
}

type Source struct{}

func (source *Source) Run(config *sources.Configuration, domain string) <-chan sources.Result {
results := make(chan sources.Result)

go func() {
defer close(results)

var err error

var key string

key, err = sources.PickRandom(config.Keys.Bufferover)
if key == "" || err != nil {
result := sources.Result{
Type: sources.Error,
Source: source.Name(),
Error: err,
}

results <- result

return
}

getTLSLogsSearchReqHeaders := map[string]string{"x-api-key": key}

getTLSLogsSearchReqURL := fmt.Sprintf("https://tls.bufferover.run/dns?q=.%s", domain)

var getTLSLogsSearchRes *http.Response

getTLSLogsSearchRes, err = httpclient.Get(getTLSLogsSearchReqURL, "", getTLSLogsSearchReqHeaders)
if err != nil {
result := sources.Result{
Type: sources.Error,
Source: source.Name(),
Error: err,
}

results <- result

getTLSLogsSearchRes.Body.Close()

return
}

var getTLSLogsSearchResData getTLSLogsSearchResponse

if err = json.NewDecoder(getTLSLogsSearchRes.Body).Decode(&getTLSLogsSearchResData); err != nil {
result := sources.Result{
Type: sources.Error,
Source: source.Name(),
Error: err,
}

results <- result

getTLSLogsSearchRes.Body.Close()

return
}

getTLSLogsSearchRes.Body.Close()

if len(getTLSLogsSearchResData.Meta.Errors) > 0 {
result := sources.Result{
Type: sources.Error,
Source: source.Name(),
Error: fmt.Errorf("%s", strings.Join(getTLSLogsSearchResData.Meta.Errors, ", ")),
}

results <- result
}

var regex *regexp.Regexp

regex, err = extractor.New(domain)
if err != nil {
result := sources.Result{
Type: sources.Error,
Source: source.Name(),
Error: err,
}

results <- result

return
}

var entries []string

if len(getTLSLogsSearchResData.FDNSA) > 0 {
entries = getTLSLogsSearchResData.FDNSA
entries = append(entries, getTLSLogsSearchResData.RDNS...)
} else if len(getTLSLogsSearchResData.Results) > 0 {
entries = getTLSLogsSearchResData.Results
}

for index := range entries {
entry := entries[index]
subdomains := regex.FindAllString(entry, -1)

for index := range subdomains {
subdomain := subdomains[index]

result := sources.Result{
Type: sources.Subdomain,
Source: source.Name(),
Value: subdomain,
}

results <- result
}
}
}()

return results
}

func (source *Source) Name() string {
return "bufferover"
}
Loading

0 comments on commit 57bc303

Please sign in to comment.