amimo/goron

Function annotation not supported?

Closed this issue · 5 comments

amimo commented

It should work, I test it on llvm 7.
The inter-procedural obfuscation may not work for those functions that have annotation, so for better obfuscation result, you should not use those annotations.

Enable obfuscate globally will make our program runs very slow, obfuscate the sensitive part is strong enough for our case.

amimo commented
#define IROBF_ENABLE_FLATTENGING             __attribute((__annotate__(("fla"))))
#define IROBF_ENABLE_INDIRECT_BRANCH         __attribute((__annotate__(("indbr"))))
#define IROBF_ENABLE_INDIRECT_CALL           __attribute((__annotate__(("icall"))))
#define IROBF_ENABLE_INDIRECT_GLOBALS        __attribute((__annotate__(("indgv"))))

int b = 1;
int test(int a)
IROBF_ENABLE_FLATTENGING
IROBF_ENABLE_INDIRECT_BRANCH
IROBF_ENABLE_INDIRECT_CALL
IROBF_ENABLE_INDIRECT_GLOBALS
{
    if (a >= 0) {
        printf("a >= 0\n");
    } else {
        printf("a < 0\n");
    }
    return a + b;
}
clang -O2 -mllvm -irobf demo.c

You have to pass "-mllvm -irobf" to goron to enable the obfucation pass,then function annotation will do the trick. You still need to pass "-mllvm -irobf-cse" if you want to encrypt all c strings.

It works well. btw, is it easy to add clang 6.0 support?

amimo commented

It should be very easy to support clang 6, but I don't want to maintain too many branches.
One suggestion for getting stronger protection, you can compile you sensitive codes to a static library with all obfuscation passes enabled, configure your project to use this obfuscated library, then build your project with the official toolchain.