Guest User

Untitled

a guest
Jun 18th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. #include <windows.h>
  2. #include <stdio.h>
  3.  
  4. void oslevel() {
  5. HANDLE token;
  6. if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &token)) {
  7. TOKEN_PRIVILEGES privileges;
  8. LUID localuid;
  9. if(LookupPrivilegeValue(NULL, SE_TCB_NAME, &localuid)) {
  10. privileges.PrivilegeCount = 1;
  11. privileges.Privileges[0].Luid = localuid;
  12. privileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
  13. if(AdjustTokenPrivileges(token, FALSE, &privileges, sizeof(TOKEN_PRIVILEGES), NULL, 0)) {
  14. printf("adjusted token privileges, now running with OS Level authorization\n");
  15. } else {
  16. printf("couldn't change privileges, error code: %d\n", (int) GetLastError());
  17. }
  18. } else {
  19. printf("couldn't lookup privileges for %s error code: %d\n", SE_TCB_NAME, (int) GetLastError());
  20. }
  21. } else {
  22. printf("couldn't open the token for %d because: %d\n", (int) GetCurrentProcessId(), (int) GetLastError());
  23. }
  24. }
Add Comment
Please, Sign In to add comment