diff --git a/libsubfinder/engines/passive/passive.go b/libsubfinder/engines/passive/passive.go index 5d265e5..7157723 100644 --- a/libsubfinder/engines/passive/passive.go +++ b/libsubfinder/engines/passive/passive.go @@ -22,6 +22,7 @@ import ( "subfinder/libsubfinder/sources/findsubdomains" "subfinder/libsubfinder/sources/dnsdumpster" "subfinder/libsubfinder/sources/passivetotal" + "subfinder/libsubfinder/sources/ptrarchive" "subfinder/libsubfinder/sources/threatcrowd" "subfinder/libsubfinder/sources/virustotal" "subfinder/libsubfinder/sources/netcraft" @@ -37,11 +38,12 @@ func PassiveDiscovery(state *helper.State) (finalPassiveSubdomains []string) { fmt.Printf("\n[-] Searching For Subdomains in Findsubdomains") fmt.Printf("\n[-] Searching For Subdomains in DNSDumpster") fmt.Printf("\n[-] Searching For Subdomains in PassiveTotal") + fmt.Printf("\n[-] Searching For Subdomains in PTRArchive") fmt.Printf("\n[-] Searching For Subdomains in Hackertarget") fmt.Printf("\n[-] Searching For Subdomains in Virustotal") fmt.Printf("\n[-] Searching For Subdomains in Netcraft\n") - ch := make(chan helper.Result, 9) + ch := make(chan helper.Result, 10) // Create goroutines for added speed and recieve data via channels go crtsh.Query(state, ch) @@ -50,12 +52,13 @@ func PassiveDiscovery(state *helper.State) (finalPassiveSubdomains []string) { go findsubdomains.Query(state, ch) go dnsdumpster.Query(state, ch) go passivetotal.Query(state, ch) + go ptrarchive.Query(state, ch) go threatcrowd.Query(state, ch) go virustotal.Query(state, ch) go netcraft.Query(state, ch) // recieve data from all goroutines running - for i := 1; i <= 9; i++ { + for i := 1; i <= 10; i++ { result := <-ch if result.Error != nil { diff --git a/libsubfinder/sources/passivetotal/passivetotal.go b/libsubfinder/sources/passivetotal/passivetotal.go index 4bb4913..8bcf61c 100644 --- a/libsubfinder/sources/passivetotal/passivetotal.go +++ b/libsubfinder/sources/passivetotal/passivetotal.go @@ -98,4 +98,9 @@ func Query(state *helper.State, ch chan helper.Result) { result.Error = nil ch <-result } + + result.Subdomains = subdomains + result.Error = nil + ch <- result + return } diff --git a/libsubfinder/sources/ptrarchive/ptrarchive.go b/libsubfinder/sources/ptrarchive/ptrarchive.go new file mode 100644 index 0000000..5fe5e1e --- /dev/null +++ b/libsubfinder/sources/ptrarchive/ptrarchive.go @@ -0,0 +1,78 @@ +// +// ptrarchive.go : A PTRArchive subdomain parser in golang +// Written By : @ice3man (Nizamul Rana) +// +// Distributed Under MIT License +// Copyrights (C) 2018 Ice3man +// + +package ptrarchive + +import ( + "io/ioutil" + "fmt" + "regexp" + + "subfinder/libsubfinder/helper" +) + +// all subdomains found +var subdomains []string + +// +// Query : Queries awesome DNSDumpster service for subdomains +// @param state : current application state, holds all information found +// +func Query(state *helper.State, ch chan helper.Result) { + + var result helper.Result + result.Subdomains = subdomains + + // Make a http request to Netcraft + resp, err := helper.GetHTTPResponse("http://ptrarchive.com/tools/search2.htm?label="+state.Domain+"&date=ALL", 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) + + // Parse Subdomains found + Regex, _ := regexp.Compile("] (.*) \\[") + match := Regex.FindAllStringSubmatch(src, -1) + + // String to hold initial subdomains + var initialSubs []string + + for _, data := range match { + initialSubs = append(initialSubs, data[1]) + } + + validSubdomains := helper.Validate(state, initialSubs) + + for _, subdomain := range validSubdomains { + if state.Verbose == true { + if state.Color == true { + fmt.Printf("\n[%sPTRARCHIVE%s] %s", helper.Red, helper.Reset, subdomain) + } else { + fmt.Printf("\n[PTRARCHIVE] %s", subdomains) + } + } + + subdomains = append(subdomains, subdomain) + } + + + result.Subdomains = subdomains + result.Error = nil + ch <-result +}