mirror of
https://github.com/cubixle/assetfinder.git
synced 2026-04-24 21:24:47 +01:00
initial
This commit is contained in:
39
crtsh.go
Normal file
39
crtsh.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package assetfinder
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type CrtShResult struct {
|
||||
Name string `json:"name_value"`
|
||||
}
|
||||
|
||||
type CrtSh struct{}
|
||||
|
||||
func (CrtSh) FetchSubDomains(domain string) ([]string, error) {
|
||||
var results []CrtShResult
|
||||
|
||||
resp, err := http.Get(
|
||||
fmt.Sprintf("https://crt.sh/?q=%%25.%s&output=json", domain),
|
||||
)
|
||||
if err != nil {
|
||||
return []string{}, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
output := make([]string, 0)
|
||||
|
||||
body, _ := ioutil.ReadAll(resp.Body)
|
||||
|
||||
if err := json.Unmarshal(body, &results); err != nil {
|
||||
return []string{}, err
|
||||
}
|
||||
|
||||
for _, res := range results {
|
||||
output = append(output, res.Name)
|
||||
}
|
||||
return output, nil
|
||||
}
|
||||
Reference in New Issue
Block a user