Skip to content

Commit

Permalink
refactor: Refine extraction from crtsh
Browse files Browse the repository at this point in the history
  • Loading branch information
enenumxela committed Aug 4, 2023
1 parent 181a378 commit 834bc18
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion pkg/xsubfind3r/sources/crtsh/crtsh.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package crtsh
import (
"encoding/json"
"fmt"
"regexp"
"strings"

"github.com/hueristiq/xsubfind3r/pkg/xsubfind3r/extractor"
"github.com/hueristiq/xsubfind3r/pkg/xsubfind3r/httpclient"
"github.com/hueristiq/xsubfind3r/pkg/xsubfind3r/sources"
"github.com/valyala/fasthttp"
Expand Down Expand Up @@ -40,8 +42,21 @@ func (source *Source) Run(_ *sources.Configuration, domain string) (subdomainsCh
return
}

var regex *regexp.Regexp

regex, err = extractor.New(domain)
if err != nil {
return
}

for _, record := range getNameValuesResData {
for _, subdomain := range strings.Split(record.NameValue, "\n") {
for _, value := range strings.Split(record.NameValue, "\n") {
subdomain := regex.FindString(value)

if subdomain == "" {
continue
}

subdomainsChannel <- sources.Subdomain{Source: source.Name(), Value: subdomain}
}
}
Expand Down

0 comments on commit 834bc18

Please sign in to comment.