Check the .htaccess file
Using AddType in your .htaccess file, you can add many other extensions from which you can run PHP. As a rule, .html extensions can be used when using PHP inside themselves. So yes, maybe:
AddType application/x-httpd-php .jpg
You can check it if you want.
- Create a directory with two files: .htaccess and test.php.jpg
- Set .htaccess content to
AddType application-x-httpd-php .jpg - Set the contents of test.php.jpg to
<?php echo 'foo'; ?> <?php echo 'foo'; ?> - Access test.php.jpg via localhost
If everything goes as planned, "foo" is displayed. You can expand it to move /tmp files if you want.
Definitely what you want to be very careful with.
Check open calls to enable / require
Another way this could be done is to call require() or include() (or any of the _once() methods), which the hacker was able to load into his badfile.php.jpg file, which was loaded as an innocent image:
<?php include $_GET["file"]; ?>
In the above example (a simplified example), a hacker can go along the path to his .php.jpg file and download its contents and process it as PHP code.
Other (scary) ideas
Requiring, including associated methods is not the only way to process external scripts - unfortunately, you can also use eval() . I would hope you did nothing. If you had any scripts on your server that used any one of the file functions to read the contents of another script and then eval() to evaluate this content as PHP, this could also provide a vulnerable security hole in your website.
Sampson Nov 06 2018-11-11T00: 00Z
source share