diff --git a/README.md b/README.md index 7bf4496..326c1bc 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,6 @@ Please feel free to issue pull requests with new sources! :) * https://certdb.com/api-documentation ## TODO -* Flags to control which sources are used - * Likely to be all on by default and a flag to disable +* ~~Flags to control which sources are used~~ + * ~~Likely to be all on by default and a flag to disable~~ * Read domains from stdin diff --git a/main.go b/main.go index 5ce96d0..f717e53 100644 --- a/main.go +++ b/main.go @@ -16,9 +16,43 @@ import ( func main() { var subsOnly bool + + var ( + useCertSpotter bool + useHackerTarget bool + useThreatCrowd bool + useCrtSh bool + useFacebook bool + useVirusTotal bool + useFindSubDomains bool + useUrlscan bool + useBufferOverrun bool + ) + flag.BoolVar(&subsOnly, "subs-only", false, "Only include subdomains of search domain") + flag.BoolVar(&useCertSpotter, "use-certspotter", true, "Enable CertSpotter source") + flag.BoolVar(&useHackerTarget, "use-hackertarget", true, "Enable HackerTarget source") + flag.BoolVar(&useThreatCrowd, "use-threatcrowd", true, "Enable ThreatCrowd source") + flag.BoolVar(&useCrtSh, "use-crtsh", true, "Enable CrtSh source") + flag.BoolVar(&useFacebook, "use-facebook", true, "Enable Facebook source") + flag.BoolVar(&useVirusTotal, "use-virustotal", true, "Enable VirusTotal source") + flag.BoolVar(&useFindSubDomains, "use-findsubdomains", true, "Enable FindSubDomains source") + flag.BoolVar(&useUrlscan, "use-urlscan", true, "Enable Urlscan source") + flag.BoolVar(&useBufferOverrun, "use-bufferoverrun", true, "Enable BufferOverrun source") flag.Parse() + useSources := map[string]bool{ + "certspotter": useCertSpotter, + "hackertarget": useHackerTarget, + "threatcrowd": useThreatCrowd, + "crtsh": useCrtSh, + "facebook": useFacebook, + "virustotal": useVirusTotal, + "findsubdomains": useFindSubDomains, + "urlscan": useUrlscan, + "bufferoverrun": useBufferOverrun, + } + var domains io.Reader domains = os.Stdin @@ -27,17 +61,30 @@ func main() { domains = strings.NewReader(domain) } - sources := []fetchFn{ - fetchCertSpotter, - fetchHackerTarget, - fetchThreatCrowd, - fetchCrtSh, - fetchFacebook, - //fetchWayback, // A little too slow :( - fetchVirusTotal, - fetchFindSubDomains, - fetchUrlscan, - fetchBufferOverrun, + var sources []fetchFn + for source, enabled := range useSources { + if enabled { + switch source { + case "certspotter": + sources = append(sources, fetchCertSpotter) + case "hackertarget": + sources = append(sources, fetchHackerTarget) + case "threatcrowd": + sources = append(sources, fetchThreatCrowd) + case "crtsh": + sources = append(sources, fetchCrtSh) + case "facebook": + sources = append(sources, fetchFacebook) + case "virustotal": + sources = append(sources, fetchVirusTotal) + case "findsubdomains": + sources = append(sources, fetchFindSubDomains) + case "urlscan": + sources = append(sources, fetchUrlscan) + case "bufferoverrun": + sources = append(sources, fetchBufferOverrun) + } + } } out := make(chan string)