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!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章