DVWA靶场-文件包含漏洞

等级:low

1
2
3
4
<?php
// The page we wish to display
$file = $_GET[ 'page' ];
?>

源码很简单,就是获取一个get参数
直接../../php.info
成功获取php配置信息
证明漏洞

DVWA靶场-文件包含漏洞

等级:medium

1
2
3
4
5
6
7
<?php
// The page we wish to display
$file = $_GET[ 'page' ];
// Input validation
$file = str_replace( array( "http://", "https://" ), "", $file );
$file = str_replace( array( "../", "..\\" ), "", $file );
?>

相比于low,就是多出了对../和..\的过滤
直接使用…/./就可以绕过

DVWA靶场-文件包含漏洞

等级:high

1
2
3
4
5
6
7
8
9
10
11
<?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;
}
?>

这次又点狠了,直接把所有的路径都过滤掉了
但是却少想了伪协议
于是构造http://192.168.43.209/DVWA/vulnerabilities/fi/?page=file:///etc/passwd
成功!