Site legit file image_upload.php
was used to upload file 89471928047.php.jpg
Which was simple file upload form that copy tmp file to same images folder.
How they managed to execute it and upload other files trough it. Someone know how this is possible?
PHP version was 5.1.6
that being updated exactly hour ago or after by schedule with host to 5.3.8
... what a, coincidence?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
Check your .htaccess file
Using
AddType
in your .htaccess file, you can add many other extensions from which PHP can be ran. This is generally how.html
extensions can be used while still using PHP within themselves. So, yes, it's possible:You can test this if you like.
AddType application-x-httpd-php .jpg
<?php echo 'foo'; ?>
If all goes as planned, "foo" will be output to your screen. You could expand upon this to move
/tmp
files around if you like.Definitely something you want to be very careful with.
Check exposed calls to include/require
Another way this could have been done is through a call to
require()
orinclude()
(or any of the_once()
methods) where by the hacker was able to load in hisbadfile.php.jpg
file that had been uploaded under the guise of an innocent image:In the above case (simplified example), the hacker could pass in a path to his
.php.jpg
file and have its contents loaded in and processed as PHP code.Other (frightening) ideas
Require, Include, and their related methods aren't the only ways you can process external scripts - unfortunately you can use
eval()
as well. I would hope that you have none of this going on though. If you did have any scripts on your server that were using any one of the file functions to read the contents of another script, and theneval()
to evaluate that content as PHP, this could also provide a gaping security hole in your website.The problem is caused by your server using the default /etc/httpd/conf.d/php.conf:
The content of /etc/httpd/conf.d/php.conf is:
Please note the last line AddHandler php5-script .php . This is causing that problem and needs to be replaced with a more secure configuration
You can read more about it and how to apply a fix here ( see last reply):
http://core.trac.wordpress.org/ticket/11122
also see this:
https://bugzilla.redhat.com/show_bug.cgi?id=885839
Your
image_upload.php
is insecure, check the following:To check if it's an image you can run getimagesize on the file, it will return FALSE if it's not an image.
How is it possible to execute that file? First, how do you know it has been executed? Did you see side effects?
How to look at the logs?
Check the date and time of the uploaded file and start to look around there for suspicious activity (look at strange url parameters). Once you've find one or more IP address, doing evil things, grep the log for that (those) IPs, to see the whole story.
Another important info to know is, did you write the site or use a CMS or similar and in this case what is it and what version? You've to check published vulnerabilities and upgrade in case.