Skip to content

Commit

Permalink
chore(*): -
Browse files Browse the repository at this point in the history
  • Loading branch information
enenumxela committed Aug 28, 2023
1 parent b543e41 commit 0be1a9f
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 48 deletions.
90 changes: 42 additions & 48 deletions pkg/xsubfind3r/xsubfind3r.go → pkg/xsubfind3r/finder.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,51 @@ import (
"github.com/hueristiq/xsubfind3r/pkg/xsubfind3r/sources/wayback"
)

type Options struct {
SourcesToExclude []string
SourcesToUSe []string
Keys sources.Keys
}

type Finder struct {
Sources map[string]sources.Source
SourcesConfiguration *sources.Configuration
}

func (finder *Finder) Find(domain string) (results chan sources.Result) {
results = make(chan sources.Result)

go func() {
defer close(results)

seenSubdomains := &sync.Map{}

wg := &sync.WaitGroup{}

for _, source := range finder.Sources {
wg.Add(1)

go func(source sources.Source) {
defer wg.Done()

sResults := source.Run(finder.SourcesConfiguration, domain)

for sResult := range sResults {
if sResult.Type == sources.Subdomain {
sResult.Value = strings.ToLower(sResult.Value)
sResult.Value = strings.ReplaceAll(sResult.Value, "*.", "")

_, loaded := seenSubdomains.LoadOrStore(sResult.Value, struct{}{})
if loaded {
continue
}
}

results <- sResult
}
}(source)
}

wg.Wait()
}()

return
}

func New(options *Options) (finder *Finder) {
finder = &Finder{
Sources: map[string]sources.Source{},
Expand All @@ -45,8 +79,6 @@ func New(options *Options) (finder *Finder) {

for _, source := range options.SourcesToUSe {
switch source {
case "otx":
finder.Sources[source] = &otx.Source{}
case "anubis":
finder.Sources[source] = &anubis.Source{}
case "bevigil":
Expand All @@ -65,6 +97,8 @@ func New(options *Options) (finder *Finder) {
finder.Sources[source] = &hackertarget.Source{}
case "intelx":
finder.Sources[source] = &intelx.Source{}
case "otx":
finder.Sources[source] = &otx.Source{}
case "shodan":
finder.Sources[source] = &shodan.Source{}
case "urlscan":
Expand All @@ -80,43 +114,3 @@ func New(options *Options) (finder *Finder) {

return
}

func (finder *Finder) Find(domain string) (results chan sources.Result) {
results = make(chan sources.Result)

go func() {
defer close(results)

seenSubdomains := &sync.Map{}

wg := &sync.WaitGroup{}

for _, source := range finder.Sources {
wg.Add(1)

go func(source sources.Source) {
defer wg.Done()

sResults := source.Run(finder.SourcesConfiguration, domain)

for sResult := range sResults {
if sResult.Type == sources.Subdomain {
sResult.Value = strings.ToLower(sResult.Value)
sResult.Value = strings.ReplaceAll(sResult.Value, "*.", "")

_, loaded := seenSubdomains.LoadOrStore(sResult.Value, struct{}{})
if loaded {
continue
}
}

results <- sResult
}
}(source)
}

wg.Wait()
}()

return
}
9 changes: 9 additions & 0 deletions pkg/xsubfind3r/options.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package xsubfind3r

import "github.com/hueristiq/xsubfind3r/pkg/xsubfind3r/sources"

type Options struct {
SourcesToExclude []string
SourcesToUSe []string
Keys sources.Keys
}

0 comments on commit 0be1a9f

Please sign in to comment.