generated from roerohan/Template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
86 lines (65 loc) · 1.25 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package main
import (
"bufio"
"flag"
"os"
"sync"
"github.com/roerohan/bird/brutus"
"github.com/roerohan/bird/logger"
"github.com/roerohan/bird/progress"
)
func main() {
flag.Parse()
if len(urls) == 0 {
flag.Usage()
os.Exit(1)
}
if wordlist == "" {
flag.Usage()
os.Exit(1)
}
if len(success) == 0 {
success = append(success, "200")
}
workers := 4
logger.Info("Starting 4 worker threads...")
successCodes := make(map[string]bool)
for _, code := range success {
successCodes[code] = true
}
var wg sync.WaitGroup
var bar progress.Progress
c := make(chan *brutus.Brute)
logs := make(chan logger.Log)
go logger.Start(logs)
for i := 0; i < workers; i++ {
wg.Add(1)
go func() {
defer wg.Done()
for b := range c {
b.Try(successCodes, logs)
}
}()
}
file, err := os.Open(wordlist)
if err != nil {
logger.Fatal("Could not open wordlist: " + wordlist)
}
defer file.Close()
stat, _ := file.Stat()
size := stat.Size()
bar.New(0, int(size))
count := 0
scanner := bufio.NewScanner(file)
scanner.Split(bufio.ScanLines)
for scanner.Scan() {
text := scanner.Text()
for _, url := range urls {
c <- brutus.New(url, text)
}
count += len(text) + 1
bar.Play(count, logs)
}
close(c)
wg.Wait()
}