Skip to content

Commit

Permalink
Merge pull request #231 from vzamanillo/radpiddns-source
Browse files Browse the repository at this point in the history
Added RapidDNS source
  • Loading branch information
Mzack9999 authored May 16, 2020
2 parents f5373ad + 2b8eadf commit 35a27a0
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 1 deletion.
3 changes: 2 additions & 1 deletion config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ sources:
- hackertarget
- ipv4info
- passivetotal
- rapiddns
- securitytrails
- shodan
- sitedossier
Expand All @@ -40,4 +41,4 @@ passivetotal: []
securitytrails: []
shodan: []
urlscan: []
virustotal: []
virustotal: []
4 changes: 4 additions & 0 deletions pkg/passive/sources.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/projectdiscovery/subfinder/pkg/subscraping/sources/hackertarget"
"github.com/projectdiscovery/subfinder/pkg/subscraping/sources/ipv4info"
"github.com/projectdiscovery/subfinder/pkg/subscraping/sources/passivetotal"
"github.com/projectdiscovery/subfinder/pkg/subscraping/sources/rapiddns"
"github.com/projectdiscovery/subfinder/pkg/subscraping/sources/securitytrails"
"github.com/projectdiscovery/subfinder/pkg/subscraping/sources/shodan"
"github.com/projectdiscovery/subfinder/pkg/subscraping/sources/sitedossier"
Expand All @@ -42,6 +43,7 @@ var DefaultSources = []string{
"hackertarget",
"ipv4info",
"passivetotal",
"rapiddns",
"securitytrails",
"shodan",
"sitedossier",
Expand Down Expand Up @@ -102,6 +104,8 @@ func (a *Agent) addSources(sources []string) {
a.sources[source] = &ipv4info.Source{}
case "passivetotal":
a.sources[source] = &passivetotal.Source{}
case "rapiddns":
a.sources[source] = &rapiddns.Source{}
case "securitytrails":
a.sources[source] = &securitytrails.Source{}
case "shodan":
Expand Down
77 changes: 77 additions & 0 deletions pkg/subscraping/sources/rapiddns/rapiddns.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// Package rapiddns is a RapidDNS Scraping Engine in Golang
package rapiddns

import (
"context"
"io/ioutil"
"regexp"
"strings"

"github.com/projectdiscovery/subfinder/pkg/subscraping"
)

// RapidDNS is a struct for archiveurlsagent
type RapidDNS struct {
Results chan subscraping.Result
Session *subscraping.Session
}

var reNext = regexp.MustCompile("<td><a href=\"(.*?)\" target=\"_blank\">.*?</a></td>")

func (a *RapidDNS) enumerate(ctx context.Context, baseURL string) {
select {
case <-ctx.Done():
return
default:
}

resp, err := a.Session.NormalGetWithContext(ctx, baseURL)
if err != nil {
a.Results <- subscraping.Result{Source: "radpiddns", Type: subscraping.Error, Error: err}
return
}

// Get the response body
body, err := ioutil.ReadAll(resp.Body)
resp.Body.Close()
if err != nil {
a.Results <- subscraping.Result{Source: "radpiddns", Type: subscraping.Error, Error: err}
return
}

src := string(body)

for _, subdomain := range a.Session.Extractor.FindAllString(src, -1) {
a.Results <- subscraping.Result{Source: "radpiddns", Type: subscraping.Subdomain, Value: subdomain}
}

match1 := reNext.FindStringSubmatch(src)
if len(match1) > 0 {
a.enumerate(ctx, strings.TrimRight(match1[1], " "))
}
}

// Source is the passive scraping agent
type Source struct{}

// Run function returns all subdomains found with the service
func (s *Source) Run(ctx context.Context, domain string, session *subscraping.Session) <-chan subscraping.Result {
results := make(chan subscraping.Result)

aInstance := RapidDNS{
Session: session,
Results: results,
}

go func() {
aInstance.enumerate(ctx, "https://rapiddns.io/subdomain/"+domain+"?full=1")
close(aInstance.Results)
}()

return aInstance.Results
}

// Name returns the name of the source
func (s *Source) Name() string {
return "rapiddns"
}

0 comments on commit 35a27a0

Please sign in to comment.