-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
main.go
50 lines (42 loc) · 1.56 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"bytes"
"context"
"io"
"log"
"github.com/projectdiscovery/subfinder/v2/pkg/runner"
)
func main() {
subfinderOpts := &runner.Options{
Threads: 10, // Thread controls the number of threads to use for active enumerations
Timeout: 30, // Timeout is the seconds to wait for sources to respond
MaxEnumerationTime: 10, // MaxEnumerationTime is the maximum amount of time in mins to wait for enumeration
// ResultCallback: func(s *resolve.HostEntry) {
// callback function executed after each unique subdomain is found
// },
// ProviderConfig: "your_provider_config.yaml",
// and other config related options
}
// disable timestamps in logs / configure logger
log.SetFlags(0)
subfinder, err := runner.NewRunner(subfinderOpts)
if err != nil {
log.Fatalf("failed to create subfinder runner: %v", err)
}
output := &bytes.Buffer{}
// To run subdomain enumeration on a single domain
if err = subfinder.EnumerateSingleDomainWithCtx(context.Background(), "hackerone.com", []io.Writer{output}); err != nil {
log.Fatalf("failed to enumerate single domain: %v", err)
}
// To run subdomain enumeration on a list of domains from file/reader
// file, err := os.Open("domains.txt")
// if err != nil {
// log.Fatalf("failed to open domains file: %v", err)
// }
// defer file.Close()
// if err = subfinder.EnumerateMultipleDomainsWithCtx(context.Background(), file, []io.Writer{output}); err != nil {
// log.Fatalf("failed to enumerate subdomains from file: %v", err)
// }
// print the output
log.Println(output.String())
}