Updated Timeout Handling and Fixed Concurrency Errors
parent
10581027bb
commit
59df043194
|
@ -13,6 +13,7 @@ package helper
|
|||
type State struct {
|
||||
Color bool // Whether to use color or not
|
||||
Threads int // Number of threads to use
|
||||
Timeout int // Timeout for requests to different passive sources
|
||||
Verbose bool // Show verbose information
|
||||
Domain string // Domain name to find subdomains for
|
||||
Recursive bool // Whether perform recursive subdomain discovery or not
|
||||
|
@ -32,5 +33,5 @@ func InitState() (state State, err error) {
|
|||
return state, err
|
||||
}
|
||||
|
||||
return State{true, 10, false, "", false, *config}, nil
|
||||
return State{true, 10, 180, false, "", false, *config}, nil
|
||||
}
|
||||
|
|
|
@ -39,11 +39,12 @@ func Query(state *helper.State, ch chan helper.Result) {
|
|||
result.Subdomains = subdomains
|
||||
|
||||
// Make a http request to Certspotter
|
||||
resp, err := helper.GetHTTPResponse("https://certspotter.com/api/v0/certs?domain="+state.Domain, 3000)
|
||||
resp, err := helper.GetHTTPResponse("https://certspotter.com/api/v0/certs?domain="+state.Domain, state.Timeout)
|
||||
if err != nil {
|
||||
// Set values and return
|
||||
result.Error = err
|
||||
ch <- result
|
||||
return
|
||||
}
|
||||
|
||||
// Get the response body
|
||||
|
@ -51,6 +52,7 @@ func Query(state *helper.State, ch chan helper.Result) {
|
|||
if err != nil {
|
||||
result.Error = err
|
||||
ch <- result
|
||||
return
|
||||
}
|
||||
|
||||
// Decode the json format
|
||||
|
@ -58,6 +60,7 @@ func Query(state *helper.State, ch chan helper.Result) {
|
|||
if err != nil {
|
||||
result.Error = err
|
||||
ch <- result
|
||||
return
|
||||
}
|
||||
|
||||
// Append each subdomain found to subdomains array
|
||||
|
|
|
@ -41,10 +41,11 @@ func Query(state *helper.State, ch chan helper.Result) {
|
|||
// Make a http request to CRT.SH server and request output in JSON
|
||||
// format.
|
||||
// I Think 5 minutes would be more than enough for CRT.SH :-)
|
||||
resp, err := helper.GetHTTPResponse("https://crt.sh/?q=%25."+state.Domain+"&output=json", 3000)
|
||||
resp, err := helper.GetHTTPResponse("https://crt.sh/?q=%25."+state.Domain+"&output=json", state.Timeout)
|
||||
if err != nil {
|
||||
result.Error = err
|
||||
ch <- result
|
||||
return
|
||||
}
|
||||
|
||||
// Get the response body
|
||||
|
@ -52,6 +53,7 @@ func Query(state *helper.State, ch chan helper.Result) {
|
|||
if err != nil {
|
||||
result.Error = err
|
||||
ch <- result
|
||||
return
|
||||
}
|
||||
|
||||
if strings.Contains(string(resp_body), "The requested URL / was not found on this server.") {
|
||||
|
@ -59,6 +61,7 @@ func Query(state *helper.State, ch chan helper.Result) {
|
|||
// move back
|
||||
result.Error = nil
|
||||
ch <- result
|
||||
return
|
||||
}
|
||||
|
||||
// Convert Response Body to string and then replace }{ to },{
|
||||
|
@ -78,6 +81,7 @@ func Query(state *helper.State, ch chan helper.Result) {
|
|||
if err != nil {
|
||||
result.Error = err
|
||||
ch <- result
|
||||
return
|
||||
}
|
||||
|
||||
// Append each subdomain found to subdomains array
|
||||
|
|
|
@ -27,7 +27,7 @@ import (
|
|||
//
|
||||
func Query(state *helper.State) (subdomains []string, err error) {
|
||||
|
||||
resp, err := helper.GetHTTPResponse("https://www.dnsdb.org/f/"+state.Domain+".dnsdb.org/", 3000)
|
||||
resp, err := helper.GetHTTPResponse("https://www.dnsdb.org/f/"+state.Domain+".dnsdb.org/", state.Timeout)
|
||||
if err != nil {
|
||||
return subdomains, err
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ func Query(state *helper.State) (subdomains []string, err error) {
|
|||
|
||||
body := string(resp_body)
|
||||
|
||||
re := regexp.MustCompile("(?<=href=\").+?(?=\")|(?<=href=').+?(?=')")
|
||||
re := regexp.MustCompile(" (?<=href=\").+?(?=\")|(?<=href=').+?(?=')")
|
||||
match := re.FindAllStringSubmatch(body, -1)
|
||||
|
||||
for _, subdomain := range match {
|
||||
|
|
|
@ -29,10 +29,11 @@ func Query(state *helper.State, ch chan helper.Result) {
|
|||
var result helper.Result
|
||||
result.Subdomains = subdomains
|
||||
|
||||
resp, err := helper.GetHTTPResponse("https://api.hackertarget.com/hostsearch/?q="+state.Domain, 3000)
|
||||
resp, err := helper.GetHTTPResponse("https://api.hackertarget.com/hostsearch/?q="+state.Domain, state.Timeout)
|
||||
if err != nil {
|
||||
result.Error = err
|
||||
ch <- result
|
||||
return
|
||||
}
|
||||
|
||||
// Get the response body
|
||||
|
@ -40,6 +41,7 @@ func Query(state *helper.State, ch chan helper.Result) {
|
|||
if err != nil {
|
||||
result.Error = err
|
||||
ch <- result
|
||||
return
|
||||
}
|
||||
|
||||
scanner := bufio.NewScanner(strings.NewReader(string(resp_body)))
|
||||
|
|
|
@ -36,7 +36,7 @@ var gCookies []*http.Cookie
|
|||
func enumerate(state *helper.State, baseUrl string) (err error) {
|
||||
|
||||
// Make a http request to Netcraft
|
||||
resp, gCookies, err := helper.GetHTTPCookieResponse(baseUrl, gCookies, 3000)
|
||||
resp, gCookies, err := helper.GetHTTPCookieResponse(baseUrl, gCookies, state.Timeout)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -124,6 +124,7 @@ func Query(state *helper.State, ch chan helper.Result) {
|
|||
result.Subdomains = globalSubdomains
|
||||
result.Error = err
|
||||
ch <- result
|
||||
return
|
||||
}
|
||||
|
||||
result.Subdomains = globalSubdomains
|
||||
|
|
|
@ -38,10 +38,11 @@ func Query(state *helper.State, ch chan helper.Result) {
|
|||
result.Subdomains = subdomains
|
||||
|
||||
// Make a http request to Threatcrowd
|
||||
resp, err := helper.GetHTTPResponse("https://www.threatcrowd.org/searchApi/v2/domain/report/?domain="+state.Domain, 3000)
|
||||
resp, err := helper.GetHTTPResponse("https://www.threatcrowd.org/searchApi/v2/domain/report/?domain="+state.Domain, state.Timeout)
|
||||
if err != nil {
|
||||
result.Error = err
|
||||
ch <- result
|
||||
return
|
||||
}
|
||||
|
||||
// Get the response body
|
||||
|
@ -49,6 +50,7 @@ func Query(state *helper.State, ch chan helper.Result) {
|
|||
if err != nil {
|
||||
result.Error = err
|
||||
ch <- result
|
||||
return
|
||||
}
|
||||
|
||||
// Decode the json format
|
||||
|
@ -56,6 +58,7 @@ func Query(state *helper.State, ch chan helper.Result) {
|
|||
if err != nil {
|
||||
result.Error = err
|
||||
ch <- result
|
||||
return
|
||||
}
|
||||
|
||||
// Append each subdomain found to subdomains array
|
||||
|
|
|
@ -37,7 +37,7 @@ var virustotalapi_data virustotalapi_object
|
|||
func queryVirustotalApi(state *helper.State) (subdomains []string, err error) {
|
||||
|
||||
// Make a search for a domain name and get HTTP Response
|
||||
resp, err := helper.GetHTTPResponse("https://www.virustotal.com/vtapi/v2/domain/report?apikey="+state.ConfigState.VirustotalAPIKey+"&domain="+state.Domain, 3000)
|
||||
resp, err := helper.GetHTTPResponse("https://www.virustotal.com/vtapi/v2/domain/report?apikey="+state.ConfigState.VirustotalAPIKey+"&domain="+state.Domain, state.Timeout)
|
||||
if err != nil {
|
||||
return subdomains, err
|
||||
}
|
||||
|
@ -95,6 +95,7 @@ func Query(state *helper.State, ch chan helper.Result) {
|
|||
result.Subdomains = subdomains
|
||||
result.Error = err
|
||||
ch <- result
|
||||
return
|
||||
}
|
||||
|
||||
result.Subdomains = subdomains
|
||||
|
|
1
main.go
1
main.go
|
@ -37,6 +37,7 @@ func ParseCmdLine() (state *helper.State, err error) {
|
|||
flag.BoolVar(&s.Verbose, "v", false, "Verbose output")
|
||||
flag.BoolVar(&s.Color, "c", true, "Use colour in outpout")
|
||||
flag.IntVar(&s.Threads, "t", 10, "Number of concurrent threads")
|
||||
flag.IntVar(&s.Timeout, "timeout", 180, "Timeout for passive discovery services")
|
||||
flag.StringVar(&s.Domain, "d", "", "Domain to find subdomains for")
|
||||
flag.BoolVar(&s.Recursive, "r", true, "Use recursion to find subdomains")
|
||||
|
||||
|
|
Loading…
Reference in New Issue