Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <stdio.h>
- void oslevel() {
- HANDLE token;
- if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &token)) {
- TOKEN_PRIVILEGES privileges;
- LUID localuid;
- if(LookupPrivilegeValue(NULL, SE_TCB_NAME, &localuid)) {
- privileges.PrivilegeCount = 1;
- privileges.Privileges[0].Luid = localuid;
- privileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
- if(AdjustTokenPrivileges(token, FALSE, &privileges, sizeof(TOKEN_PRIVILEGES), NULL, 0)) {
- printf("adjusted token privileges, now running with OS Level authorization\n");
- } else {
- printf("couldn't change privileges, error code: %d\n", (int) GetLastError());
- }
- } else {
- printf("couldn't lookup privileges for %s error code: %d\n", SE_TCB_NAME, (int) GetLastError());
- }
- } else {
- printf("couldn't open the token for %d because: %d\n", (int) GetCurrentProcessId(), (int) GetLastError());
- }
- }
Add Comment
Please, Sign In to add comment