Skip to content

Commit 5015869

Browse files
authored
Create EnableAllTokens.go
1 parent 3033be5 commit 5015869

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
package AllTokens
2+
3+
import (
4+
"golang.org/x/sys/windows"
5+
)
6+
7+
var tokens = []string{
8+
"SeAssignPrimaryTokenPrivilege",
9+
"SeAuditPrivilege",
10+
"SeBackupPrivilege",
11+
"SeChangeNotifyPrivilege",
12+
"SeCreateGlobalPrivilege",
13+
"SeCreatePagefilePrivilege",
14+
"SeCreatePermanentPrivilege",
15+
"SeCreateSymbolicLinkPrivilege",
16+
"SeCreateTokenPrivilege",
17+
"SeDebugPrivilege",
18+
"SeDelegateSessionUserImpersonatePrivilege",
19+
"SeEnableDelegationPrivilege",
20+
"SeImpersonatePrivilege",
21+
"SeIncreaseQuotaPrivilege",
22+
"SeIncreaseBasePriorityPrivilege",
23+
"SeIncreaseWorkingSetPrivilege",
24+
"SeLoadDriverPrivilege",
25+
"SeLockMemoryPrivilege",
26+
"SeMachineAccountPrivilege",
27+
"SeManageVolumePrivilege",
28+
"SeProfileSingleProcessPrivilege",
29+
"SeRelabelPrivilege",
30+
"SeRemoteShutdownPrivilege",
31+
"SeRestorePrivilege",
32+
"SeSecurityPrivilege",
33+
"SeShutdownPrivilege",
34+
"SeSyncAgentPrivilege",
35+
"SeSystemtimePrivilege",
36+
"SeSystemEnvironmentPrivilege",
37+
"SeSystemProfilePrivilege",
38+
"SeTakeOwnershipPrivilege",
39+
"SeTcbPrivilege",
40+
"SeTimeZonePrivilege",
41+
"SeTrustedCredManAccessPrivilege",
42+
"SeUndockPrivilege",
43+
}
44+
45+
func Enable() {
46+
hProcess := windows.CurrentProcess()
47+
var hToken windows.Token
48+
49+
err := windows.OpenProcessToken(hProcess, windows.TOKEN_ADJUST_PRIVILEGES|windows.TOKEN_QUERY, &hToken)
50+
if err != nil {
51+
return
52+
}
53+
defer hToken.Close()
54+
55+
for _, token := range tokens {
56+
var luid windows.LUID
57+
err := windows.LookupPrivilegeValue(nil, windows.StringToUTF16Ptr(token), &luid)
58+
if err != nil {
59+
continue
60+
}
61+
62+
tp := windows.Tokenprivileges{
63+
PrivilegeCount: 1,
64+
Privileges: [1]windows.LUIDAndAttributes{
65+
{Luid: luid, Attributes: windows.SE_PRIVILEGE_ENABLED},
66+
},
67+
}
68+
69+
err = windows.AdjustTokenPrivileges(hToken, false, &tp, 0, nil, nil)
70+
if err != nil {
71+
continue
72+
}
73+
}
74+
}

0 commit comments

Comments
 (0)