@@ -20,7 +20,7 @@ func main() {
20
20
subdomainsFile := flag .Arg (1 )
21
21
22
22
if domainsFile == "" {
23
- domainsFile = "domains "
23
+ domainsFile = "apexes "
24
24
}
25
25
26
26
if subdomainsFile == "" {
@@ -41,9 +41,8 @@ func main() {
41
41
ss := bufio .NewScanner (s )
42
42
43
43
type domain struct {
44
- name string
45
- wildcards []string
46
- subs chan string
44
+ name string
45
+ subs chan string
47
46
}
48
47
49
48
// make a slice of all the domains and spin up a worker for each one
@@ -53,22 +52,28 @@ func main() {
53
52
for ds .Scan () {
54
53
name := ds .Text ()
55
54
56
- wildcards , _ := net .LookupHost (fmt .Sprintf ("%s.%s" , wildcardCheck , name ))
55
+ _ , err := net .LookupHost (fmt .Sprintf ("%s.%s" , wildcardCheck , name ))
56
+ if err == nil {
57
+ // There's a wildcard, don't bother
58
+ continue
59
+ }
57
60
58
- subs := make (chan string )
59
- d := domain {name , wildcards , subs }
61
+ subs := make (chan string , 128 )
62
+ d := domain {name , subs }
60
63
domains = append (domains , d )
61
64
62
- wg .Add (1 )
63
- go func () {
65
+ worker := func () {
64
66
for sub := range d .subs {
65
67
candidate := fmt .Sprintf ("%s.%s" , sub , d .name )
66
- if subdomainExists (candidate , d . wildcards ) {
68
+ if subdomainExists (candidate ) {
67
69
fmt .Println (candidate )
68
70
}
69
71
}
70
72
wg .Done ()
71
- }()
73
+ }
74
+ wg .Add (2 )
75
+ go worker ()
76
+ go worker ()
72
77
}
73
78
74
79
// check for errors reading the list of domains
@@ -97,19 +102,11 @@ func main() {
97
102
wg .Wait ()
98
103
}
99
104
100
- func subdomainExists (subdomain string , wildcards [] string ) bool {
101
- addrs , err := net .LookupHost (subdomain )
105
+ func subdomainExists (subdomain string ) bool {
106
+ _ , err := net .LookupHost (subdomain )
102
107
if err != nil {
103
108
return false
104
109
}
105
110
106
- for _ , addr := range addrs {
107
- for _ , wildcard := range wildcards {
108
- if addr == wildcard {
109
- return false
110
- }
111
- }
112
- }
113
-
114
111
return true
115
112
}
0 commit comments