Skip to content

Commit

Permalink
BeVigil Source Added (#591)
Browse files Browse the repository at this point in the history
* BeVigil Source Added

* updated readme.md

* updated .gitignore

* fmt sources

Co-authored-by: Mzack9999 <mzack9999@protonmail.com>
  • Loading branch information
alt-glitch and Mzack9999 authored Aug 22, 2022
1 parent 2469035 commit 0aa8931
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
.DS_Store
cmd/subfinder/subfinder
# subfinder binary when built with `go build`
v2/cmd/subfinder/subfinder
# subfinder binary when built with `make`
v2/subfinder
vendor/
.idea
.idea
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ go install -v github.com/projectdiscovery/subfinder/v2/cmd/subfinder@latest

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](https://binaryedge.io), [C99](https://api.c99.nl/), [Certspotter](https://sslmate.com/certspotter/api/), [Chinaz](http://my.chinaz.com/ChinazAPI/DataCenter/MyDataApi), [Censys](https://censys.io), [Chaos](https://chaos.projectdiscovery.io), [DnsDB](https://api.dnsdb.info), [Fofa](https://fofa.info/static_pages/api_help), [Github](https://github.com), [Intelx](https://intelx.io), [Passivetotal](http://passivetotal.org), [Robtex](https://www.robtex.com/api/), [SecurityTrails](http://securitytrails.com), [Shodan](https://shodan.io), [Threatbook](https://x.threatbook.cn/en), [Virustotal](https://www.virustotal.com), [WhoisXML API](https://whoisxmlapi.com/), [Zoomeye](https://www.zoomeye.org)
[BeVigil](https://bevigil.com/osint-api), [Binaryedge](https://binaryedge.io), [C99](https://api.c99.nl/), [Certspotter](https://sslmate.com/certspotter/api/), [Chinaz](http://my.chinaz.com/ChinazAPI/DataCenter/MyDataApi), [Censys](https://censys.io), [Chaos](https://chaos.projectdiscovery.io), [DnsDB](https://api.dnsdb.info), [Fofa](https://fofa.info/static_pages/api_help), [Github](https://github.com), [Intelx](https://intelx.io), [Passivetotal](http://passivetotal.org), [Robtex](https://www.robtex.com/api/), [SecurityTrails](http://securitytrails.com), [Shodan](https://shodan.io), [Threatbook](https://x.threatbook.cn/en), [Virustotal](https://www.virustotal.com), [WhoisXML API](https://whoisxmlapi.com/), [Zoomeye](https://www.zoomeye.org)

These 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.

Expand Down
2 changes: 2 additions & 0 deletions v2/pkg/passive/sources.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/projectdiscovery/subfinder/v2/pkg/subscraping/sources/alienvault"
"github.com/projectdiscovery/subfinder/v2/pkg/subscraping/sources/anubis"
"github.com/projectdiscovery/subfinder/v2/pkg/subscraping/sources/archiveis"
"github.com/projectdiscovery/subfinder/v2/pkg/subscraping/sources/bevigil"
"github.com/projectdiscovery/subfinder/v2/pkg/subscraping/sources/binaryedge"
"github.com/projectdiscovery/subfinder/v2/pkg/subscraping/sources/bufferover"
"github.com/projectdiscovery/subfinder/v2/pkg/subscraping/sources/c99"
Expand Down Expand Up @@ -49,6 +50,7 @@ var AllSources = [...]subscraping.Source{
&alienvault.Source{},
&anubis.Source{},
&archiveis.Source{},
&bevigil.Source{},
&binaryedge.Source{},
&bufferover.Source{},
&c99.Source{},
Expand Down
2 changes: 2 additions & 0 deletions v2/pkg/passive/sources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ var (
"alienvault",
"anubis",
"archiveis",
"bevigil",
"binaryedge",
"bufferover",
"c99",
Expand Down Expand Up @@ -51,6 +52,7 @@ var (
expectedDefaultSources = []string{
"alienvault",
"anubis",
"bevigil",
"bufferover",
"c99",
"certspotter",
Expand Down
81 changes: 81 additions & 0 deletions v2/pkg/subscraping/sources/bevigil/bevigil.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// Package bevigil logic
package bevigil

import (
"context"
"fmt"

jsoniter "github.com/json-iterator/go"
"github.com/projectdiscovery/subfinder/v2/pkg/subscraping"
)

type Response struct {
Domain string `json:"domain"`
Subdomains []string `json:"subdomains"`
}

type Source struct{}

var apiKeys []string

func (s *Source) Run(ctx context.Context, domain string, session *subscraping.Session) <-chan subscraping.Result {
results := make(chan subscraping.Result)
go func() {
defer close(results)

randomApiKey := subscraping.PickRandom(apiKeys)
if randomApiKey == "" {
return
}

getUrl := fmt.Sprintf("https://osint.bevigil.com/api/%s/subdomains/", domain)

resp, err := session.Get(ctx, getUrl, "", map[string]string{"X-Access-Token": randomApiKey})
if err != nil {
results <- subscraping.Result{Source: s.Name(), Type: subscraping.Error, Error: err}
session.DiscardHTTPResponse(resp)
return
}

var subdomains []string
var response Response
err = jsoniter.NewDecoder(resp.Body).Decode(&response)
if err != nil {
results <- subscraping.Result{Source: s.Name(), Type: subscraping.Error, Error: err}
resp.Body.Close()
return
}

resp.Body.Close()

if len(response.Subdomains) > 0 {
subdomains = response.Subdomains
}

for _, subdomain := range subdomains {
results <- subscraping.Result{Source: s.Name(), Type: subscraping.Subdomain, Value: subdomain}
}
}()

return results
}

func (s *Source) Name() string {
return "bevigil"
}

func (s *Source) IsDefault() bool {
return true
}

func (s *Source) HasRecursiveSupport() bool {
return false
}

func (s *Source) NeedsKey() bool {
return true
}

func (s *Source) AddApiKeys(keys []string) {
apiKeys = keys
}

0 comments on commit 0aa8931

Please sign in to comment.