1. 程式人生 > >DVWA學習筆記--03--File Inclusion

DVWA學習筆記--03--File Inclusion

amp all not dvwa input https 必須 div 文件

0x00

三個是文件包含漏洞

分為遠程文件包含和本地文件包含兩種

但是遠程文件包含是需要開啟allow_url_include()這個函數才行

0x01

low

在low下的全部源碼

<?php

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

?>

想怎麽包含怎麽包含

如果包含的參數錯了 則會報錯 那麽服務器的路徑就給爆出來了(開了錯誤顯示)

技術分享

遠程包含--

技術分享

本地包含--

就沒寫別的文件 直接利用dvwa帶的文件

技術分享

如果不知道絕對路徑 僅有相對路徑也可以這樣包含

技術分享

0x02

medium

在medium下的全部源碼

<?php

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

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

可見medium下 增加了一個replace函數 將"http://", "https://","../", "..\"" 都進行了一次過濾

這種replace一次過濾還是很簡單的 雙寫繞過就好了

遠程包含--

技術分享

本地包含--

技術分享有絕對路徑的

技術分享沒有絕對路徑的

0x03

high

在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()函數

一個匹配的函數

意思就是在參數不為include.php的時候 參數必須以file開頭

因為題目給了三個本地文件嘛 file1.php file2.php file3.php

file-本地傳輸協議 主要用於訪問本地計算機中的文件

file:///path 這個可以直接訪問文件(file://也行)

所以把這個用上就能正好繞過這個防護

技術分享

至於遠程文件上傳我沒有找到什麽好姿勢

以後再看看其他的協議

0x03

impossible

在impossible下的全部源碼

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

?>

可見impossible下直接對傳入的參數進行了一個名單匹配

關於 ‘!= ‘的繞過只想到md5加密後的0e可以繞過

沒想到其他的繞過方法

而且就算繞過了也沒法訪問我們想要的路徑

所以沒辦法了(姿勢不夠)

DVWA學習筆記--03--File Inclusion