Skip to content

Commit

Permalink
Fixed error handling removing ineffectual assignments
Browse files Browse the repository at this point in the history
  • Loading branch information
Ice3man543 committed Jun 25, 2018
1 parent 3a41a23 commit 0b89802
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 0 deletions.
9 changes: 9 additions & 0 deletions libsubfinder/output/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ func WriteOutputJSON(state *helper.State, subdomains []string) error {

// Write the output to file
err = ioutil.WriteFile(state.Output, data, 0644)
if err != nil {
return err
}

return nil
}
Expand All @@ -79,6 +82,9 @@ func WriteOutputAquatoneJSON(state *helper.State, subdomains []helper.Domain) er

// Write the output to file
err = ioutil.WriteFile(state.Output, data, 0644)
if err != nil {
return err
}

return nil
}
Expand Down Expand Up @@ -118,6 +124,9 @@ func WriteOutputToDir(state *helper.State, subdomains []string, domain string) (

// Write the output to file
err = ioutil.WriteFile(state.OutputDir+domain+"_hosts.json", data, 0644)
if err != nil {
return err
}

return nil

Expand Down
21 changes: 21 additions & 0 deletions libsubfinder/sources/censys/censys.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ func Query(args ...interface{}) interface{} {

client := &http.Client{}
req, err := http.NewRequest("POST", "https://www.censys.io/api/v1/search/certificates", bytes.NewBuffer(request))
if err != nil {
if !state.Silent {
fmt.Printf("\ncensys: %v\n", err)
}
return subdomains
}

req.SetBasicAuth(username, key)

// Set content type as application/json
Expand Down Expand Up @@ -134,6 +141,13 @@ func Query(args ...interface{}) interface{} {

client := &http.Client{}
req, err := http.NewRequest("POST", "https://www.censys.io/api/v1/search/certificates", bytes.NewBuffer(request))
if err != nil {
if !state.Silent {
fmt.Printf("\ncensys: %v\n", err)
}
return subdomains
}

req.SetBasicAuth(username, key)

// Set content type as application/json
Expand Down Expand Up @@ -202,6 +216,13 @@ func Query(args ...interface{}) interface{} {

client := &http.Client{}
req, err := http.NewRequest("POST", "https://www.censys.io/api/v1/search/certificates", bytes.NewBuffer(request))
if err != nil {
if !state.Silent {
fmt.Printf("\ncensys: %v\n", err)
}
return subdomains
}

req.SetBasicAuth(username, key)

// Set content type as application/json
Expand Down
12 changes: 12 additions & 0 deletions libsubfinder/sources/dnsdumpster/dnsdumpster.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,25 @@ func Query(args ...interface{}) interface{} {

// Create a post request to get subdomain data
req, err := http.NewRequest("POST", "https://dnsdumpster.com", strings.NewReader(form.Encode()))
if err != nil {
if !state.Silent {
fmt.Printf("\ndnsdumpster: %v\n", err)
}
return subdomains
}

req.PostForm = form
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
req.Header.Add("Referer", "https://dnsdumpster.com")
req.Header.Set("User-Agent", "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1")

resp, err = hc.Do(req)
if err != nil {
if !state.Silent {
fmt.Printf("\ndnsdumpster: %v\n", err)
}
return subdomains
}

// Get the response body
body, err = ioutil.ReadAll(resp.Body)
Expand Down
7 changes: 7 additions & 0 deletions libsubfinder/sources/passivetotal/passivetotal.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ func Query(args ...interface{}) interface{} {

client := &http.Client{}
req, err := http.NewRequest("GET", "https://api.passivetotal.org/v2/enrichment/subdomains", bytes.NewBuffer(request))
if err != nil {
if !state.Silent {
fmt.Printf("\npassivetotal: %v\n", err)
}
return subdomains
}

req.SetBasicAuth(username, key)

// Set content type as application/json
Expand Down
26 changes: 26 additions & 0 deletions libsubfinder/sources/riddler/riddler.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,22 @@ func Query(args ...interface{}) interface{} {

// Create a post request to get subdomain data
req, err := http.NewRequest("POST", "https://riddler.io/auth/login", bytes.NewBuffer(data))
if err != nil {
if !state.Silent {
fmt.Printf("\nriddler: %v\n", err)
}
return subdomains
}

req.Header.Add("Content-Type", "application/json")

resp, err := hc.Do(req)
if err != nil {
if !state.Silent {
fmt.Printf("\nriddler: %v\n", err)
}
return subdomains
}

// Get the response body
body, err := ioutil.ReadAll(resp.Body)
Expand Down Expand Up @@ -80,10 +93,23 @@ func Query(args ...interface{}) interface{} {
data = []byte(`{"query":"pld:` + domain + `", "output":"host", "limit":500}`)

req, err = http.NewRequest("POST", "https://riddler.io/api/search", bytes.NewBuffer(data))
if err != nil {
if !state.Silent {
fmt.Printf("\nriddler: %v\n", err)
}
return subdomains
}

req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authentication-Token", auth.Response.User.AuthenticationToken)

resp, err = hc.Do(req)
if err != nil {
if !state.Silent {
fmt.Printf("\nriddler: %v\n", err)
}
return subdomains
}

// Get the response body
body, err = ioutil.ReadAll(resp.Body)
Expand Down
6 changes: 6 additions & 0 deletions libsubfinder/sources/securitytrails/securitytrails.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ func Query(args ...interface{}) interface{} {

client := &http.Client{}
req, err := http.NewRequest("GET", "https://api.securitytrails.com/v1/domain/"+domain+"/subdomains", nil)
if err != nil {
if !state.Silent {
fmt.Printf("\npassivetotal: %v\n", err)
}
return subdomains
}

req.Header.Add("APIKEY", securitytrailsKey)

Expand Down

0 comments on commit 0b89802

Please sign in to comment.