Buuctf-Web-[ACTF2020 新生賽]Include
阿新 • • 發佈:2022-05-13
前言
刷題網址:https://buuoj.cn/challenges#[ACTF2020 新生賽]Include
首先開啟網頁,提示tips
點選他,根據題目提示很難不想到是檔案包含,但是提示是能找到外面的flag嗎,如下圖。
這裡我猜想的是否在上上一個目錄,../
上一個目錄,但是無論我輸多少都不行。
所以這裡我轉換思路嘗試去讀取,index.php,發現也不行,所以這裡我猜想的是,是不是php偽協議
,關於php偽協議的東西可以自行百度查詢,這裡我使用php://filter
讀取檔案,發現讀取成功,這裡我讀取的是index.php
,讀取使用的payload如下,是把檔案以base64的方式讀取,然後我們拿去網址線上解密。
payload: /?file=php://filter/read=convert.base64-encode/resource=index.php
解密程式碼如下,我們可以清晰的看見,如果file裡面有這些php://input
,zip://
,phar://
,data:
就會直接退出程式,並且報錯hacker
。
這裡沒有過濾php://filter
所以我們能進來。
<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>'; } ?>
既然是這樣,我們在嘗試讀取一下flag.php
試試,payload如下。
payload: /?file=php://filter/read=convert.base64-encode/resource=flag.php
然後我們在拿去base64解密,flag就出來了,如下圖。