site templates free download



To obfuscate your program with Tigress first include the tigress.h file supplied in the Tigress distribution directory, and then invoke Tigress specifying at least one transformation applied to at least one function. Here is a trivial example where Tigress is flattening the function bar in the program foo.c:

#include "PATH-TO-TIGRESS-INSTALLATION/tigress.h"
void bar () {
    ...
}
int main () {
   ...
}
tigress \
   --Environment=x86_64:Linux:Gcc:4.6 \
   --Transform=Flatten \
      --Functions=bar \
   --out=foo_out.c foo.c

Command line options. These are some useful Tigress command line options:

*) tigress --help     : Show this message
*) tigress --install  : Show how to install Tigress 
*) tigress --test     : Show how to run tests to ensure proper installation 
*) tigress --license  : Display the tigress license
*) tigress --bugs     : How to get past some known issues
*) tigress --version  : Show the current Tigress version

Multiple Input Files. Note that Tigress accepts exactly one C file as input. This is so that Tigress can do whole-program analysis and transformations. If your project has multiple files you must first merge them together into one. Tigress (through the CIL library on which it is built) allows you to merge your source files automatically. For complex scenarios, see the CIL information page about merging. For simple cases, all you have to do to merge two files file1.c and file2.c into full.c, is to call the tigress-merge program like this: 

$ tigress-merge file1.c file2.c --out=full.c

Cross-compilation and 32-vs-64-bit machine models. By default, we assume you're generating code for the machine on which you execute Tigress. If this is not the case, in particular, if your target machine has a different wordsize than the one you compile on, you must run Tigress with the --envmachine option and set the CIL_MACHINE environment variable with the relevant C type sizes. For the current version of Tigress, this is really only relevant for the virtualize transformation. See the CIL documentation for more information.

If you want to use a specific compiler (other than the default gcc)  you can use the --gcc=command to tell cilly which compiler to use, for example --gcc=arm-elf-gcc.

Here's an example of how to set CIL_MACHINE for a typical 32-bit target:

CIL_MACHINE="short=2,2 int=4,4 long=4,4 long_long=8,8 pointer=4,4 \
             alignof_enum=4 float=4,4 double=8,8 long_double=12,12 \
             void=1 bool=1,1 fun=1,1 alignof_string=1 max_alignment=16 \
             size_t=unsigned_int wchar_t=int char_signed=true \
             const_string_literals=true big_endian=false \
             __thread_is_keyword=true __builtin_va_list=true \
             underscore_name=true"; export CIL_MACHINE;

WebAssembly: Below is an example of how to first obfuscate a C program foo_in.c with Tigress, and then compile the obfuscated file foo_obf.c with Emscripten to a WebAssembly/html/Javascript package. Note the use of the CIL_MACHINE environment variable and the --envmachine argument to Tigress; these specify that the word size of the target machine (WASM) is different from that of the machine of which Tigress is run. Notice also the --gcc=emcc argument to Tigress. This specifies that the WebAssembly compiler (emcc) should be used, rather than the native C compiler.

export EMSDKPATH=PATH-TO-EMCC-INSTALLATION/emsdk/emscripten/1.38.29/system/include/

export CIL_MACHINE="short=2,2 int=4,4 long=4,4 long_long=8,8 pointer=4,4 alignof_enum=4 float=4,4 \
             double=8,8 long_double=8,8 void=1 bool=1,1 fun=1,4 alignof_string=1 max_alignment=16 \
             size_t=unsigned_long wchar_t=int char_signed=true const_string_literals=true \
             big_endian=false __thread_is_keyword=true __builtin_va_list=true underscore_name=true"
             
tigress \
   --gcc=emcc \
   --envmachine \
   -D _Float128=double \
   -I $EMSDKPATH \
   --Environment=x86_64:Linux:Gcc:4.6 \
   --Transform=Flatten \
      --Functions=bar \
   --out=foo_obf.c foo_in.c 
emcc \
   -I $EMSDKPATH \
   -O2 \
   foo_obf.c \
   -o foo_wasm.html \
   -s WASM=1 \
   -s ALLOW_MEMORY_GROWTH=1 \
   -s AGGRESSIVE_VARIABLE_ELIMINATION=1 \
   -s ERROR_ON_UNDEFINED_SYMBOLS=0 \
   -s USE_WEBGL2=1 \
   -s USE_GLFW=3 \
   -s FULL_ES3=1 \
   -fmacro-backtrace-limit=0

Android: Tigress has not been extensively tested on Android, but the following commands seem to work. Download the Android NDK from https://developer.android.com/ndk/downloads. Create the following shell script, name it "compiler", and set the target to the platform for which you want to compile:

#!/bin/sh

./toolchains/llvm/prebuilt/darwin-x86_64/bin/clang -target aarch64-none-linux-android21 "$@"

If you're not on OSX, you need to replace darwin-x86_64 with the appropriate path. Set CIL_MACHINE to the appropriate value for your target (depending on if it is a 32 or 64 bit architecture). Assuming you have two files foo.c and bar.c, issue these commands to merge them into out.c and obfuscate them into obf.c:

> cd android-ndk-r20b

> chmod a+rx ./compiler

> CIL_MACHINE="short=2,2 int=4,4 long=4,4 ...; export CIL_MACHINE;

> tigress-merge --Environment=x86_64:Linux:Gcc:4.6 --envmachine --gcc=./compiler foo.c bar.c --out=out.c
> tigress --Environment=x86_64:Linux:Gcc:4.6 --envmachine --gcc=./compiler --Transform=Flatten --Functions=fib out.c --out=obf.c

Bugs and other issues. There are some platform specific issues (particularly on clang/Darwin), and some bugs that originate either in CIL or the underlying compilers. Here's what we know about:

  • Darwin extensions. If you experience issues on clang/Darwin, start by including this file: bin/tigress/3.0/tigress.h at the top of your source files. If you still get compilation errors (in particular when the tigress processes standard .h files, such as stdio.h), let me know. I think I have covered all the issues (particularly with the #include<Availability.h> file), but since there's not much documentation it's hard to know.
  • Clang issue (1). Compile with -fgnu89-inline  to get past a redeclaration bug in MAC OS 10.9. For an explanation, see, for example, http//sourceforge.net/p/resil/tickets/6.
  • Clang issue (2). Compile with -Wno-builtin-requires-header to avoid a spurious warning generated by clang.
  • CIL issue (1). CIL fails on Gcc torture test pr15296.c: typedef int __attribute__ ((mode (__pointer__))) intptr_t;
  • CIL issue (2). CIL fails on __alignof__(void).
  • Glibc issue. If you get someting like
       /usr/include/bits/mathcalls-helper-functions.h[21:12-28] : syntax error
       Parsing errorFatal error: exception Frontc.ParseError("Parse error")
    you may have run into an issue with recent versions of glibc which now support 128-bit floats (Tigress doesn't). There are two potential ways to fix this:
    1) add -D _Float128=double to the Tigress command line or 2) add #undef __HAVE_DISTINCT_FLOAT128 before including math.h.
  • C99 issue. Tigress supports the C99 language. Depending on your compiler, you may have to add a switch (such as -std=c99 for gcc) to indicate this.