From f513331c0ac4dba12282a59b63b21c6f95519130 Mon Sep 17 00:00:00 2001 From: "Alex Munene (@enenumxela)" <62714471+enenumxela@users.noreply.github.com> Date: Sun, 25 Jun 2023 13:40:21 +0300 Subject: [PATCH] feat: Add bevigil source --- pkg/xsubfind3r/sources/bevigil/bevigil.go | 66 +++++++++++++++++++++++ pkg/xsubfind3r/sources/configuration.go | 1 + pkg/xsubfind3r/sources/sources.go | 1 + pkg/xsubfind3r/xsubfind3r.go | 3 ++ 4 files changed, 71 insertions(+) create mode 100644 pkg/xsubfind3r/sources/bevigil/bevigil.go diff --git a/pkg/xsubfind3r/sources/bevigil/bevigil.go b/pkg/xsubfind3r/sources/bevigil/bevigil.go new file mode 100644 index 0000000..014878d --- /dev/null +++ b/pkg/xsubfind3r/sources/bevigil/bevigil.go @@ -0,0 +1,66 @@ +package bevigil + +import ( + "encoding/json" + "fmt" + + "github.com/hueristiq/xsubfind3r/pkg/xsubfind3r/httpclient" + "github.com/hueristiq/xsubfind3r/pkg/xsubfind3r/sources" + "github.com/valyala/fasthttp" +) + +type response struct { + Domain string `json:"domain"` + Subdomains []string `json:"subdomains"` +} + +type Source struct{} + +func (source *Source) Run(config *sources.Configuration) (subdomains chan sources.Subdomain) { + subdomains = make(chan sources.Subdomain) + + go func() { + defer close(subdomains) + + var ( + key string + err error + res *fasthttp.Response + headers = map[string]string{} + ) + + key, err = sources.PickRandom(config.Keys.Bevigil) + if key == "" || err != nil { + return + } + + if len(config.Keys.Bevigil) > 0 { + headers["X-Access-Token"] = key + } + + reqURL := fmt.Sprintf("https://osint.bevigil.com/api/%s/subdomains/", config.Domain) + + res, err = httpclient.Request(fasthttp.MethodGet, reqURL, "", headers, nil) + if err != nil { + return + } + + body := res.Body() + + var results response + + if err = json.Unmarshal(body, &results); err != nil { + return + } + + for _, i := range results.Subdomains { + subdomains <- sources.Subdomain{Source: source.Name(), Value: i} + } + }() + + return +} + +func (source *Source) Name() string { + return "bevigil" +} diff --git a/pkg/xsubfind3r/sources/configuration.go b/pkg/xsubfind3r/sources/configuration.go index 5b1110d..17e8ab6 100644 --- a/pkg/xsubfind3r/sources/configuration.go +++ b/pkg/xsubfind3r/sources/configuration.go @@ -12,6 +12,7 @@ type Configuration struct { } type Keys struct { + Bevigil []string `yaml:"bevigil"` Chaos []string `yaml:"chaos"` GitHub []string `yaml:"github"` Intelx []string `yaml:"intelx"` diff --git a/pkg/xsubfind3r/sources/sources.go b/pkg/xsubfind3r/sources/sources.go index c20197d..a2fd20e 100644 --- a/pkg/xsubfind3r/sources/sources.go +++ b/pkg/xsubfind3r/sources/sources.go @@ -4,6 +4,7 @@ var List = []string{ "alienvault", "anubis", "archiveis", + "bevigil", "bufferover", "cebaidu", "certspotterv0", diff --git a/pkg/xsubfind3r/xsubfind3r.go b/pkg/xsubfind3r/xsubfind3r.go index ed10ef2..dc6410e 100644 --- a/pkg/xsubfind3r/xsubfind3r.go +++ b/pkg/xsubfind3r/xsubfind3r.go @@ -8,6 +8,7 @@ import ( "github.com/hueristiq/xsubfind3r/pkg/xsubfind3r/sources/alienvault" "github.com/hueristiq/xsubfind3r/pkg/xsubfind3r/sources/anubis" "github.com/hueristiq/xsubfind3r/pkg/xsubfind3r/sources/archiveis" + "github.com/hueristiq/xsubfind3r/pkg/xsubfind3r/sources/bevigil" "github.com/hueristiq/xsubfind3r/pkg/xsubfind3r/sources/bufferover" "github.com/hueristiq/xsubfind3r/pkg/xsubfind3r/sources/cebaidu" "github.com/hueristiq/xsubfind3r/pkg/xsubfind3r/sources/certspotterv0" @@ -62,6 +63,8 @@ func New(options *Options) (finder *Finder) { finder.Sources[source] = &anubis.Source{} case "archiveis": finder.Sources[source] = &archiveis.Source{} + case "bevigil": + finder.Sources[source] = &bevigil.Source{} case "bufferover": finder.Sources[source] = &bufferover.Source{} case "cebaidu":