Added PassiveTotal Support. Resolves #2
parent
05a36730e6
commit
c2789a771a
|
@ -1,3 +1,6 @@
|
|||
{
|
||||
"virustotalapikey":""
|
||||
"virustotalApikey":"",
|
||||
|
||||
"passivetotalUsername":"",
|
||||
"passivetotalKey":""
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import (
|
|||
"subfinder/libsubfinder/sources/hackertarget"
|
||||
"subfinder/libsubfinder/sources/findsubdomains"
|
||||
"subfinder/libsubfinder/sources/dnsdumpster"
|
||||
"subfinder/libsubfinder/sources/passivetotal"
|
||||
"subfinder/libsubfinder/sources/threatcrowd"
|
||||
"subfinder/libsubfinder/sources/virustotal"
|
||||
"subfinder/libsubfinder/sources/netcraft"
|
||||
|
@ -35,11 +36,12 @@ func PassiveDiscovery(state *helper.State) (finalPassiveSubdomains []string) {
|
|||
fmt.Printf("\n[-] Searching For Subdomains in Threatcrowd")
|
||||
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 Hackertarget")
|
||||
fmt.Printf("\n[-] Searching For Subdomains in Virustotal")
|
||||
fmt.Printf("\n[-] Searching For Subdomains in Netcraft\n")
|
||||
|
||||
ch := make(chan helper.Result, 8)
|
||||
ch := make(chan helper.Result, 9)
|
||||
|
||||
// Create goroutines for added speed and recieve data via channels
|
||||
go crtsh.Query(state, ch)
|
||||
|
@ -47,12 +49,13 @@ func PassiveDiscovery(state *helper.State) (finalPassiveSubdomains []string) {
|
|||
go hackertarget.Query(state, ch)
|
||||
go findsubdomains.Query(state, ch)
|
||||
go dnsdumpster.Query(state, ch)
|
||||
go passivetotal.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 <= 8; i++ {
|
||||
for i := 1; i <= 9; i++ {
|
||||
result := <-ch
|
||||
|
||||
if result.Error != nil {
|
||||
|
|
|
@ -26,7 +26,10 @@ type State struct {
|
|||
}
|
||||
|
||||
type Config struct {
|
||||
VirustotalAPIKey string `json:"virustotalapikey"` // Virustotal API Key
|
||||
VirustotalAPIKey string `json:"virustotalApikey"` // Virustotal API Key
|
||||
|
||||
PassivetotalUsername string `json:"passivetotalUsername"` // PassiveTotal Username (Email Address)
|
||||
PassivetotalKey string `json:"passivetotalKey"` // PassiveTotal api key
|
||||
}
|
||||
|
||||
func InitState() (state State, err error) {
|
||||
|
|
|
@ -0,0 +1,101 @@
|
|||
//
|
||||
// passivetotal.go : A golang client for Passive total Subdomain Discovery
|
||||
// Written By : @ice3man (Nizamul Rana)
|
||||
//
|
||||
// Distributed Under MIT License
|
||||
// Copyrights (C) 2018 Ice3man
|
||||
//
|
||||
|
||||
package passivetotal
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"fmt"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"bytes"
|
||||
|
||||
"subfinder/libsubfinder/helper"
|
||||
)
|
||||
|
||||
type passivetotal_object struct {
|
||||
Subdomains []string `json:"subdomains"`
|
||||
}
|
||||
|
||||
var passivetotal_data passivetotal_object
|
||||
|
||||
// all subdomains found
|
||||
var subdomains []string
|
||||
|
||||
//
|
||||
// Query : Queries awesome Passivetotal Service for Subdomains
|
||||
// @param state : Current application state
|
||||
//
|
||||
func Query(state *helper.State, ch chan helper.Result) {
|
||||
|
||||
var result helper.Result
|
||||
|
||||
// We have recieved an API Key
|
||||
// Now, we will use Virustotal API key to fetch subdomain info
|
||||
if state.ConfigState.PassivetotalUsername != "" && state.ConfigState.PassivetotalKey != "" {
|
||||
|
||||
// Get credentials for performing HTTP Basic Auth
|
||||
username := state.ConfigState.PassivetotalUsername
|
||||
key := state.ConfigState.PassivetotalKey
|
||||
|
||||
// Create JSON Get body
|
||||
var request = []byte(`{"query":"`+state.Domain+`"}`)
|
||||
|
||||
client := &http.Client{}
|
||||
req, err := http.NewRequest("GET", "https://api.passivetotal.org/v2/enrichment/subdomains", bytes.NewBuffer(request))
|
||||
req.SetBasicAuth(username, key)
|
||||
|
||||
// Set content type as application/json
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
result.Subdomains = subdomains
|
||||
result.Error = err
|
||||
ch <- result
|
||||
return
|
||||
}
|
||||
|
||||
// Get the response body
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
result.Subdomains = subdomains
|
||||
result.Error = err
|
||||
ch <- result
|
||||
return
|
||||
}
|
||||
|
||||
// Decode the json format
|
||||
err = json.Unmarshal([]byte(body), &passivetotal_data)
|
||||
if err != nil {
|
||||
result.Subdomains = subdomains
|
||||
result.Error = err
|
||||
ch <- result
|
||||
return
|
||||
}
|
||||
|
||||
// Append each subdomain found to subdomains array
|
||||
for _, subdomain := range passivetotal_data.Subdomains {
|
||||
finalSubdomain := subdomain+"."+state.Domain
|
||||
|
||||
if state.Verbose == true {
|
||||
if state.Color == true {
|
||||
fmt.Printf("\n[%sPASSIVETOTAL%s] %s", helper.Red, helper.Reset, finalSubdomain)
|
||||
} else {
|
||||
fmt.Printf("\n[PASSIVETOTAL] %s", finalSubdomain)
|
||||
}
|
||||
}
|
||||
|
||||
subdomains = append(subdomains, finalSubdomain)
|
||||
}
|
||||
|
||||
result.Subdomains = subdomains
|
||||
result.Error = nil
|
||||
ch <-result
|
||||
}
|
||||
}
|
|
@ -102,4 +102,11 @@ func Query(state *helper.State, ch chan helper.Result) {
|
|||
result.Error = nil
|
||||
ch <-result
|
||||
}
|
||||
|
||||
var subdomains []string
|
||||
|
||||
result.Subdomains = subdomains
|
||||
result.Error = nil
|
||||
ch <- result
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue