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 ""
}
if state.IsWildcard == true {
if state.IsWildcard {
result := helper.CheckWildcard(state, ips)
if result == true {
if result {
// We have a wildcard ip
return ""
}

View File

@ -387,13 +387,13 @@ func (s *Source) printSummary() {
}
func (s *Source) parseAPIKeys(state *helper.State) {
if state.ConfigState.CensysUsername == "" && state.ConfigState.CensysSecret == "" {
if state.ConfigState.CensysUsername == "" || state.ConfigState.CensysSecret == "" {
s.Censys = false
}
if state.ConfigState.PassivetotalUsername == "" && state.ConfigState.PassivetotalKey == "" {
if state.ConfigState.PassivetotalUsername == "" || state.ConfigState.PassivetotalKey == "" {
s.Passivetotal = false
}
if state.ConfigState.RiddlerEmail == "" && state.ConfigState.RiddlerPassword == "" {
if state.ConfigState.RiddlerEmail == "" || state.ConfigState.RiddlerPassword == "" {
s.Riddler = false
}
if state.ConfigState.SecurityTrailsKey == "" {
@ -408,7 +408,6 @@ func (s *Source) parseAPIKeys(state *helper.State) {
if state.ConfigState.VirustotalAPIKey == "" {
s.Virustotal = false
}
return
}
//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
state.IsWildcard, state.WildcardIP = helper.InitWildcard(domain)
if state.IsWildcard == true {
if state.Silent != true {
if state.IsWildcard {
if !state.Silent {
fmt.Printf("\nFound Wildcard DNS at %s", domain)
for _, ip := range state.WildcardIP {
fmt.Printf("\n - %s", ip)
@ -452,7 +451,7 @@ func discover(state *helper.State, domain string, sourceConfig *Source) (subdoma
domainDiscoverPool.Wait()
if state.Silent != true {
if !state.Silent {
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)
for _, subdomain := range results {
finalPassiveSubdomains = append(finalPassiveSubdomains, subdomain)
}
finalPassiveSubdomains = append(finalPassiveSubdomains, results...)
}
domainDiscoverPool.Stop()
@ -576,7 +573,7 @@ func discover(state *helper.State, domain string, sourceConfig *Source) (subdoma
var words []string
var BruteforceSubdomainList []string
// 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)
if err != nil {
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())
}
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)
}
@ -610,7 +607,7 @@ func discover(state *helper.State, domain string, sourceConfig *Source) (subdoma
if state.Alive || state.AquatoneJSON {
// 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)
}
passiveSubdomainsArray = resolver.Resolve(state, validPassiveSubdomains)
@ -638,7 +635,7 @@ func discover(state *helper.State, domain string, sourceConfig *Source) (subdoma
if state.Alive || state.AquatoneJSON {
for _, subdomain := range passiveSubdomainsArray {
if state.Silent != true {
if !state.Silent {
fmt.Printf("\n%s\t\t%s", subdomain.IP, subdomain.Fqdn)
} else {
fmt.Printf("\n%s", subdomain.Fqdn)
@ -713,21 +710,19 @@ func Enumerate(state *helper.State) []string {
completedJobs := passivePool.Results()
for _, job := range completedJobs {
if job.Result != nil {
results := job.Result.([]string)
if state.Output != "" {
if state.IsJSON == true {
err := output.WriteOutputJSON(state, results)
if err != nil {
if state.Silent == true {
fmt.Printf("\n%s-> %v%s\n", helper.Bad, err, helper.Reset)
}
}
}
}
allSubdomains = append(allSubdomains, results...)
if job.Result == nil {
continue
}
results := job.Result.([]string)
if state.Output != "" && state.IsJSON {
err := output.WriteOutputJSON(state, results)
if err != nil && state.Silent {
fmt.Printf("\n%s-> %v%s\n", helper.Bad, err, helper.Reset)
}
}
allSubdomains = append(allSubdomains, results...)
}
passivePool.Stop()

View File

@ -26,9 +26,9 @@ func consume(args ...interface{}) interface{} {
return ""
}
if state.IsWildcard == true {
if state.IsWildcard {
result := helper.CheckWildcard(state, ips)
if result == true {
if result {
// We have a wildcard ip
return ""
}
@ -65,8 +65,8 @@ func Resolve(state *helper.State, list []string) (subdomains []helper.Domain) {
fqdn := job.Args[0].(string)
ip := job.Result.(string)
subdomain := helper.Domain{IP: ip, Fqdn: fqdn}
if state.Silent != true {
if state.Verbose == true {
if !state.Silent {
if state.Verbose {
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{}
for v := range elements {
if encountered[elements[v]] == true {
if encountered[elements[v]] {
// Do not add duplicate.
} else {
// 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
func WriteOutputToDir(state *helper.State, subdomains []string, domain string) (err error) {
if state.OutputDir != "" {
if state.IsJSON == false {
if !state.IsJSON {
file, err := os.Create(state.OutputDir + domain + "_hosts.txt")
if err != nil {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -43,6 +43,10 @@ func Query(args ...interface{}) interface{} {
domain := args[0].(string)
state := args[1].(*helper.State)
if state.ConfigState.RiddlerEmail == "" || state.ConfigState.RiddlerPassword == "" {
return subdomains
}
hc := http.Client{}
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
securitytrailsKey := state.ConfigState.SecurityTrailsKey
if securitytrailsKey == "" {
return subdomains
}
client := &http.Client{}
req, err := http.NewRequest("GET", "https://api.securitytrails.com/v1/domain/"+domain+"/subdomains", nil)
if err != nil {

View File

@ -41,6 +41,11 @@ func Query(args ...interface{}) interface{} {
state := args[1].(*helper.State)
shodanAPIKey := state.ConfigState.ShodanAPIKey
if shodanAPIKey == "" {
return subdomains
}
maxPages, _ := strconv.Atoi(state.CurrentSettings.ShodanPages)
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)

View File

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

View File

@ -55,7 +55,7 @@ func main() {
if !subfinder.State.Silent {
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("===============================================")
}

View File

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