
半年ぶりの TryHackMe で Advent of Cyber 2023 に挑む 6日目【Advent of Cyber: Day 6】
[Day 6] Memories of Christmas Past
バッファオーバーフローを利用してゲームで好き放題やってしまおうというお話。
If the coins variable had the in-memory value in the image below, how many coins would you have in the game?

適当な変換サイトを用いて 16 進数から 10 進数に変換すればよい。メモリの並びがリトルエンディアンであることに注意。

What is the value of the final flag?
まずゲーム画面内の PC をひたすら叩いて 16 枚のコインを得る(PC はぶっ壊れる)。

16 枚のコインで 16 文字分名前を変更する(ここでは koikoikoikoiaaaa)。aaaa の部分が名前を管理するメモリ領域からはみ出てコインを管理する領域に入ることで大金が手に入る。

これでスターが購入できるかと思いきや、商人が難癖を付けてきて売ってくれず、別のアイテムを渡される。これではゲームをクリアできない。
そこで今度はアイテム欄(インベントリ)に着目すると、アイテムを管理するメモリ領域の ASCII 表現と商人が管理するアイテムの ID とが一致する。再度名前変更でバッファオーバーフローを発動させ、アイテムを管理するメモリ領域まで浸食させる。アイテム欄に "d" が入ればスターが手に入るのであとはツリーに話しかけてゲームクリアとなる。

Van Jolly still thinks the Ghost of Christmas Past is in the game. She says she has seen it with her own eyes! She thinks the Ghost is hiding in a glitch, whatever that means. What could she have seen?
この問題(?)は No answer needed なのだがちょっと気になったのでいろいろ触ってみた。
商人が売るアイテムに ID が "a" のものがなかったので見てみると、昨年の Advent of Cyber 2022 で悪さをしていたイエティ君がアイテム欄にあることがわかる。Van Jolly はこのイエティを the Ghost of Christmas Past だと思ったのではないか。知らんけど。ちなみに the Ghost of Christmas Past とは小説『クリスマス キャロル』に登場する架空の人物らしい。知らんけど。

感想
去年に続いてのゲーム回。前回は無敵チートで爽快感があったが、今回のもハックしてる感(?)あってよかったと思う。文字入力はなんたらインジェクションとかもあっていろいろバグをうみやすいみたいである。数多くのバグが存在する可能性があるので界隈の人は入力欄を見ると興奮するらしい。知らんけど。