Skip to content

Latest commit

 

History

History
441 lines (310 loc) · 11.3 KB

privileges.md

File metadata and controls

441 lines (310 loc) · 11.3 KB

Privileges

Contents

Reference

Functions

GetTokenPrivileges

FreeTokenPrivileges

LookupPrivilegesValue

EnableAvailablePrivileges

  • Example
    • Enable the avaliable privileges.

      #include <Win32Ex/Security/Privilege.h>
      
      PREVIOUS_TOKEN_PRIVILEGES prev;
      if (EnableAvailablePrivileges(TRUE, &prev, NULL))
      {
      // TODO
      RevertPrivileges(&prev)
      }

EnablePrivilege

  • Example
    • Enable the shutdown privilege.

      #include <Win32Ex/Security/Privilege.h>
      
      PREVIOUS_TOKEN_PRIVILEGES prev;
      if (EnablePrivilege(TRUE, SE_SHUTDOWN_NAME, &prev, NULL))
      {
      // TODO
      RevertPrivileges(&prev)
      }

EnablePrivilegeEx

  • Similar to EnablePrivilege, but uses LUID instead of privilege name.

EnablePrivileges

  • Example
    • Enable change notify and shutdown privileges.

      #include <Win32Ex/Security/Privilege.h>
      
      PREVIOUS_TOKEN_PRIVILEGES prev;
      PCTSTR privileges = {
        SE_CHANGE_NOTIFY_NAME,
        SE_SHUTDOWN_NAME
      };
      if (EnablePrivileges(TRUE, 2, privileges, &prev, NULL))
      {
        // TODO
        RevertPrivileges(&prev)
      }

EnablePrivilegesV

  • Example
    • Enable change notify and shutdown privileges.

      #include <Win32Ex/Security/Privilege.h>
      
      PREVIOUS_TOKEN_PRIVILEGES prev;
      if (!EnablePrivilegesV(TRUE, &prev, NULL, 2, SE_CHANGE_NOTIFY_NAME, SE_SHUTDOWN_NAME))
      {
      // TODO
      RevertPrivileges(&prev)
      }

EnablePrivilegesEx

  • Similar to EnablePrivileges, but uses LUIDs instead of privilege names.

EnablePrivilegesExV

  • Similar to EnablePrivilegeV, but uses LUIDs instead of privilege names.

IsPrivilegeEnabled

  • Example
    • Determines whether the specified privilege is enabled.

      #include <Win32Ex/Security/Privilege.h>
      
      if (IsPrivilegeEnabled(SE_CHANGE_NOTIFY_NAME, NULL))
      {
      }

IsPrivilegeEnabledEx

  • Similar to IsPrivilegeEnabled, but uses LUID instead of privilege name.
  • Example
    • Determines whether the specified privilege is enabled.

      #include <Win32Ex/Security/Privilege.h>
      
      if (IsPrivilegeEnabledEx(Win32Ex::Security::SeChangeNotifyPrivilege, NULL))
      {
      }

IsPrivilegesEnabled

  • Example
    • Determines whether the change notify and shutdown privileges is enabled.

      #include <Win32Ex/Security/Privilege.h>
      
      PCTSTR privileges = {
        SE_CHANGE_NOTIFY_NAME,
        SE_SHUTDOWN_NAME
      };
      
      if (IsPrivilegesEnabled(2, privileges, NULL))
      {
      }

IsPrivilegesEnabledV

  • Example
    • Determines whether the change notify and shutdown privileges is enabled.

      #include <Win32Ex/Security/Privilege.h>
      
      if (IsPrivilegesEnabledV(NULL, 2, SE_CHANGE_NOTIFY_NAME, SE_SHUTDOWN_NAME))
      {
      }

IsPrivilegesEnabledEx

  • Similar to IsPrivilegesEnabled, but uses LUIDs instead of privilege names.

IsPrivilegesEnabledExV

  • Similar to IsPrivilegesEnabledV, but uses LUIDs instead of privilege names.

