DVWA 实验报告:4、文件包含 File Inclusion

文章更新于:2020-04-15

一、安全级别:Low

1.1、源码

<?php

// The page we wish to display
$file = $_GET[ 'page' ];

?>

1.2、攻击

可以看出,源码中没有做任何防护,这意味着我们有可能能读取到任意文件。
当我们在地址栏构造如下地址时:

http://home.cc/dvwa/vulnerabilities/fi/?page=../../../../../../etc/passwd

可以获得密码文件的内容:
在这里插入图片描述
包含远程文件:
在这里插入图片描述

二、安全级别:Medium

2.1、源码


<?php

// The page we wish to display
$file = $_GET[ 'page' ];

// Input validation
$file = str_replace( array( "http://", "https://" ), "", $file );
$file = str_replace( array( "../", "..\"" ), "", $file );

?>

2.2、攻击

从源码可以看出,对 http 等字符进行了替换。
但大小写却没有校验。
所以我们可以:
在这里插入图片描述

三、安全等级:High

3.1、源码

<?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;
}

?>

3.2、攻击

源码可以看出,
文件要么是 file 开头,
要么是 include,php,
否则报文件未找到错误。
那么:
在这里插入图片描述

四、安全等级:Impossible

4.1、源码

<?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;
}

4.2、攻击

白名单过滤机制,
攻击没戏。

五、Enjoy!

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值