-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
67 lines (54 loc) · 1.51 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package main
import (
"log"
"sync"
"github.com/censoredplanet/CenFuzz/config"
"github.com/censoredplanet/CenFuzz/util"
"github.com/censoredplanet/CenFuzz/worker"
)
func WorkerType() worker.Worker {
switch config.Protocol {
case "https":
return &worker.HTTPSWorker{}
case "http":
return &worker.HTTPWorker{}
default:
panic("unknown protocol")
}
}
func main() {
w := WorkerType()
log.Printf("Starting HTTP(S) fuzzers")
inputs := util.ParseInfile(config.Infile)
uncensoredKeyword := config.UncensoredKeyword
outfile := config.Outfile
ResultsQueue := make(chan *util.Result)
workerdoneChan := make(chan bool)
resultsdoneChan := make(chan bool)
workQueue := make(chan interface{})
fuzzerList := util.ParseFuzzerInfile(config.FuzzerInFile)
fuzzerObjects := w.FuzzerObjects(fuzzerList)
var workWG sync.WaitGroup
for i := 0; i < config.NumWorkers; i++ {
go w.Worker(workQueue, ResultsQueue, uncensoredKeyword, &workWG, workerdoneChan)
}
log.Printf("Workers spawned")
go util.SaveResults(ResultsQueue, outfile, resultsdoneChan)
log.Printf("Output routine started")
for _, input := range inputs {
vp := input.VP
vp.Mu.Lock()
work := w.Work(input.VP.IP, input.Domain, fuzzerObjects)
workWG.Add(1)
workQueue <- work
log.Println("Assigned work to VP: ", input.VP.IP)
vp.Mu.Unlock()
}
close(workQueue)
log.Println("All work assigned. Waiting for workers to return")
workWG.Wait()
<-workerdoneChan
log.Println("Waiting for results to be written")
close(ResultsQueue)
<-resultsdoneChan
}