Variables

Privilege LUID variables [C++ Only]

SeCreateTokenPrivilege
SeAssignPrimaryTokenPrivilege
SeLockMemoryPrivilege
SeIncreaseQuotaPrivilege
SeUnsolicitedInputPrivilege
SeMachineAccountPrivilege
SeTcbPrivilege
SeSecurityPrivilege
SeTakeOwnershipPrivilege
SeLoadDriverPrivilege
SeSystemProfilePrivilege
SeSystemtimePrivilege
SeProfileSingleProcessPrivilege
SeIncreaseBasePriorityPrivilege
SeCreatePagefilePrivilege
SeCreatePermanentPrivilege
SeBackupPrivilege
SeRestorePrivilege
SeShutdownPrivilege
SeDebugPrivilege
SeAuditPrivilege
SeSystemEnvironmentPrivilege
SeChangeNotifyPrivilege
SeRemoteShutdownPrivilege
SeUndockPrivilege
SeSyncAgentPrivilege
SeEnableDelegationPrivilege
SeManageVolumePrivilege
SeImpersonatePrivilege
SeCreateGlobalPrivilege
SeTrustedCredManAccessPrivilege
SeRelabelPrivilege
SeIncreaseWorkingSetPrivilege
SeTimeZonePrivilege
SeCreateSymbolicLinkPrivilege
SeDelegateSessionUserImpersonatePrivilege

Classes

TokenPrivileges

  • Example
    • Adjust a debug and shutdown privileges.

      #include <Win32Ex/System/Privilege.h>
      using namespace Win32Ex;
      
      Security::TokenPrivileges priv({Security::SeDebugPrivilege, Security::SeShutdownPrivilege});
      if (priv.AcquiredPrivileges().size() == 2)
      {
          // TODO
      }
      
      if (priv.IsAcquired())
      {
          // TODO
      }
    • Adjust debug privilege.

      #include <Win32Ex/System/Privilege.hpp>
      using namespace Win32Ex;
      
      {
      Security::TokenPrivileges priv(Security::SeDebugPrivilege);
      if (priv.IsAcquired())
      {
          // TODO
      }
      }
      
      // Debug privilege released.
      #include <Win32Ex/System/Privilege.hpp>
      using namespace Win32Ex;
      
      {
      Security::TokenPrivileges priv(Security::SeDebugPrivilege);
      if (priv.IsAcquired())
      {
          priv.SetPermanent(TRUE);
          // TODO
      }
      
      priv.Release();
      
      // Debug privilege released.
      }

Macros

Privilege macros

SE_MIN_WELL_KNOWN_PRIVILEGE
SE_MAX_WELL_KNOWN_PRIVILEGE
SE_PROF_SINGLE_PROCESS_NAME_W
SE_INC_BASE_PRIORITY_NAME_W
SE_CREATE_PAGEFILE_NAME_W
SE_CREATE_PERMANENT_NAME_W
SE_BACKUP_NAME_W
SE_RESTORE_NAME_W
SE_SHUTDOWN_NAME_W
SE_DEBUG_NAME_W
SE_AUDIT_NAME_W
SE_SYSTEM_ENVIRONMENT_NAME_W
SE_CHANGE_NOTIFY_NAME_W
SE_REMOTE_SHUTDOWN_NAME_W
SE_UNDOCK_NAME_W
SE_SYNC_AGENT_NAME_W
SE_ENABLE_DELEGATION_NAME_W
SE_MANAGE_VOLUME_NAME_W
SE_IMPERSONATE_NAME_W
SE_CREATE_GLOBAL_NAME_W
SE_TRUSTED_CREDMAN_ACCESS_NAME_W
SE_RELABEL_NAME_W
SE_INCORKING_SET_NAME_W
SE_TIME_ZONE_NAME_W
SE_CREATE_SYMBOLIC_LINK_NAME_W
SE_DELEGATE_SESSION_USER_IMPERSONATE_NAME_W