fixed DnsDB data source

master
himanshudas 2018-04-26 17:29:06 +05:30
parent cd43240dde
commit f07ef61dd6
2 changed files with 78 additions and 3 deletions

View File

@ -20,6 +20,7 @@ import (
"github.com/Ice3man543/subfinder/libsubfinder/sources/certdb" "github.com/Ice3man543/subfinder/libsubfinder/sources/certdb"
"github.com/Ice3man543/subfinder/libsubfinder/sources/certspotter" "github.com/Ice3man543/subfinder/libsubfinder/sources/certspotter"
"github.com/Ice3man543/subfinder/libsubfinder/sources/crtsh" "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/dnsdumpster"
"github.com/Ice3man543/subfinder/libsubfinder/sources/findsubdomains" "github.com/Ice3man543/subfinder/libsubfinder/sources/findsubdomains"
"github.com/Ice3man543/subfinder/libsubfinder/sources/hackertarget" "github.com/Ice3man543/subfinder/libsubfinder/sources/hackertarget"
@ -52,12 +53,13 @@ type Source struct {
Waybackarchive bool Waybackarchive bool
Threatminer bool Threatminer bool
Riddler bool Riddler bool
Dnsdb bool
NoOfSources int NoOfSources int
} }
func PassiveDiscovery(state *helper.State) (finalPassiveSubdomains []string) { 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") fmt.Printf("\n")
if state.Sources == "all" { 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 WaybackArchive")
fmt.Printf("\n[-] Searching For Subdomains in ThreatMiner") fmt.Printf("\n[-] Searching For Subdomains in ThreatMiner")
fmt.Printf("\n[-] Searching For Subdomains in Riddler") 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 { } else {
// Check data sources and create a source configuration structure // Check data sources and create a source configuration structure
@ -177,6 +180,12 @@ func PassiveDiscovery(state *helper.State) (finalPassiveSubdomains []string) {
} }
sourceConfig.Riddler = true sourceConfig.Riddler = true
sourceConfig.NoOfSources = sourceConfig.NoOfSources + 1 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 { if sourceConfig.Riddler == true {
go riddler.Query(state, ch) go riddler.Query(state, ch)
} }
if sourceConfig.Dnsdb == true {
go dnsdb.Query(state, ch)
}
// Recieve data from all goroutines running // Recieve data from all goroutines running
for i := 0; i < sourceConfig.NoOfSources; i++ { for i := 0; i < sourceConfig.NoOfSources; i++ {

View File

@ -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("<a[^>]*?[^>]*>(.*?)</a>")
match := re.FindAllStringSubmatch(src, -1)
for _, subdomain := range match {
string_split := strings.Split(subdomain[0], "\">")[1]
finishedSub := strings.TrimRight(string_split, "</a>")
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
}