Merge branch 'master' into mzack9999-refactor-as-embeddable

master
mzack 2018-06-28 20:28:26 +02:00
commit a7d571a217
19 changed files with 76 additions and 73 deletions

View File

@ -28,9 +28,9 @@ func consume(args ...interface{}) interface{} {
return "" return ""
} }
if state.IsWildcard == true { if state.IsWildcard {
result := helper.CheckWildcard(state, ips) result := helper.CheckWildcard(state, ips)
if result == true { if result {
// We have a wildcard ip // We have a wildcard ip
return "" return ""
} }

View File

@ -387,13 +387,13 @@ func (s *Source) printSummary() {
} }
func (s *Source) parseAPIKeys(state *helper.State) { func (s *Source) parseAPIKeys(state *helper.State) {
if state.ConfigState.CensysUsername == "" && state.ConfigState.CensysSecret == "" { if state.ConfigState.CensysUsername == "" || state.ConfigState.CensysSecret == "" {
s.Censys = false s.Censys = false
} }
if state.ConfigState.PassivetotalUsername == "" && state.ConfigState.PassivetotalKey == "" { if state.ConfigState.PassivetotalUsername == "" || state.ConfigState.PassivetotalKey == "" {
s.Passivetotal = false s.Passivetotal = false
} }
if state.ConfigState.RiddlerEmail == "" && state.ConfigState.RiddlerPassword == "" { if state.ConfigState.RiddlerEmail == "" || state.ConfigState.RiddlerPassword == "" {
s.Riddler = false s.Riddler = false
} }
if state.ConfigState.SecurityTrailsKey == "" { if state.ConfigState.SecurityTrailsKey == "" {
@ -408,7 +408,6 @@ func (s *Source) parseAPIKeys(state *helper.State) {
if state.ConfigState.VirustotalAPIKey == "" { if state.ConfigState.VirustotalAPIKey == "" {
s.Virustotal = false s.Virustotal = false
} }
return
} }
//nbrActive ses reflection to get automatic active amount of searches //nbrActive ses reflection to get automatic active amount of searches
@ -438,8 +437,8 @@ func discover(state *helper.State, domain string, sourceConfig *Source) (subdoma
// Initialize Wildcard Subdomains // Initialize Wildcard Subdomains
state.IsWildcard, state.WildcardIP = helper.InitWildcard(domain) state.IsWildcard, state.WildcardIP = helper.InitWildcard(domain)
if state.IsWildcard == true { if state.IsWildcard {
if state.Silent != true { if !state.Silent {
fmt.Printf("\nFound Wildcard DNS at %s", domain) fmt.Printf("\nFound Wildcard DNS at %s", domain)
for _, ip := range state.WildcardIP { for _, ip := range state.WildcardIP {
fmt.Printf("\n - %s", ip) fmt.Printf("\n - %s", ip)
@ -452,7 +451,7 @@ func discover(state *helper.State, domain string, sourceConfig *Source) (subdoma
domainDiscoverPool.Wait() domainDiscoverPool.Wait()
if state.Silent != true { if !state.Silent {
fmt.Printf("\nRunning enumeration on %s\n", domain) fmt.Printf("\nRunning enumeration on %s\n", domain)
} }
@ -561,9 +560,7 @@ func discover(state *helper.State, domain string, sourceConfig *Source) (subdoma
} }
} }
results := job.Result.([]string) results := job.Result.([]string)
for _, subdomain := range results { finalPassiveSubdomains = append(finalPassiveSubdomains, results...)
finalPassiveSubdomains = append(finalPassiveSubdomains, subdomain)
}
} }
domainDiscoverPool.Stop() domainDiscoverPool.Stop()
@ -576,7 +573,7 @@ func discover(state *helper.State, domain string, sourceConfig *Source) (subdoma
var words []string var words []string
var BruteforceSubdomainList []string var BruteforceSubdomainList []string
// Start the bruteforcing workflow if the user has asked for it // Start the bruteforcing workflow if the user has asked for it
if state.Bruteforce == true && state.Wordlist != "" { if state.Bruteforce && state.Wordlist != "" {
file, err := os.Open(state.Wordlist) file, err := os.Open(state.Wordlist)
if err != nil { if err != nil {
fmt.Fprintf(os.Stderr, "\nerror: %v\n", err) fmt.Fprintf(os.Stderr, "\nerror: %v\n", err)
@ -592,7 +589,7 @@ func discover(state *helper.State, domain string, sourceConfig *Source) (subdoma
words = append(words, scanner.Text()) words = append(words, scanner.Text())
} }
if state.Silent != true { if !state.Silent {
fmt.Printf("\n\nStarting Bruteforcing of %s%s%s with %s%d%s words", helper.Info, domain, helper.Reset, helper.Info, len(words), helper.Reset) fmt.Printf("\n\nStarting Bruteforcing of %s%s%s with %s%d%s words", helper.Info, domain, helper.Reset, helper.Info, len(words), helper.Reset)
} }
@ -610,7 +607,7 @@ func discover(state *helper.State, domain string, sourceConfig *Source) (subdoma
if state.Alive || state.AquatoneJSON { if state.Alive || state.AquatoneJSON {
// Nove remove all wildcard subdomains // Nove remove all wildcard subdomains
if state.Silent != true { if !state.Silent {
fmt.Printf("\n\nResolving %s%d%s Unique Hosts found", helper.Info, len(validPassiveSubdomains), helper.Reset) fmt.Printf("\n\nResolving %s%d%s Unique Hosts found", helper.Info, len(validPassiveSubdomains), helper.Reset)
} }
passiveSubdomainsArray = resolver.Resolve(state, validPassiveSubdomains) passiveSubdomainsArray = resolver.Resolve(state, validPassiveSubdomains)
@ -638,7 +635,7 @@ func discover(state *helper.State, domain string, sourceConfig *Source) (subdoma
if state.Alive || state.AquatoneJSON { if state.Alive || state.AquatoneJSON {
for _, subdomain := range passiveSubdomainsArray { for _, subdomain := range passiveSubdomainsArray {
if state.Silent != true { if !state.Silent {
fmt.Printf("\n%s\t\t%s", subdomain.IP, subdomain.Fqdn) fmt.Printf("\n%s\t\t%s", subdomain.IP, subdomain.Fqdn)
} else { } else {
fmt.Printf("\n%s", subdomain.Fqdn) fmt.Printf("\n%s", subdomain.Fqdn)
@ -713,22 +710,20 @@ func Enumerate(state *helper.State) []string {
completedJobs := passivePool.Results() completedJobs := passivePool.Results()
for _, job := range completedJobs { for _, job := range completedJobs {
if job.Result != nil { if job.Result == nil {
continue
}
results := job.Result.([]string) results := job.Result.([]string)
if state.Output != "" { if state.Output != "" && state.IsJSON {
if state.IsJSON == true {
err := output.WriteOutputJSON(state, results) err := output.WriteOutputJSON(state, results)
if err != nil { if err != nil && state.Silent {
if state.Silent == true {
fmt.Printf("\n%s-> %v%s\n", helper.Bad, err, helper.Reset) fmt.Printf("\n%s-> %v%s\n", helper.Bad, err, helper.Reset)
} }
} }
}
}
allSubdomains = append(allSubdomains, results...) allSubdomains = append(allSubdomains, results...)
} }
}
passivePool.Stop() passivePool.Stop()

View File

@ -26,9 +26,9 @@ func consume(args ...interface{}) interface{} {
return "" return ""
} }
if state.IsWildcard == true { if state.IsWildcard {
result := helper.CheckWildcard(state, ips) result := helper.CheckWildcard(state, ips)
if result == true { if result {
// We have a wildcard ip // We have a wildcard ip
return "" return ""
} }
@ -65,8 +65,8 @@ func Resolve(state *helper.State, list []string) (subdomains []helper.Domain) {
fqdn := job.Args[0].(string) fqdn := job.Args[0].(string)
ip := job.Result.(string) ip := job.Result.(string)
subdomain := helper.Domain{IP: ip, Fqdn: fqdn} subdomain := helper.Domain{IP: ip, Fqdn: fqdn}
if state.Silent != true { if !state.Silent {
if state.Verbose == true { if state.Verbose {
fmt.Printf("\n[%sRESOLVED%s] %s : %s", helper.Info, helper.Reset, subdomain.Fqdn, subdomain.IP) fmt.Printf("\n[%sRESOLVED%s] %s : %s", helper.Info, helper.Reset, subdomain.Fqdn, subdomain.IP)
} }
} }

View File

@ -54,7 +54,7 @@ func Unique(elements []string) []string {
result := []string{} result := []string{}
for v := range elements { for v := range elements {
if encountered[elements[v]] == true { if encountered[elements[v]] {
// Do not add duplicate. // Do not add duplicate.
} else { } else {
// Record this element as an encountered element. // Record this element as an encountered element.

View File

@ -92,7 +92,7 @@ func WriteOutputAquatoneJSON(state *helper.State, subdomains []helper.Domain) er
// WriteOutputToDir writes output state into a directory // WriteOutputToDir writes output state into a directory
func WriteOutputToDir(state *helper.State, subdomains []string, domain string) (err error) { func WriteOutputToDir(state *helper.State, subdomains []string, domain string) (err error) {
if state.OutputDir != "" { if state.OutputDir != "" {
if state.IsJSON == false { if !state.IsJSON {
file, err := os.Create(state.OutputDir + domain + "_hosts.txt") file, err := os.Create(state.OutputDir + domain + "_hosts.txt")
if err != nil { if err != nil {

View File

@ -38,9 +38,9 @@ func enumerate(state *helper.State, baseURL string, domain string) (err error) {
for _, subdomain := range match { for _, subdomain := range match {
finishedSub := subdomain finishedSub := subdomain
if helper.SubdomainExists(finishedSub, globalSubdomains) == false { if !helper.SubdomainExists(finishedSub, globalSubdomains) {
if state.Verbose == true { if state.Verbose {
if state.Color == true { if state.Color {
fmt.Printf("\n[%sARCHIVE.IS%s] %s", helper.Red, helper.Reset, finishedSub) fmt.Printf("\n[%sARCHIVE.IS%s] %s", helper.Red, helper.Reset, finishedSub)
} else { } else {
fmt.Printf("\n[ARCHIVE.IS] %s", finishedSub) fmt.Printf("\n[ARCHIVE.IS] %s", finishedSub)

View File

@ -64,7 +64,7 @@ func Query(args ...interface{}) (i interface{}) {
newSubdomainsFound := 0 newSubdomainsFound := 0
for _, subdomain := range match { for _, subdomain := range match {
if sort.StringsAreSorted(subdomains) == false { if !sort.StringsAreSorted(subdomains) {
sort.Strings(subdomains) sort.Strings(subdomains)
} }
@ -73,8 +73,8 @@ func Query(args ...interface{}) (i interface{}) {
continue continue
} }
if state.Verbose == true { if state.Verbose {
if state.Color == true { if state.Color {
fmt.Printf("\n[%sAsk%s] %s", helper.Red, helper.Reset, subdomain) fmt.Printf("\n[%sAsk%s] %s", helper.Red, helper.Reset, subdomain)
} else { } else {
fmt.Printf("\n[Ask] %s", subdomain) fmt.Printf("\n[Ask] %s", subdomain)

View File

@ -66,7 +66,7 @@ func Query(args ...interface{}) interface{} {
newSubdomainsFound := 0 newSubdomainsFound := 0
for _, subdomain := range match { for _, subdomain := range match {
if sort.StringsAreSorted(subdomains) == false { if !sort.StringsAreSorted(subdomains) {
sort.Strings(subdomains) sort.Strings(subdomains)
} }
@ -75,8 +75,8 @@ func Query(args ...interface{}) interface{} {
continue continue
} }
if state.Verbose == true { if state.Verbose {
if state.Color == true { if state.Color {
fmt.Printf("\n[%sBaidu%s] %s", helper.Red, helper.Reset, subdomain) fmt.Printf("\n[%sBaidu%s] %s", helper.Red, helper.Reset, subdomain)
} else { } else {
fmt.Printf("\n[Baidu] %s", subdomain) fmt.Printf("\n[Baidu] %s", subdomain)

View File

@ -66,7 +66,7 @@ func Query(args ...interface{}) interface{} {
newSubdomainsFound := 0 newSubdomainsFound := 0
for _, subdomain := range match { for _, subdomain := range match {
if sort.StringsAreSorted(subdomains) == false { if !sort.StringsAreSorted(subdomains) {
sort.Strings(subdomains) sort.Strings(subdomains)
} }
@ -75,8 +75,8 @@ func Query(args ...interface{}) interface{} {
continue continue
} }
if state.Verbose == true { if state.Verbose {
if state.Color == true { if state.Color {
fmt.Printf("\n[%sBing%s] %s", helper.Red, helper.Reset, subdomain) fmt.Printf("\n[%sBing%s] %s", helper.Red, helper.Reset, subdomain)
} else { } else {
fmt.Printf("\n[Bing] %s", subdomain) fmt.Printf("\n[Bing] %s", subdomain)

View File

@ -52,6 +52,10 @@ func Query(args ...interface{}) interface{} {
username := state.ConfigState.CensysUsername username := state.ConfigState.CensysUsername
key := state.ConfigState.CensysSecret key := state.ConfigState.CensysSecret
if username == "" || key == "" {
return subdomains
}
if state.CurrentSettings.CensysPages != "all" { if state.CurrentSettings.CensysPages != "all" {
CensysPages, _ := strconv.Atoi(state.CurrentSettings.CensysPages) CensysPages, _ := strconv.Atoi(state.CurrentSettings.CensysPages)
@ -102,12 +106,8 @@ func Query(args ...interface{}) interface{} {
// Add all items found // Add all items found
for _, res := range hostResponse.Results { for _, res := range hostResponse.Results {
for _, host := range res.Data { initialSubdomains = append(initialSubdomains, res.Data...)
initialSubdomains = append(initialSubdomains, host) initialSubdomains = append(initialSubdomains, res.Data1...)
}
for _, host := range res.Data1 {
initialSubdomains = append(initialSubdomains, host)
}
} }
validSubdomains := helper.Validate(domain, initialSubdomains) validSubdomains := helper.Validate(domain, initialSubdomains)
@ -178,12 +178,8 @@ func Query(args ...interface{}) interface{} {
// Add all items found // Add all items found
for _, res := range hostResponse.Results { for _, res := range hostResponse.Results {
for _, host := range res.Data { initialSubdomains = append(initialSubdomains, res.Data...)
initialSubdomains = append(initialSubdomains, host) initialSubdomains = append(initialSubdomains, res.Data1...)
}
for _, host := range res.Data1 {
initialSubdomains = append(initialSubdomains, host)
}
} }
validSubdomains := helper.Validate(domain, initialSubdomains) validSubdomains := helper.Validate(domain, initialSubdomains)
@ -250,12 +246,8 @@ func Query(args ...interface{}) interface{} {
// Add all items found // Add all items found
for _, res := range hostResponse.Results { for _, res := range hostResponse.Results {
for _, host := range res.Data { initialSubdomains = append(initialSubdomains, res.Data...)
initialSubdomains = append(initialSubdomains, host) initialSubdomains = append(initialSubdomains, res.Data1...)
}
for _, host := range res.Data1 {
initialSubdomains = append(initialSubdomains, host)
}
} }
validSubdomains := helper.Validate(domain, initialSubdomains) validSubdomains := helper.Validate(domain, initialSubdomains)

View File

@ -51,7 +51,6 @@ func findSubdomains(link string, state *helper.State, channel chan []string) {
} }
channel <- subdomainsfound channel <- subdomainsfound
return
} }
// Query function returns all subdomains found using the service. // Query function returns all subdomains found using the service.

View File

@ -84,8 +84,6 @@ func printSubdomains(match [][]string, state *helper.State) {
subdomains = append(subdomains, finalSubdomain) subdomains = append(subdomains, finalSubdomain)
} }
} }
return
} }
// Query function returns all subdomains found using the service. // Query function returns all subdomains found using the service.

View File

@ -37,6 +37,10 @@ func Query(args ...interface{}) interface{} {
username := state.ConfigState.PassivetotalUsername username := state.ConfigState.PassivetotalUsername
key := state.ConfigState.PassivetotalKey key := state.ConfigState.PassivetotalKey
if username == "" || key == "" {
return subdomains
}
// Create JSON Get body // Create JSON Get body
var request = []byte(`{"query":"` + domain + `"}`) var request = []byte(`{"query":"` + domain + `"}`)

View File

@ -43,6 +43,10 @@ func Query(args ...interface{}) interface{} {
domain := args[0].(string) domain := args[0].(string)
state := args[1].(*helper.State) state := args[1].(*helper.State)
if state.ConfigState.RiddlerEmail == "" || state.ConfigState.RiddlerPassword == "" {
return subdomains
}
hc := http.Client{} hc := http.Client{}
var data = []byte(`{"email":"` + state.ConfigState.RiddlerEmail + `", "password":"` + state.ConfigState.RiddlerPassword + `"}`) var data = []byte(`{"email":"` + state.ConfigState.RiddlerEmail + `", "password":"` + state.ConfigState.RiddlerPassword + `"}`)

View File

@ -35,6 +35,10 @@ func Query(args ...interface{}) interface{} {
// Get credentials for performing HTTP Basic Auth // Get credentials for performing HTTP Basic Auth
securitytrailsKey := state.ConfigState.SecurityTrailsKey securitytrailsKey := state.ConfigState.SecurityTrailsKey
if securitytrailsKey == "" {
return subdomains
}
client := &http.Client{} client := &http.Client{}
req, err := http.NewRequest("GET", "https://api.securitytrails.com/v1/domain/"+domain+"/subdomains", nil) req, err := http.NewRequest("GET", "https://api.securitytrails.com/v1/domain/"+domain+"/subdomains", nil)
if err != nil { if err != nil {

View File

@ -41,6 +41,11 @@ func Query(args ...interface{}) interface{} {
state := args[1].(*helper.State) state := args[1].(*helper.State)
shodanAPIKey := state.ConfigState.ShodanAPIKey shodanAPIKey := state.ConfigState.ShodanAPIKey
if shodanAPIKey == "" {
return subdomains
}
maxPages, _ := strconv.Atoi(state.CurrentSettings.ShodanPages) maxPages, _ := strconv.Atoi(state.CurrentSettings.ShodanPages)
for currentPage := 0; currentPage <= maxPages; currentPage++ { for currentPage := 0; currentPage <= maxPages; currentPage++ {
resp, err := helper.GetHTTPResponse("https://api.shodan.io/shodan/host/search?query=hostname:"+domain+"&page="+strconv.Itoa(currentPage)+"&key="+shodanAPIKey, state.Timeout) resp, err := helper.GetHTTPResponse("https://api.shodan.io/shodan/host/search?query=hostname:"+domain+"&page="+strconv.Itoa(currentPage)+"&key="+shodanAPIKey, state.Timeout)

View File

@ -75,6 +75,10 @@ func Query(args ...interface{}) interface{} {
var subdomains []string var subdomains []string
if state.ConfigState.VirustotalAPIKey == "" {
return subdomains
}
// Get subdomains via API // Get subdomains via API
subdomains, err := queryVirustotalAPI(domain, state) subdomains, err := queryVirustotalAPI(domain, state)

View File

@ -55,7 +55,7 @@ func main() {
if !subfinder.State.Silent { if !subfinder.State.Silent {
fmt.Println("===============================================") fmt.Println("===============================================")
fmt.Printf("%s%s-=Subfinder%s v1.1 github.com/subfinder/subfinder\n", helper.Info, helper.Cyan, helper.Reset) fmt.Printf("%s%s-=Subfinder%s v1.1.1 github.com/subfinder/subfinder\n", helper.Info, helper.Cyan, helper.Reset)
fmt.Println("===============================================") fmt.Println("===============================================")
} }

View File

@ -108,9 +108,7 @@ func (s *Subfinder) parseComResolver() {
setResolvers := strings.Split(s.State.ComResolver, ",") setResolvers := strings.Split(s.State.ComResolver, ",")
for _, resolver := range setResolvers { s.State.LoadResolver = append(s.State.LoadResolver, setResolvers...)
s.State.LoadResolver = append(s.State.LoadResolver, resolver)
}
} }
func (s *Subfinder) parseListResolver() { func (s *Subfinder) parseListResolver() {