Requesting Priviledge Token SE_PRIVILEGE_ENABLED

Hi Friend,

I would like to give a simple tutorial on windows programming to escalate your priviledge token programatically.

In this tutorial is to enable your application to have SE_PRIVILEGE_ENABLED token in order to do alot of more action such as dll injection.

#include <iostream>
using namespace std;

bool injectSetDebugPriv() {

    bool bRet = FALSE;
    HANDLE hToken = NULL;
    LUID luid = { 0 };

    if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken)) {
        if (LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &luid)) {
            TOKEN_PRIVILEGES tokenPriv = { 0 };
            tokenPriv.PrivilegeCount = 1;
            tokenPriv.Privileges[0].Luid = luid;
            tokenPriv.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
            bRet = AdjustTokenPrivileges(hToken,FALSE,&tokenPriv,sizeof(TOKEN_PRIVILEGES), NULL, NULL);
    return bRet;


int main()
     bool result = injectSetDebugPriv();

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s