[Day 10] Hack a game You’re a mean one, Mr. Yeti¶
Le Cours¶
The Memory of a Program¶
Whenever we execute a program, all data will be processed somehow through the computer’s RAM (Random Access Memory). If you think of a videogame, your HP, position, movement speed and direction are all stored somewhere in memory and updated as needed as the game goes. If you can modify the relevant memory positions, you could trick the game into thinking you have more HP than you should or even a higher score! This sounds relatively easy, but a program’s memory space is vast and sparse, and finding the location where these variables are stored is nothing you’d want to do by hand. Hopefully, some tools will help us navigate memory and find where all the juicy information is at.
Be sure to hit the Start Machine button before continuing. The machine will start in a split-screen view. In case the VM is not visible, use the blue Show Split View button at the top-right of the page. All you need for this challenge is available in the deployable machine. If you prefer to do so, however, you can download and install Cetus on your own machine by downloading it from here. Cetus Logo
The Mighty Cetus¶
Cetus is a simple browser plugin that works for Firefox and Chrome, allowing you to explore the memory space of Web Assembly games that run in your browser. The main idea behind it is to provide you with the tools to easily find any piece of data stored in memory and modify it if needed. On top of that, it will let you modify a game’s compiled code and alter its behaviours if you want, although we won’t need to go that deep for this task.
Cetus is already installed on Chrome in your deployed machine, so you can use it straight away for the rest of the task. If you find the game runs slowly when using the in-browser machine, you can always install Cetus on your machine and do the task from there, following the indications given below.
Le Chall¶
Ce chall est encore bien guidé, et sert à apprendre. On se retrouve donc dans un jeu où l’objectif est de faire varier des informations en mémoire pour pouvoir gagner.
Question 1 : What is the Guard’s flag?¶
Pour cette question, il faut tout d’abord parler au garde une première fois et découvrir son chiffre.
À l’aide de Cetus, il est alors possible de regarder dans la mémoire où se trouve le nombre en question à l’aide d’une recherche avec un « EQ »(égal).
Une fois que l’on connaît son emplacement, on pourra le relire en parlant une seconde fois au personnage … Où la modifier directement pour qu’elle corresponde à ce que l’on désire.
En reparlant encore avec le gardien, on obtient son flag : THM{5_star_Fl4gzzz}.
Question 2 : What is the Yeti’s flag?¶
Une fois passer devant le gardien, on arrive sur un pont avec plein de boule de neige. Chaque boule nous fait perdre de la vie et l’on doit très vite recommencer.
Cet exercice permet de découvrir la recherche dynamique de Cetus : Quand on prend des dégâts, généralement, une variable diminue. Ainsi, on peut déjà enchaîner les recherches sans prendre de dégâts pour réduire le champs des emplacements mémoires de possibles (EQ). Ensuite, il suffit de prendre quelques dégâts pour rechercher la ou les variables qui ont diminué (LT). Heureusement, rien qu’une : notre vie. Libre à nous d’avoir autant d’HP que l’on désire … Ou de freezer la variable pour qu’elle ne bouge plus.
A la fin, on discute avec le yeti qui nous donne son flag : THM{yetiyetiyetiflagflagflag}.