From f07ef61dd626412b265c8a9cd4f3821e06321487 Mon Sep 17 00:00:00 2001 From: himanshudas Date: Thu, 26 Apr 2018 17:29:06 +0530 Subject: [PATCH] fixed DnsDB data source --- libsubfinder/engines/passive/passive.go | 18 +++++-- libsubfinder/sources/dnsdb/dnsdb.go | 63 +++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 libsubfinder/sources/dnsdb/dnsdb.go diff --git a/libsubfinder/engines/passive/passive.go b/libsubfinder/engines/passive/passive.go index a699e58..3e845b9 100644 --- a/libsubfinder/engines/passive/passive.go +++ b/libsubfinder/engines/passive/passive.go @@ -20,6 +20,7 @@ import ( "github.com/Ice3man543/subfinder/libsubfinder/sources/certdb" "github.com/Ice3man543/subfinder/libsubfinder/sources/certspotter" "github.com/Ice3man543/subfinder/libsubfinder/sources/crtsh" + "github.com/Ice3man543/subfinder/libsubfinder/sources/dnsdb" "github.com/Ice3man543/subfinder/libsubfinder/sources/dnsdumpster" "github.com/Ice3man543/subfinder/libsubfinder/sources/findsubdomains" "github.com/Ice3man543/subfinder/libsubfinder/sources/hackertarget" @@ -52,12 +53,13 @@ type Source struct { Waybackarchive bool Threatminer bool Riddler bool + Dnsdb bool NoOfSources int } func PassiveDiscovery(state *helper.State) (finalPassiveSubdomains []string) { - sourceConfig := Source{false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, 0} + sourceConfig := Source{false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, 0} fmt.Printf("\n") if state.Sources == "all" { @@ -78,10 +80,11 @@ func PassiveDiscovery(state *helper.State) (finalPassiveSubdomains []string) { fmt.Printf("\n[-] Searching For Subdomains in WaybackArchive") fmt.Printf("\n[-] Searching For Subdomains in ThreatMiner") fmt.Printf("\n[-] Searching For Subdomains in Riddler") - fmt.Printf("\n[-] Searching For Subdomains in Netcraft\n") + fmt.Printf("\n[-] Searching For Subdomains in Netcraft") + fmt.Printf("\n[-] Searching For Subdomains in Dnsdb\n") } - sourceConfig = Source{true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, 15} + sourceConfig = Source{true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, 16} } else { // Check data sources and create a source configuration structure @@ -177,6 +180,12 @@ func PassiveDiscovery(state *helper.State) (finalPassiveSubdomains []string) { } sourceConfig.Riddler = true sourceConfig.NoOfSources = sourceConfig.NoOfSources + 1 + } else if source == "dnsdb" { + if state.Silent != true { + fmt.Printf("\n[-] Searching For Subdomains in Dnsdb") + } + sourceConfig.Dnsdb = true + sourceConfig.NoOfSources = sourceConfig.NoOfSources +1 } } } @@ -231,6 +240,9 @@ func PassiveDiscovery(state *helper.State) (finalPassiveSubdomains []string) { if sourceConfig.Riddler == true { go riddler.Query(state, ch) } + if sourceConfig.Dnsdb == true { + go dnsdb.Query(state, ch) + } // Recieve data from all goroutines running for i := 0; i < sourceConfig.NoOfSources; i++ { diff --git a/libsubfinder/sources/dnsdb/dnsdb.go b/libsubfinder/sources/dnsdb/dnsdb.go new file mode 100644 index 0000000..f47f516 --- /dev/null +++ b/libsubfinder/sources/dnsdb/dnsdb.go @@ -0,0 +1,63 @@ +// +// Written By : @mehimansu (Himanshu Das) +// +// Distributed Under MIT License +// Copyrights (C) 2018 Ice3man +// + +// Golang driver from dnsdb.org +package dnsdb + +import ( + "fmt" + "io/ioutil" + "regexp" + "strings" + + "github.com/Ice3man543/subfinder/libsubfinder/helper" +) + +// all subdomains found +var subdomains []string + +// Query function returns all subdomains found using the service. +func Query(state *helper.State, ch chan helper.Result) { + var result helper.Result + result.Subdomains = subdomains + + // Make a http request to DnsDB + resp, err := helper.GetHTTPResponse("http://www.dnsdb.org/f/"+state.Domain+".dnsdb.org/", state.Timeout) + if err != nil { + result.Error = err + ch <- result + return + } + // Get the response body + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + result.Error = err + ch <- result + return + } + src := string(body) + re := regexp.MustCompile("]*?[^>]*>(.*?)") + match := re.FindAllStringSubmatch(src, -1) + + for _, subdomain := range match { + string_split := strings.Split(subdomain[0], "\">")[1] + finishedSub := strings.TrimRight(string_split, "") + + if state.Verbose == true { + if state.Color == true { + fmt.Printf("\n[%sDNSDB%s] %s", helper.Red, helper.Reset, finishedSub) + } else { + fmt.Printf("\n[DNSDB] %s", finishedSub) + } + } + + subdomains = append(subdomains, finishedSub) + } + result.Subdomains = subdomains + result.Error = nil + ch <- result +}