Delphi 进程提权写法

2021-05-23 09:32

阅读:695

标签:成功   eval   show   bugs   phi   getc   count   bsp   stat   

 1 procedure debugs; stdcall;
 2 var
 3   NewState: TTokenPrivileges;
 4   lpLuid: Int64;
 5   ReturnLength: DWord;
 6   hAccessToken: THandle;
 7   a: Boolean;
 8 begin
 9 
10   a := OpenProcessToken(GetCurrentProcess, TOKEN_Adjust_Privileges,   //获取进程令牌,成功返回非0,失败返回0,
11     hAccessToken);
12   ShowMessage(BoolToStr(a) +            + IntToStr(GetLastError())); // a=0则失败,成功则getlasterror为0
13   LookupPrivilegeValue(nil, SeDebugPrivilege, lpLuid);               //debug权限
14   NewState.PrivilegeCount := 1;
15   NewState.Privileges[0].Luid := lpLuid;
16   NewState.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
17   ReturnLength := 0;
18   AdjustTokenPrivileges(hAccessToken, False, NewState, 0, nil, ReturnLength);  //提权函数
19 end;

 

Delphi 进程提权写法

标签:成功   eval   show   bugs   phi   getc   count   bsp   stat   

原文地址:https://www.cnblogs.com/qianqing/p/11137502.html


评论


亲,登录后才可以留言!