Code Monkey home page Code Monkey logo

tigress_protection's Introduction

Tigress Protections

Tigress is a diversifying virtualizer/obfuscator for the C language that supports many novel defenses against both static and dynamic reverse engineering and de-virtualization attacks.

In particular, Tigress protects against static de-virtualization by generating virtual instruction sets of arbitrary complexity and diversity, by producing interpreters with multiple types of instruction dispatch, and by inserting code for anti alias analysis. Tigress protects against dynamic de-virtualization by merging the real code with bogus functions, by inserting implicit flow, and by creating slowly-executing reenetrant interpreters. Tigress implements its own version of code packing through the use of runtime code generation. Finally, Tigress' dynamic transformation provides a generalized form of continous runtime code modification.

VMs descriptions

Tigress team has provided some challenges where we can find different kind of protections

  • VM-0: One level of virtualization, random dispatch.
  • VM-1: One level of virtualization, superoperators, split instruction handlers.
  • VM-2: One level of virtualization, bogus functions, implicit flow.
  • VM-3: One level of virtualization, instruction handlers obfuscated with arithmetic encoding, virtualized function is split and the split parts merged.
  • VM-4: Two levels of virtualization, implicit flow.
  • VM-5: One level of virtualization, one level of jitting, implicit flow.
  • VM-6: Two levels of jitting, implicit flow.

Challenge

All challenges take as input a number and return a hash. Example:

$ ./obfuscated_binaries/tigress-2-challenge-2 1234
202180712448

$ ./obfuscated_binaries/tigress-2-challenge-2 823748
50564355584

$ ./obfuscated_binaries/tigress-2-challenge-2 2834723
50714072576

The hash computation function is obfuscated. Types of possible attacks:

  • In a source recovery attack the task is to identify the algorithm that computes SECRET.
  • In a data recovery attack the task is to extract a specific run-time or compile-time data item.
  • In a metadata recovery attack the task is to identify the sequence of transformations that resulted in SECRET, along with arguments to those transformations, such as the dispatch method used in a virtualization.
  • In a location attack the task is to identify the code bytes of the program that comprise the obfuscated SECRET function.

Automatic deobfuscation

Our goals were to:

  • Symbolically extract the hash algorithm
  • Simplify these symbolic expressions
  • Provide python scripts where we can get the hash from a given input and get input collisions from a given hash
  • Provide a new simplified version of the binary

And all of this with only one generic script :). To do so, we made in the following order:

  • Symbolically emulate the obfuscated binary with Triton
  • Concretize everything which are not related to the user input.
  • Extract the hash algorithm and create input->hash and hash->inputs using templates
  • Convert Triton's expressions to the Arybo's expressions
  • Convert Arybo's expressions to the LLVM-IR representation
  • Apply LLVM optimizations (O2)
  • Rebuild a simplified binary version

If you want more information, you can checkout our solve-vm.py script.

solve-vm.py

Prerequisites: you must clone the branch dev-319-bis of Triton, the branch feature/exprs of Arybo and the llvmlite project.

However, we already pushed all of our results in this repository but if you want to reproduce by yourself this analysis, you only have to do execute solve-vm.py like this:

$ ./solve-vm.py ./obfuscated_binaries/_binary_

Example:

$ ./solve-vm.py ./obfuscated_binaries/tigress-0-challenge-0
./solve-vm.py:441: SyntaxWarning: name 'VM_INPUT' is assigned to before global declaration
  global VM_INPUT
[+] Loading 0x400040 - 0x400238
[+] Loading 0x400238 - 0x400254
[+] Loading 0x400000 - 0x400f14
[+] Loading 0x601e28 - 0x602550
[+] Loading 0x601e50 - 0x601fe0
[+] Loading 0x400254 - 0x400298
[+] Loading 0x400dc4 - 0x400e08
[+] Loading 0x000000 - 0x000000
[+] Loading 0x601e28 - 0x602000
[+] Hooking printf
[+] Hooking __libc_start_main
[+] Hooking strtoul
[+] Starting emulation.
[+] __libc_start_main hooked
[+] argv[0] = ./obfuscated_binaries/tigress-0-challenge-0
[+] argv[1] = 1234
[+] strtoul hooked
[+] Symbolizing the strtoul return
[+] printf hooked
3035321144166078008
[+] Slicing end-point user expression
[+] Instruction executed: 39817
[+] PC len: 0
[+] Emulation done.
[+] Generating symbolic_expressions/./tigress-0-challenge-0_input_to_hash.py
[+] Generating symbolic_expressions/./tigress-0-challenge-0_hash_to_input.py
[+] Converting symbolic expressions to an LLVM module...
warning: overriding the module target triple with x86_64-pc-linux-gnu [-Woverride-module]
1 warning generated.
[+] LLVM module wrote in llvm_expressions/./tigress-0-challenge-0.ll
[+] Recompiling deobfuscated binary...
warning: overriding the module target triple with x86_64-pc-linux-gnu [-Woverride-module]
1 warning generated.
[+] Deobfuscated binary recompiled: deobfuscated_binaries/./tigress-0-challenge-0.deobfuscated
$

Then, symbolic expressions can be found here, LLVM representations can be found here and recompiled binaries can be found here.

Testing our simplified binaries

As we simplified and recompiled new binaries, we must provide the same behavior of the original binaries. So, to test our binary versions we use this script.

$ ./testing_equality.py ./obfuscated_binaries/tigress-0-challenge-0 ./deobfuscated_binaries/tigress-0-challenge-0.deobfuscated
[...]
[+] Success with 272966812638982633
[+] Success with 2304147855662358786
[+] Success with 15697842028176298504
[+] Success with 15273138908025273913
[+] Success with 17329851347176088980
[+] Success with 12160831137213706322
[+] Success with 3489058267725840982
[+] Success with 6474275930952607745
[+] Success with 7363567981237584398
[+] Success with 3685039181436704621
[+] Success: 100.00

Basically, this script runs the obfuscated and the deobfuscated binaries with random inputs and checks if they have the same output results.

Benchmarks

Results with only one trace

With one trace

Results with the union of two traces

With two traces

Time of extraction per trace

Time per trace

Publication

Credits

tigress_protection's People

Contributors

jonathansalwan avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.