Hellscape

Files in examples/ of tip
Login

Files in examples/ of tip

Files in directory /examples from the latest check-in


Examples

C tutorial

Throughout this walk-through, we'll use the target function in target.c. The CFG produced by this function (including GIMPLE IR) is as follows:

gcc -fplugin=../build/hellscape.so \
    -fplugin-arg-hellscape-viz=. \
    -c target.c -o /dev/null

The compiler plugin is easy to use; let's enable each pass one-by-one and look at the CFG, then at the end run all 3 passes together.

Instruction Substitution

For the first magic trick, instruction substitution. The command below,

$ gcc -fPIC -fplugin=/path/to/hellscape.so -fplugin-arg-hellscape-seed=deadbeef -fplugin-arg-hellscape-sub target.c

Let's view the produced CFG with the Viz class:

Bogus Control Flow

Now for a smokescreen: bogus control flow. The command below,

$ gcc -fPIC -fplugin=/path/to/hellscape.so -fplugin-arg-hellscape-seed=deadbeef -fplugin-arg-hellscape-bcf target.c

Again, viewing the CFG:

Flattening

The last trick (for now) is flattening. The command below,

$ gcc -fPIC -fplugin=/path/to/hellscape.so -fplugin-arg-hellscape-seed=deadbeef -fplugin-arg-hellscape-fla target.c

Then, viewing the CFG:

All at once

Simply rolling all the above commands together, we get the following CFG (view in a browser):

$ gcc -fPIC -fplugin=/path/to/hellscape.so -fplugin-arg-hellscape-seed=deadbeef -fplugin-arg-hellscape-fla -fplugin-arg-hellscape-bcf -fplugin-arg-hellscape-sub target.c

And of course in IDA it is even worse due to switch lowering:

gccgo

This example explains building a Go executable obfuscated with Hellscape.

For this guide, you will need gccgo installed. The standard Go executable will NOT work with this example.

In the CMakeLists.txt, edit the execute_process command to use the gccgo executable instead of the standard gcc executable. Then, build Hellscape as normal.

It can then be used with the main.go provided here with the example command (to enable all passes):

$ gccgo -fplugin=/path/to/hellscape.so -fplugin-arg-hellscape-seed=deadbeef -fplugin-arg-hellscape-fla -fplugin-arg-hellscape-bcf -fplugin-arg-hellscape-sub main.go