Evil Hackers from Outerspace

Been having fun since Friday dealing with a compromised server. Somehow an infiltrator loaded two files onto the server in question. One in an OS Commerce directory (very out of date installation) and the other into the root of a Word Press 2.9 install. The malicious code would then phone home to a recently registered domains named jsonapplet.com and bxubwsxj.co.tv. Presumably some sort of virus/trojan was installed on the end-users computer from this domain. Each of these domains just had the default Apache install screen when you went to the index page, but nested in other pages in the server was where the payload was.

Noticing that jsonapplet.com seemed a bit weird (the .TV had not been discovered at this point) we dug in finding that it had just been recently registered to a company in China known for this sort of thing. Whether the company is actually based in China is unknown, but it still served to raise suspicions further.

The PHP script was crafty in that it would only write the malicious javascript to the document if the user had come in from a search engine. This made finding the exploit hard since we were visiting the pages directly (no HTTP REFERRER was set). Furthermore most online scanners would not find the exploit. The only one that reported it was unmaskparasites.com, but even that scanner said it was NOT suspicious. Googles online scanner (even though Google Adwords originally notified the company) and McAffee Scan Alert did not find this exploit either.

Here is the script:

Though somewhat obfuscated a simple grep of the server for document.cookie would have quickly found this. Unfortunately initial greps were looking for things like eval and document.write instead. There are few reports on what the payload actually does from Anubis and Sucuri.

Steps taken :

1. Disabled all SSH access and created new accounts.

2. Checked to see who else was logged into the server using the who command. If anyone had been found those accounts would have been killed.

3. Removed the exploited files.

4. Changed SSH account passwords again.

5. Patched affected and non-affected software throughout the system.

I also contacted leaseweb.com informing them about the account. Contacted unmaskparasites.com as a thanks and to hopefully give them some hints on improving their scanner. Finally at the urging of a fellow developer I wrote this blog to hopefully create some awareness about this exploit.


  • anoldman says:

    I found the same thing on a site – the owner had received notification from Google that the site contained malware. The svn status of a live file was M, and the code was in that file ( alongside quantcast code ).

    The most disturbing aspect of the code is the @include()… this means that the originator ( or someone who understands the code ) can actually set their cookie in such a was as to load ANY PHP CODE into the namespace, giving them file system or sql db access… quite a backdoor.

    To find on your site, grep for “@include” – it’s highly unlikely that proper php code uses this.

  • anoldman says:

    I also have found a related file cleverly hidden as Thumbs.db – but file was owned by Apache. Inspecting the contents revealed php code. Parsing the obfuscated code revealed a file_get_contents from a dot ca domain.

  • chris says:

    Interesting. Wouldn’t apache need to be configured to parse .db files though?