zoukankan      html  css  js  c++  java
  • win7下提权代码

    inline BOOL SetPrivilege()
    {
        HANDLE hProcess, hToken; 
        TOKEN_PRIVILEGES NewState;
        LUID luidPrivilegeLUID; 
        hProcess = GetCurrentProcess();
        if(!OpenProcessToken(hProcess, TOKEN_ADJUST_PRIVILEGES, &hToken))
            return FALSE;
        if (!LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &luidPrivilegeLUID))
            return FALSE;
        NewState.PrivilegeCount = 1;
        NewState.Privileges[0].Luid = luidPrivilegeLUID;
        NewState.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
        if(!AdjustTokenPrivileges(hToken, FALSE, &NewState, NULL, NULL, NULL))
            return FALSE;
        return TRUE;
    }
    bool enableDebugPriv()  
    {  
        HANDLE hToken;  
        LUID sedebugnameValue;  
        TOKEN_PRIVILEGES tkp;  
      
        if (!OpenProcessToken(GetCurrentProcess(),  
            TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) {  
            return false;  
        }  
        if (!LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &sedebugnameValue)) 
        {  
            CloseHandle(hToken);  
            return false;  
        }  
        tkp.PrivilegeCount = 1;  
        tkp.Privileges[0].Luid = sedebugnameValue;  
        tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;  
        if (!AdjustTokenPrivileges(hToken, FALSE, &tkp, sizeof(tkp), NULL, NULL)) 
        {  
            CloseHandle(hToken);  
            return false;  
        }  
        return true;  
    } 
  • 相关阅读:
    win7下cygwin命令行颜色和中文乱码解决
    maven mirror
    maven命令
    dubbo获取错误ip
    eclipse netbeans 代码模板
    windows下配置Groovy
    c++ 载入内存中dll ,以及内存注入
    表达式求值的 计算器
    vc 编译器的一些精典报错
    内联汇编实现 memcpy 和 memset
  • 原文地址:https://www.cnblogs.com/wumac/p/4187702.html
Copyright © 2011-2022 走看看