Knocking our opps with a debugger (PhaserJS)
Of course I didn’t used those cheats to win the prizes, I’m not that down bad 🥀
Introduction
While wasting my times on snapchat I came across an ad about a game for promoting the new album of a rapper and I wondered if I could cheat on it.
The game is hosted at https://www.ladouille.fr/ and is a 2D web browser game where you have to eliminate the ennemies, the “opps”, coming from the both sides of the screen.
Eliminating a target earns you 1 point, and eliminating multiple targets quickly get you a combo and more points.
The player is supposed to make the biggest score so he can have a chance to win a 100€ gift card or a custom gold disc (350€).
When the game is finished, we are asked to fill out a form to enroll to the giveway :

Let’s dive in !
Finding where the code is
The whole game is stored client side on two JS file :
- index-ByZ33U9g.js ~15000 lines
- phaser-DJkhv3Fe.js ~70000 lines
When I saw the line count, I told myself “naaah I ain’t reading ts 🥀”.

The “phaser.js” made me curious so I looked up in google and found out that it is a HTML 5 game engine based on javascript : https://phaser.io/. It uses WebGL and Canvas.
Also, by opening the console when the page load, we got a log message mentionning Phaser :
By intuition, I thought that index-ByZ33U9g.js
(I will refer as ‘index.js’ from now), is the main part of the game. And by reading it we see that the other JS file is imported :
|
|
The variable names are made of one letter, reminding me of a compressed or obfuscated JS code. There is tooooo many code so my first move was looking for strings in the code. And to know which one, I tried to look what happen when I press the “Commencer” button (“Start” in french) and look for this in the JS code.
But nothing is specified in the HTML :
So I immediately look up in index.js
for “Commencer” and got only one result :
|
|
So the event 'start-game'
is started when the button Commencer
is pressed.
By looking again in the code, we find that 'start-game'
is defined in the class be
, which inherit C.Scene
class, a PhaserJS class.
Which run this.handleStartGame
:
|
|
This function is defined right above and run : this.scene.start('Game')
, where this
is the be
class.
However, scene.start
is not defined in index.js
, so it must be part of phaser.js
because be
class inherit C.Scene
.
And C
further in the code is defined in index.js
and is equal to r()
, a function exported from PhaserJS supposed to be the game context.
Here are the exported functions in the phaser.js
file :
|
|
For example in another Phaser game, Phaser is exported like that :
|
|
So I understand that our target game source code is compressed or altered in someway. The fact is, for this game the Phaser template used is for React JS, that’s why the code is different.
However there are still hardcoded value so it slightly changes the difficulty.
Now, we need to know where is the actual code handling the ennemies we attack, our score and stuff ? Well reading the documentation for making a Pḧaser game, we learn about essential functions :
create()
: This function will define Phaser variables, staging and everything.upload()
: This function will be executed in a loop to check some events, for instance it handle what to do when and ennemy attack a player.preload()
: Phaser will automatically loof for this function when it starts a scene load anything defined within it..
Then we can search for those functions in the code.
And we can find a nice reference under the class ve
which call the superclass ‘GAME’
|
|
We can see that some very interesting variables are defined :
|
|
Finding where the code REALLY is
Now we know that, how can we edit those variables and have a big score ?
Usually, we could directly edit the variable on the console, and edit the properties inside the ve
class instance, but first we need to find this instance.
Fast forward, I found further in the code that ve
alongside other classes were put in another variable ke
:
|
|
And the game start with ke
as argument :
|
|
So, the game context is stored in n.current
. However, when I start the game I couldn’t find any n
variable in the console, it returns undefined
.
It’s weird because the game is actually here, I can play it.

The answer is, if n
is accessed in a specific context, I can also access it but only in this specific context.
This guy got the same case.
So we need to use the debugger to add a breakpoint inside the function where n
is defined, create a reference to it and we should be able to do our modifications.
In the debugger we can open index.js
which is a one liner but we can format it by clicking on {}
on bottom left corner.
Now we can breakpoint on any line not grayed out. I chose to break at line 14715
because it occurs after the definition of n.current
and because the other line 14706
just never stop the execution.
Now when refreshing the page I got a white overlay over the web page and in the console I can find n.current
.
We can set a reference to it :
|
|
By searching a bit we can find where the properties are stored, inside window.gameRef.scene.keys.Game
:
Now we can play and try to edit some values.

Cheating in the game
Infinite lives
We can just set infinite lives by setting lives
values :
|
|
No further check is made and the lifebar overflows :
And as we will take to much time to get to 0 HP, we can stop the game in the console with window.gameRef.scene.keys.Game.stopGame()
.
Big score
The score is saved at the same place as the lives. And it is updated while we play so we are at the right place :
Let’s update it :
At the end of the game the score is correctly set :

God mode (almost)
For this cheat I aimed to keep the same the life points, but not take any damage and still get point. Because, the default behaviour in the game when ennemy attack me, is to lose HP and not get any point.
First I started by investigating the function responsible for taking damage and killing ennemy. I saw setupCollision
to be a good candidate and I was right.
setupCollisions
|
|
In shorts :
- We take damage if we are not attacking, and if
life <= 0
-> gameOver - If the most recent kill was made under 500ms, a combo is started
- If we dash (dash==attack), we get invincible during the dash, and if we aslo touch an ennemy, we get a point
Like that, we learn about an invinciblity ability already implemented. Looking in the code, we can find those three functions :
|
|
To keep it shorts, when dashing, isInvincible
is set to 1. And in other place in the code, the dash set a timer after which one isInvincible
is set back to 0 by calling stopInvincibility()
.
Now let’s replace those functions to always keep isInvincible
active :
|
|
And it works, but I can’t move and I don’t know why (I’m too lazy to investigate) :
Conclusion
In the end, it wasn’t much difficult to cheat in this game even though some functions were renamed and made less understable. As PhaserJS is a client side engine, I managed to cheat on other games the same way, sometimes easily and sometimes not.
I still cannot find a way to script my cheats with tool like tampermonkey as I have to use the debugger (if someone have an idea, I’m all ears : wepfen on Discord).