Featured image of post Forging a client-side score to beat an unbeatable game - PwnMe 2023

Forging a client-side score to beat an unbeatable game - PwnMe 2023

Beating an unbeatable game by forging the client-side score request. PwnMe 2023 web write-up.

Introduction

This challenge is a WEB challenge from the PWNME 2023 CTF.

Context explanation

A pro player challenges you in a new game. They have spent a lot of time on it and achieved an extremely high score.

Directive

Your goal is to beat them by any means necessary.

Solution

It’s a game: pilot a ship, dodge shots, shoot enemies.

Beat me!

The score to beat belongs to Eteck, the challenge author, at 1337420. We’re obviously not grinding that out legitimately, so let’s find a flaw instead.

At the end of a run, two requests fire:

  • POST /scores: to send the score obtained at the end of the game.
  • GET /scores: to retrieve the scoreboard.

Beat me!

The score POST looks like:

{
    "name": "HitCat",
    "score": 12,
    "signature": -1166920824
}

Replaying it with a bumped score fails on the signature:

Beat me!

So the score is signed client-side. The home page is unremarkable apart from a few script imports, including /js/main.0acc8a51228c77e4a908.bundle.js, which is obfuscated.

Rather than deobfuscate it, I set a breakpoint and let the browser do the work. Searching signature leads to this function:

signature

The signature is _0x3f306f(_0x5a84cd), presumably a hash function over the score. Stepping through confirms it:

signature

Top-left, my score is 12; on the right, _0x5a84cd is also 12. So that variable is the score, and it’s signed right here before being sent.

Paused on the breakpoint, I just overwrite _0x5a84cd with a huge value:

signature

The signature is then computed over the forged score, so it’s valid, and resuming posts it and prints the flag:

signature

Flag: PWNME{ChE4t_oN_cLI3N7_G4m3_Is_Not_3aS1}

Tips & Tricks

  • Debug the JavaScript code to see how data is processed.
  • Use the debugger to modify values.
  • Don’t overlook obfuscated or minified JavaScript files; often, they contain valuable information.