From 2caa74a2015fd6075820f78799b50fd470c4205f Mon Sep 17 00:00:00 2001 From: ice3man Date: Sun, 8 Apr 2018 13:49:26 +0530 Subject: [PATCH] Updated CertDB with Concurrency --- libsubfinder/helper/state.go | 4 +++- libsubfinder/sources/certdb/certdb.go | 30 +++++++++++++++++---------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/libsubfinder/helper/state.go b/libsubfinder/helper/state.go index 153ecc7..803364f 100644 --- a/libsubfinder/helper/state.go +++ b/libsubfinder/helper/state.go @@ -17,6 +17,8 @@ type State struct { Verbose bool // Show verbose information Domain string // Domain name to find subdomains for Recursive bool // Whether perform recursive subdomain discovery or not + Output string // Name of output file + IsJSON bool // Provide JSON output file Wordlist string // Wordlist file for subdomains bruteforcing Bruteforce bool // Flag to decide whether to bruteforce or not WildcardIPs []string // Wildcard IP Structure @@ -40,5 +42,5 @@ func InitState() (state State, err error) { return state, err } - return State{true, 10, 180, false, "", false, "", false, []string{}, true, *config}, nil + return State{true, 10, 180, false, "", false, "", false, "", false, []string{}, true, *config}, nil } diff --git a/libsubfinder/sources/certdb/certdb.go b/libsubfinder/sources/certdb/certdb.go index 06dadc7..d8686e1 100644 --- a/libsubfinder/sources/certdb/certdb.go +++ b/libsubfinder/sources/certdb/certdb.go @@ -20,23 +20,28 @@ import ( var subdomains []string // Parser subdomains from SSL Certificate Information Page -func findSubdomains(link string, state *helper.State) (subdomainsfound []string, err error) { +func findSubdomains(link string, state *helper.State, channel chan []string) { + var subdomainsfound []string + resp, err := helper.GetHTTPResponse("https://certdb.com"+link, state.Timeout) if err != nil { - return subdomainsfound, err + channel <- subdomainsfound + return } // Get the response body body, err := ioutil.ReadAll(resp.Body) if err != nil { - return subdomainsfound, err + channel <- subdomainsfound + return } src := string(body) SubdomainRegex, err := regexp.Compile("") if err != nil { - return subdomainsfound, err + channel <- subdomainsfound + return } match := SubdomainRegex.FindAllStringSubmatch(src, -1) @@ -45,7 +50,8 @@ func findSubdomains(link string, state *helper.State) (subdomainsfound []string, subdomainsfound = append(subdomainsfound, link[1]) } - return subdomainsfound, nil + channel <- subdomainsfound + return } // @@ -80,14 +86,16 @@ func Query(state *helper.State, ch chan helper.Result) { match := Regex.FindAllStringSubmatch(src, -1) var initialSubs []string + var subsReturned []string + + channel := make(chan []string, len(match)) for _, link := range match { - subsReturned, err := findSubdomains(link[1], state) - if err != nil { - result.Error = err - ch <- result - return - } + go findSubdomains(link[1], state, channel) + } + + for i:=0; i < len(match); i++ { + subsReturned = <-channel initialSubs = append(initialSubs, subsReturned...) }