In a recent development, I recently received a game called âHitsterâ as a gift. Itâs a board game where you try to identify songs and guess things like when they came out, who the artist or band is, etc. Each card has a QR code that you scan using the Hitster app, which then plays the music through Spotify or Apple Music.
Recent findings suggest that sadly, the app requires an Apple Music or Spotify subscription. In this blog post, Iâll go down the rabbit hole of reverse engineering the Android app and bypassing their very, very sloppy attempt at hiding the data.
First, we need to understand how the game works.
It has been revealed that on the front of each card, youâll find the artist or band name, the year the song came out, and the song title. On the back, thereâs a QR code. Scanning it takes you to a URL with two things in its path: the gameâs region (DE in my case) and the card ID. The music then starts playing in the app or through Spotify.
According to recent reports, this means thereâs a mapping from Card ID â Spotify Track. There are also multiple card versions per region, so the card ID alone isnât enough to identify a song. Card ID 1 might be âWet Dreamâ in the UK, but âTage wie dieseâ in Germany.
After getting the appâs APK from some sketchy Android APK download website, I used jadx to get the decompiled Java code.
After digging around for a bit, I found a few JSON files under res/raw. One of them was named gameset_database_4.json, and it seemed to be encrypted.
Industry observers note that I ran a tool to identify the format, and it came back as Base64. Thatâs an encoding, so I decoded it first. The result still wasnât readable, and I guessed it was encrypted with AES or something similar. (Related: Industry News: Simple considerations for simple people ...)
Iâd never reverse engineered an Android app before, so I just searched globally for AES. And guess what? There was a file called k43.java with the entire decryption process laid out in front of me:.
So letâs walk through this step by step.
The function f takes two strings as inputs. The first, str, contains the Base64-encoded data, which it decodes:.
It then checks whether the decoded data is at least 28 bytes long:.
Next, it passes a bunch of data to the function o, which handles the final stage of decryption:.
In a recent development, the first argument is the first 12 bytes of the decoded data. Thatâs our IV, or nonce. The second argument is the entire decoded byte array.
According to recent reports, the third argument is where things get interesting. It takes the total length minus 28 and passes that, along with str2, to the function m. Those 28 bytes account for the 12-byte nonce and the 16-byte authentication tag.
Inside m, the remaining length is converted to a string and joined with str2. That combined string is then hashed using SHA-256 to produce the AES key. (Related: How to train a newly introduced language model from scr...)
So str2 isnât the AES key itself. Itâs the secret string used to derive it, and we havenât found it yet.
Finally, o does the actual decryption:.
It sets up AES-GCM with the derived key and nonce, then decrypts the data after the first 12 bytes.
Thatâs the decryption process figured out. Now we just need the secret string.
I was doing this in a Discord call in the Rust Language Community server, and someone pointed out that I should look for a byte array with a length of 32 bytes.
Recent findings suggest that I first searched for byte[32], but didnât find anything useful. I then tried this pattern:.
That led me to m17.java, which contained these two super cool arrays:.
In a recent development, we then tried to figure out how to turn these into something useful. After a bit of experimenting, someone suggested XORing the two arrays together. We interpreted the resulting bytes as text and got this:.
Using this string, I wrote a little decryptor in Rust:.
That gave us this awesome test.txt file with around 31,000 lines of mappings from card IDs to Apple Music and Spotify tracks, plus ISRCs, across multiple regions.
We then looked around the code a little more and found out that all of this wasnât really needed.
If weâd searched for an HTTPS URL first, we wouldâve landed on this:.
https://hitster.jumboplay.com/hitster-assets/.
And with a little imagination, we tried:.
https://hitster.jumboplay.com/hitster-assets/gameset_database.json.
There was the entire thing. No encryption.
We spent around 18 hours chasing a file that, in the end, wasnât even a real secret.
