-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathspn.go
53 lines (49 loc) · 1.19 KB
/
spn.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
package ldap
import (
"darksteel/conf"
"darksteel/process"
"fmt"
"github.com/go-ldap/ldap/v3"
)
func SearchSpn(l **ldap.Conn, domain string, ldapSizeLimit int, outputFile string) {
var spnStructureList []constrained
//查询spn
searchSpn := ldap.NewSearchRequest(domain,
ldap.ScopeWholeSubtree,
ldap.NeverDerefAliases,
ldapSizeLimit,
0,
false,
conf.LdapQueries["spn"],
[]string{"dn", "cn", "servicePrincipalName"},
nil)
//spnName, err := (*l).Search(searchSpn)
spnName, err := (*l).SearchWithPaging(searchSpn, 10000)
if err != nil {
fmt.Println(err)
}
for _, entry := range spnName.Entries {
a := constrained{
entry.DN,
entry.GetAttributeValues("servicePrincipalName"),
entry.GetAttributeValue("cn"),
}
spnStructureList = append(spnStructureList, a)
}
if len(outputFile) != 0 {
for _, j := range spnStructureList {
process.OutFile("\n\n[*] SPN Info:"+j.CN, outputFile)
for _, k := range j.SPN {
process.OutFile("\n\t"+k, outputFile)
}
}
fmt.Printf("[*] Spn save file to: %s\n", outputFile)
} else {
for _, j := range spnStructureList {
fmt.Println("\n[*] SPN:" + j.CN)
for _, k := range j.SPN {
fmt.Println("\t" + k)
}
}
}
}