易截截图软件、单文件、免安装、纯绿色、仅160KB

[Delphi函数]提升进程权限为DEBUG权限

在网上也看到了一些提升进程令牌的函数但都不怎么好用,最后我还是从一个黑客后门程序的源代码中提取出了一个好的提升进程令牌的函数,不敢独享,跟大家分享下.那个后门真的写的很好...
Hysia提示你:
这个函数用在对付病毒的程序中效果很好,只有提升自身权限才能KILL掉病毒进程我曾写写出来尝试结束Winlogon进程,导致的结果是,我的电脑立刻蓝屏后重启!
//提升进程权限为DEBUG权限
procedure SetPrivilege;
var
   OldTokenPrivileges, TokenPrivileges: TTokenPrivileges;
   ReturnLength: dword;
   hToken: THandle;
   Luid: int64;
begin
   OpenProcessToken(GetCurrentProcess, TOKEN_ADJUST_PRIVILEGES, hToken);
   LookupPrivilegeValue(nil, 'SeDebugPrivilege', Luid);
   TokenPrivileges.Privileges[0].luid := Luid;
   TokenPrivileges.PrivilegeCount := 1;
   TokenPrivileges.Privileges[0].Attributes := 0;
   AdjustTokenPrivileges(hToken, False, TokenPrivileges, SizeOf(TTokenPrivileges), OldTokenPrivileges, ReturnLength);
   OldTokenPrivileges.Privileges[0].luid := Luid;
   OldTokenPrivileges.PrivilegeCount := 1;
   OldTokenPrivileges.Privileges[0].Attributes := TokenPrivileges.Privileges[0].Attributes or SE_PRIVILEGE_ENABLED;
   AdjustTokenPrivileges(hToken, False, OldTokenPrivileges, ReturnLength, PTokenPrivileges(nil)^, ReturnLength);
end;
用法就不用说了吧,
procedure TForm1.FormCreate(Sender: TObject);
begin SetPrivilege; ...
一句话就把程序提升为DEBUG权限了,然后就可以随便结束其他进程了.
好东西跟大家分享~!


相关文档:

delphi 编译后出现iphist.dat 文件

 很奇怪,昨天在编译程序的时候,出现过,iphist.dat 文件。每次执行都出现,仔细查看代码,什么也没有啊!后来在网站找到原因:
 使用了IPWatch 控件的
一般产生这个文件是因为使用了indy的 TIdIPWatch 控件
该控件有个
ip历史的功能。
historyfilename指定的是保存ip历史记录的文件名,默认是iphist.Dat ......

Delphi 创建目录及写日志文件


Delphi 创建目录及写日志文件
var
TF: TextFile;
LogFile: string;
txt :string;
sysDir:string;
//创建按钮
procedure TForm1.Button1Click(Sender: TObject);
begin
sysDir:=extractfilepath(application.ExeName );
if not directoryexists(sysdir+'log\') then
createdir(sysdir+'log ......

Delphi中的THashTable

在Delphi中,Inifiles单元中有一个TStringHash的类,不过它的Value仅支持Integer(其实也不是问题,有其它类型可以将变量变为Pointer),有点不舒服,今天没事做就把它替换为variant了,其中Key的名称大小写无关,就是为了加快开发速度!
使用Hashtable,查找和删除复杂度都是常数级别的!
type
PPHashItem = ^PHashItem;
......

Delphi定时Showmessage事件

在Delphi中,调用Showmessage后,如何使弹出的对话框在一秒钟后自动关闭,而不用手动去点确定
1:用timer控件的函数
procedure TForm1.Timer1Timer(Sender: TObject);
var
AHandle: THandle;
begin
AHandle := FindWindow('TMessageForm',
PChar(Application.Title));
if AHandle > 0 then
SendMessage( ......

delphi中的DBGRid鼠标滚动事件

Procedure OnMouseWheel(Var Msg :TMsg;var Handled:Boolean);
begin
  if Msg.message = WM_MouseWheel then
  begin
    if Msg.wParam > 0 then
     begin
       if DBGrid.Focused then
       ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号