mirror of
https://github.com/cubixle/assetfinder.git
synced 2026-04-24 18:44:42 +01:00
40 lines
665 B
Go
40 lines
665 B
Go
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
|
|
}
|