觅风论坛
标题:
C++ 提升自身进程权限到调试级别写法源码
[打印本页]
作者:
小一
时间:
2022-4-2 15:28
标题:
C++ 提升自身进程权限到调试级别写法源码
TOKEN_PRIVILEGES tp;
tp.PrivilegeCount = 1;
int res = LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &tp.Privileges[0].Luid);
if (!res)
{
int err = ::GetLastError();
TRACE(_T("LookupPrivilegeValue(SE_DEBUG_NAME) Fail!!"));
}
typedef int(__stdcall *PRtlAdjustPrivilege)(ULONG, BOOLEAN, BOOLEAN, PBOOLEAN);
PRtlAdjustPrivilege RtlAdjustPrivilege =
(PRtlAdjustPrivilege)GetProcAddress(GetModuleHandle(_T("ntdll")), "RtlAdjustPrivilege");
while (!RtlAdjustPrivilege)
{
int err = ::GetLastError();
TRACE(_T("GetProcAddress(ntdll.dll::RtlAdjustPrivilege) Fail!!"));
}
// 实验了下 提权成功了 但是返回值还是NULL 如果这个时候验证返回值将不准确了.
BOOLEAN enabled = 0;
res = RtlAdjustPrivilege(tp.Privileges[0].Luid.LowPart, TRUE, FALSE, &enabled);//...LowPart = 0x14
欢迎光临 觅风论坛 (https://www.eyyba.com/)
Powered by Discuz! X3.4