-
Notifications
You must be signed in to change notification settings - Fork 7
/
main.go
172 lines (148 loc) · 4.67 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
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
var debugRun bool
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,kerberos)")
flag.StringVar(&pathToTargetList, "tl", "targets.txt", "Path to targets list")
flag.IntVar(&workersNumber, "w", 5, "Number of Workers")
flag.BoolVar(&debugRun, "debug", false, "Show debug info")
flag.Parse()
}
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 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,debugRun)
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" {
for _,task := range tasks{
wg.Add(1)
go kerberosSpray(&wg,channelForWorker,task,¤tTask.WorkersStates[iter].WorkerProgress)
iter++
}
}
go monitorCurrentTask()
wg.Wait()
close(channelForWorker)
}