DVWA之 File Inclusion
1.LOW级别
1.PHP代码分析
我们可以通过 View Source获得代码如下
<?php
// The page we wish to display
$file = $_GET[ 'page' ];
?>
服务器获取 page 的值,没有进行任何过滤。
二 MEDIUM级别
1.PHP代码分析
我们可以通过 View Source获得代码如下
<?php
// The page we wish to display
$file = $_GET[ 'page' ];
// Input validation
$file = str_replace( array( "http://", "https://" ), "", $file );
$file = str_replace( array( "../", "..\"" ), "", $file );
?>
1、使用绝对路径绕过。
2、使用的是 str_replace() 函数,可以使用重写的方式绕过
htthttp://p:// -> http://
三 HIGH级别
1.PHP代码分析
我们可以通过 View Source获得代码如下
<?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()函数检查page参数,要求page参数的开头必须是file,服务器才会去包含相应的文件。可配合文件上传漏洞利用。
?page=file:///F:/phpStudy/PHPTutorial/WWW/dvwa/php.ini
四 IMPOSSIBLE级别
<?php
// The page we wish to display
$file = $_GET[ 'page' ];
// Only allow include.php or file{1..3}.php
if( $file != "include.php" && $file != "file1.php" && $file != "file2.php" && $file != "file3.php" ) {
// This isn't the page we want!
echo "ERROR: File not found!";
exit;
}
?>
固定了文件名,无解