首先我们打开kali的apache服务,以此验证远程文件包含
后面都用index.html来验证远程文件包含
low
本地包含
直接调用dvwa文件目录下自带的phpinfo.php
可以用绝对路径来读
也可以构造相对路径来读
远程包含
可以直接读取其下的index.html
源码
<?php
// The page we wish to display
$file = $_GET[ 'page' ];
?>
并未做任何过滤
medium
本地包含
'..././'中的'../'被去除,则'..././'变为'../'以此来绕过
远程包含
双写绕过对http://协议的绕过
源码
<?php
// The page we wish to display
$file = $_GET[ 'page' ];
// Input validation
$file = str_replace( array( "http://", "https://" ), "", $file );
$file = str_replace( array( "../", "..\\" ), "", $file );
?>
我们可以采用双写来绕过过滤
high
用file协议来读取绝对路径下的phpinfo.php
源码
<?php
// The page we wish to display
$file = $_GET[ 'page' ];
// Input validation
if( !fnmatch( "file*", $file ) && $file != "include.php" ) {
// This isn't the page we want!
echo "ERROR: File not found!";
exit;
}
?>
fnmatch() 函数根据指定的模式来匹配文件名或字符串。
规定了必须用file协议来读取
File协议主要用于访问本地计算机中的文件,就如同在Windows资源管理器中打开文件一样