Merge branch 'master' into bing-passive-search
commit
a7836666fc
|
@ -36,6 +36,7 @@ import (
|
|||
"github.com/Ice3man543/subfinder/libsubfinder/sources/waybackarchive"
|
||||
"github.com/Ice3man543/subfinder/libsubfinder/sources/baidu"
|
||||
"github.com/Ice3man543/subfinder/libsubfinder/sources/bing"
|
||||
"github.com/Ice3man543/subfinder/libsubfinder/sources/ask"
|
||||
)
|
||||
|
||||
// Sources configuration structure specifying what should we use
|
||||
|
@ -60,6 +61,7 @@ type Source struct {
|
|||
Dnsdb bool
|
||||
Baidu bool
|
||||
Bing bool
|
||||
Ask bool
|
||||
|
||||
NoOfSources int
|
||||
}
|
||||
|
@ -90,7 +92,8 @@ func PassiveDiscovery(state *helper.State) (finalPassiveSubdomains []string) {
|
|||
fmt.Printf("\n[-] Searching For Subdomains in Netcraft")
|
||||
fmt.Printf("\n[-] Searching For Subdomains in Dnsdb")
|
||||
fmt.Printf("\n[-] Searching For Subdomains in Baidu")
|
||||
fmt.Printf("\n[-] Searching For Subdomains in Bing\n")
|
||||
fmt.Printf("\n[-] Searching For Subdomains in Bing")
|
||||
fmt.Printf("\n[-] Searching For Subdomains in Ask\n")
|
||||
}
|
||||
|
||||
sourceConfig = Source{true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, 19}
|
||||
|
@ -212,6 +215,11 @@ func PassiveDiscovery(state *helper.State) (finalPassiveSubdomains []string) {
|
|||
fmt.Printf("\n[-] Searching For Subdomains in Bing")
|
||||
}
|
||||
sourceConfig.Bing = true
|
||||
} else if source == "ask" {
|
||||
if state.Silent != true {
|
||||
fmt.Printf("\n[-] Searching For Subdomains in Ask")
|
||||
}
|
||||
sourceConfig.Ask = true
|
||||
sourceConfig.NoOfSources = sourceConfig.NoOfSources + 1
|
||||
}
|
||||
}
|
||||
|
@ -278,6 +286,8 @@ func PassiveDiscovery(state *helper.State) (finalPassiveSubdomains []string) {
|
|||
}
|
||||
if sourceConfig.Bing == true {
|
||||
go bing.Query(state, ch)
|
||||
if sourceConfig.Ask == true {
|
||||
go ask.Query(state, ch)
|
||||
}
|
||||
|
||||
// Recieve data from all goroutines running
|
||||
|
|
|
@ -0,0 +1,96 @@
|
|||
//
|
||||
// Written By : @Mzack9999 (Marco Rivoli)
|
||||
//
|
||||
// Distributed Under MIT License
|
||||
// Copyrights (C) 2018 Ice3man
|
||||
//
|
||||
|
||||
// A golang client for Ask Subdomain Discovery
|
||||
package ask
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"sort"
|
||||
"net/url"
|
||||
|
||||
"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
|
||||
min_iterations := 15
|
||||
max_iterations := 760
|
||||
search_query := ""
|
||||
current_page := 0
|
||||
for current_iteration := 0; current_iteration <= max_iterations; current_iteration++ {
|
||||
new_search_query := "site:" + state.Domain
|
||||
if len(subdomains) > 0 {
|
||||
new_search_query += " -www." + state.Domain
|
||||
}
|
||||
new_search_query = url.QueryEscape(new_search_query)
|
||||
if search_query != new_search_query {
|
||||
current_page = 0
|
||||
search_query = new_search_query
|
||||
}
|
||||
|
||||
resp, err := helper.GetHTTPResponse("http://www.ask.com/web?q=" + search_query + "&page=" + strconv.Itoa(current_page) + "&qid=8D6EE6BF52E0C04527E51F64F22C4534&o=0&l=dir&qsrc=998&qo=pagination", 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-z0-9]+\.)+` + state.Domain)
|
||||
match := re.FindAllString(src, -1)
|
||||
|
||||
new_subdomains_found := 0
|
||||
for _, subdomain := range match {
|
||||
if sort.StringsAreSorted(subdomains) == false {
|
||||
sort.Strings(subdomains)
|
||||
}
|
||||
|
||||
insert_index := sort.SearchStrings(subdomains, subdomain)
|
||||
if insert_index < len(subdomains) && subdomains[insert_index] == subdomain {
|
||||
continue
|
||||
}
|
||||
|
||||
if state.Verbose == true {
|
||||
if state.Color == true {
|
||||
fmt.Printf("\n[%sAsk%s] %s", helper.Red, helper.Reset, subdomain)
|
||||
} else {
|
||||
fmt.Printf("\n[Ask] %s", subdomain)
|
||||
}
|
||||
}
|
||||
|
||||
subdomains = append(subdomains, subdomain)
|
||||
new_subdomains_found++
|
||||
}
|
||||
// If no new subdomains are found exits after min_iterations
|
||||
if new_subdomains_found == 0 && current_iteration > min_iterations {
|
||||
break
|
||||
}
|
||||
current_page++
|
||||
}
|
||||
|
||||
result.Subdomains = subdomains
|
||||
result.Error = nil
|
||||
ch <- result
|
||||
}
|
19
main.go
19
main.go
|
@ -86,7 +86,24 @@ func main() {
|
|||
object := strings.Split(config, "=")
|
||||
|
||||
// Change value dynamically using reflect package
|
||||
reflect.ValueOf(&state.ConfigState).Elem().FieldByName(object[0]).SetString(object[1])
|
||||
if strings.EqualFold(object[0], "virustotalapikey") == true {
|
||||
reflect.ValueOf(&state.ConfigState).Elem().FieldByName("VirustotalAPIKey").SetString(object[1])
|
||||
} else if strings.EqualFold(object[0], "passivetotalusername") == true {
|
||||
reflect.ValueOf(&state.ConfigState).Elem().FieldByName("PassivetotalUsername").SetString(object[1])
|
||||
} else if strings.EqualFold(object[0], "passivetotalkey") == true {
|
||||
reflect.ValueOf(&state.ConfigState).Elem().FieldByName("PassivetotalKey").SetString(object[1])
|
||||
} else if strings.EqualFold(object[0], "securitytrailskey") == true {
|
||||
reflect.ValueOf(&state.ConfigState).Elem().FieldByName("SecurityTrailsKey").SetString(object[1])
|
||||
} else if strings.EqualFold(object[0], "riddleremail") == true {
|
||||
reflect.ValueOf(&state.ConfigState).Elem().FieldByName("RiddlerEmail").SetString(object[1])
|
||||
} else if strings.EqualFold(object[0], "riddlerpassword") == true {
|
||||
reflect.ValueOf(&state.ConfigState).Elem().FieldByName("RiddlerPassword").SetString(object[1])
|
||||
} else if strings.EqualFold(object[0], "censysusername") == true {
|
||||
reflect.ValueOf(&state.ConfigState).Elem().FieldByName("CensysUsername").SetString(object[1])
|
||||
} else if strings.EqualFold(object[0], "censyssecret") == true {
|
||||
reflect.ValueOf(&state.ConfigState).Elem().FieldByName("CensysSecret").SetString(object[1])
|
||||
}
|
||||
|
||||
configJson, _ := json.MarshalIndent(state.ConfigState, "", " ")
|
||||
err = ioutil.WriteFile(path, configJson, 0644)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue