forked from hakluke/haktrails
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubmit.go
37 lines (32 loc) · 767 Bytes
/
submit.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
package main
import (
"fmt"
"sync"
)
// the main subdomains function will wait until it has received $buffer number of subdomains from stdin, then submit them
func submit(work chan string, wg *sync.WaitGroup, buffer int) {
defer wg.Done()
var subs []string
for text := range work {
subs = append(subs, text)
if len(subs) >= buffer {
submitSubdomains(subs)
subs = nil
}
}
submitSubdomains(subs)
}
// get the subdomains + print them
func submitSubdomains(subs []string) {
// convert the string slice into a list of strings
var postBody string
for c, s := range subs {
if c == 0 {
postBody = s
} else {
postBody = postBody + fmt.Sprintf("\n%s", s)
}
}
// send it
fmt.Println(getResponse("POST", "submit/hostnames", postBody))
}