Stomped
Control flow flattening
stomped
Author: Fawl
Help! I was trying to retrieve my flags from my super secure safe, but I accidentally stepped on my binary.Background
Stomped was a challenge I made to explore an interesting obfuscation technique I'd run across a few times in the past, and was interested in testing out myself - control flow flattening. The challenge name alluded to that, somewhat.
Before we get to the challenge proper, I'd like to give the reader an overview of just what exactly control flow flattening accomplishes. This is with the goal of informing the reader's understanding of some terms I'll use, and the basic premise of the challenge itself.
Typically, programs execute in a manner that can be described as a flowchart when looking at the disassembly. At certain points, comparisons and checks may be made and flow of execution may divert down different diverging paths. By and large, loops aside, code proceeds in a linear manner when executed. This aids the reverse engineer - the flow of code execution can be traced quite simply using such a method.
Control-flow flattening aims to remove this indicator.

There are a few types of ways this can be done, and this link here covers them quite succintly. In brief, control flow flattening redirects the flow of execution using either switch statements, goto statements, indirect gotos through a jump table or through a table of function pointers.
In the interest of maximum fun, I chose the indirect function pointers (of course).
Undo-ing the Stomp
As always, our trusty file command:
Stripped binaries are annoying but we'll manage. Since it's a standard ELF, we throw it into our disassembler of choice (IDA's mine).
Let's also run the binary once, just to see what it does.
So, it's a flagchecker then. Time for some static analysis.
Here's C pseudocode, annotated for brevity.
At a first glance, some things are quite apparent:
An input of size 60 is expected.
Some data is loaded using XMM instructions to stack variables
A while loop
Last updated
Was this helpful?