Lurker News
OFRAK Tetris is a project I started at work about two weeks ago. It's a web-based game that works on desktop and mobile. I made it for my company to bring to events like DEF CON, and to promote our binary analysis and patching framework called OFRAK.

In the game, 32-bit, little-endian ARM assembly instructions fall, and you can modify the operands before executing them on a CPU emulator. There are two segments mapped – one for instructions, and one for data (though both have read, write, and execute permissions). Your score is a four byte signed integer stored at the virtual address pointed to by the R12 register, and the goal is to use the instructions that fall to make the score value in memory as high as possible. When it's game over, you can download your game as an ELF to relive the glory in GDB on your favorite ARM device.
The CPU emulator is a version of Unicorn (https://www.unicorn-engine.org/) that has been cross-compiled to WebAssembly (https://alexaltea.github.io/unicorn.js/), so everything on the page runs in the browser without the need for any complicated infrastructure on the back end.
Since I've only been working on this for a short period of time leading up to its debut at DEF CON, there are still many more features I'd eventually like to implement. These include adding support for other ISAs besides ARM, adding an instruction reference manual, and lots of little cleanups, bug fixes, and adjustments.
My highest score is 509,644,979, but my average is about 131,378.
I look forward to feedback, bug reports, feature requests, and strategy discussions!

Comments (53) 23 threads

Show all comments

Showing thread 3 of 23

mpeg2 replies#
This is so clever, I couldn't help but smile when I saw "Your score is stored in memory at the address pointed to by R12" :)

Thanks for sharing, it does makes me miss DEFCON, maybe next year...

velosol1 reply#
Is the reason for R12 making you smile something you could share?
mpeg#
It's the fact that the score is handled within the game mechanics itself – so the way to get a high score is not just to play but to play with the goal of modifying R12 (so it points to a high value)

They could have easily made score be handled outside the game and you get a point per every executed statement within the time limit etc – but that would not be as fun

Jerry85381 reply#
> Your score is stored in memory at the address pointed to by R12

As someone who has very little idea of what instructions or addresses are, what is this a reference to?
Edit: I had the page loaded before your reply, so I didn't see it until I replied, reloading the page lol

justsid1 reply#
It's not a reference, it's just a really neat game mechanic. Normally the high score is guarded by the game and changes only if the game deems it fit to change it. In this game, because the high score is accessible within the game and you can execute arbitrary instructions, you can use that to modify the high score.

It's as if in a more normal game the high score was kept in a big chest somewhere in the game world and once discovered you can start messing with the contents of it all within the rules of the world itself.