playing with binary analysis
play

Playing with Binary Analysis Deobfuscation of VM based software - PowerPoint PPT Presentation

Playing with Binary Analysis Deobfuscation of VM based software protection Jonathan Salwan, Sbastien Bardin and Marie-Laure Potet SSTIC 2017 Topic Binary protection Virtualization-based software protection Automatic


  1. Playing with Binary Analysis Deobfuscation of VM based software protection Jonathan Salwan, Sébastien Bardin and Marie-Laure Potet SSTIC 2017

  2. Topic Binary protection ● Virtualization-based software protection ○ Automatic deobfuscation, our approach ● The Tigress challenges ● Limitations ● ● What next? Conclusion ●

  3. Binary Protection

  4. Binary Protection Goal ● Turn your program to make it hard to analyze ○ Protect your software against reverse engineering ■ P Transformation P’

  5. Binary Protection There are several kinds of protection ● [...] ○ Virtualization-based software protection ○

  6. Binary Protection - Virtualization Also called Virtual Machine (VM) ● Virtualize a custom Instruction Set Architecture (ISA) ●

  7. Binary Protection - Virtualization Also called Virtual Machine (VM) ● Virtualize a custom Instruction Set Architecture (ISA) ● long secret(long x) { [transformations on x] return x; } bool auth(long user_input) { long h = secret(user_input); return (h == 0x9e3779b97f4a7c13); }

  8. Binary Protection - Virtualization Also called Virtual Machine (VM) ● Virtualize a custom Instruction Set Architecture (ISA) ● long secret(long x) { [transformations on x] Bytecodes - Custom ISA return x; } bool auth(long user_input) { long h = secret(user_input); return (h == 0x9e3779b97f4a7c13); }

  9. Binary Protection - Virtualization Also called Virtual Machine (VM) ● Virtualize a custom Instruction Set Architecture (ISA) ● long secret(long x) { [transformations on x] Bytecodes - Custom ISA return x; } bool auth(long user_input) { long h = 0; VM(opcodes, &h, user_input); return (h == 0x9e3779b97f4a7c13); }

  10. Binary Protection - Virtualization Also called Virtual Machine (VM) ● Virtualize a custom Instruction Set Architecture (ISA) ● Removed long secret(long x) { [transformations on x] Bytecodes - Custom ISA return x; } bool auth(long user_input) { long h = 0; VM(opcodes, &h, user_input); return (h == 0x9e3779b97f4a7c13); }

  11. Binary Protection - VM Design (a simple one) Fetching Decoding Dispatcher Close to a CPU design ● Operator 1 Operator 2 Operator 3 a. Fetch the opcode pointed via the virtual IP b. Decode the opcode - mnemonic / operands c. Dispatch to the appropriate semantics handler d. Execute the semantics Terminator e. Go to the next instruction or terminate

  12. Binary Protection - VM Design (a simple one) Fetching long secret(long x) { Decoding [transformations on x] Bytecodes - Custom ISA return x; } Dispatcher Close to a CPU design ● Operator 1 Operator 2 Operator 3 a. Fetch the opcode pointed via the virtual IP b. Decode the opcode - mnemonic / operands c. Dispatch to the appropriate semantics handler d. Execute the semantics Terminator e. Go to the next instruction or terminate

  13. Binary Protection - VM Design (a simple one) Fetching Bytecodes - Custom ISA Decoding Fetch : Dispatcher Decode : Code : Operator 1 Operator 2 Operator 3 Terminator

  14. Binary Protection - VM Design (a simple one) Fetching Bytecodes - Custom ISA Decoding Fetch : 0xaabbccdd Dispatcher Decode : Code : Operator 1 Operator 2 Operator 3 Terminator

  15. Binary Protection - VM Design (a simple one) Fetching Bytecodes - Custom ISA Decoding Fetch : 0xaabbccdd Dispatcher Decode : mov r/r Code : Operator 1 Operator 2 Operator 3 Terminator

  16. Binary Protection - VM Design (a simple one) Fetching Bytecodes - Custom ISA Decoding Fetch : 0xaabbccdd Dispatcher Decode : mov r/r Code : Operator 1 Operator 2 Operator 3 Terminator

  17. Binary Protection - VM Design (a simple one) Fetching Bytecodes - Custom ISA Decoding Fetch : 0xaabbccdd Dispatcher Decode : mov r/r Code : mov r1, input Operator 1 Operator 2 Operator 3 Terminator

  18. Binary Protection - VM Design (a simple one) Fetching Bytecodes - Custom ISA Decoding Fetch : Dispatcher Decode : Code : mov r1, input Operator 1 Operator 2 Operator 3 Terminator

  19. Binary Protection - VM Design (a simple one) Fetching Bytecodes - Custom ISA Decoding Fetch : 0x11223344 Dispatcher Decode : Code : mov r1, input Operator 1 Operator 2 Operator 3 Terminator

  20. Binary Protection - VM Design (a simple one) Fetching Bytecodes - Custom ISA Decoding Fetch : 0x11223344 Dispatcher Decode : mov r/i Code : mov r1, input Operator 1 Operator 2 Operator 3 Terminator

  21. Binary Protection - VM Design (a simple one) Fetching Bytecodes - Custom ISA Decoding Fetch : 0x11223344 Dispatcher Decode : mov r/i Code : mov r1, input Operator 1 Operator 2 Operator 3 Terminator

  22. Binary Protection - VM Design (a simple one) Fetching Bytecodes - Custom ISA Decoding Fetch : 0x11223344 Dispatcher Decode : mov r/i Code : mov r1, input mov r2, 2 Operator 1 Operator 2 Operator 3 Terminator

  23. Binary Protection - VM Design (a simple one) Fetching Bytecodes - Custom ISA Decoding Fetch : Dispatcher Decode : Code : mov r1, input mov r2, 2 Operator 1 Operator 2 Operator 3 Terminator

  24. Binary Protection - VM Design (a simple one) Fetching Bytecodes - Custom ISA Decoding Fetch : 0x5577aabb Dispatcher Decode : Code : mov r1, input mov r2, 2 Operator 1 Operator 2 Operator 3 Terminator

  25. Binary Protection - VM Design (a simple one) Fetching Bytecodes - Custom ISA Decoding Fetch : 0x5577aabb Dispatcher Decode : mul r/r/r Code : mov r1, input mov r2, 2 Operator 1 Operator 2 Operator 3 Terminator

  26. Binary Protection - VM Design (a simple one) Fetching Bytecodes - Custom ISA Decoding Fetch : 0x5577aabb Dispatcher Decode : mul r/r/r Code : mov r1, input mov r2, 2 Operator 1 Operator 2 Operator 3 Terminator

  27. Binary Protection - VM Design (a simple one) Fetching Bytecodes - Custom ISA Decoding Fetch : 0x5577aabb Dispatcher Decode : mul r/r/r Code : mov r1, input mov r2, 2 Operator 1 Operator 2 Operator 3 mul r3, r1, r2 Terminator

  28. Binary Protection - VM Design (a simple one) Fetching Bytecodes - Custom ISA Decoding Fetch : Dispatcher Decode : Code : mov r1, input mov r2, 2 Operator 1 Operator 2 Operator 3 mul r3, r1, r2 Terminator

  29. Binary Protection - VM Design (a simple one) Fetching Bytecodes - Custom ISA Decoding Fetch : 0x1337dead Dispatcher Decode : Code : mov r1, input mov r2, 2 Operator 1 Operator 2 Operator 3 mul r3, r1, r2 Terminator

  30. Binary Protection - VM Design (a simple one) Fetching Bytecodes - Custom ISA Decoding Fetch : 0x1337dead Dispatcher Decode : ret r Code : mov r1, input mov r2, 2 Operator 1 Operator 2 Operator 3 mul r3, r1, r2 Terminator

  31. Binary Protection - VM Design (a simple one) Fetching Bytecodes - Custom ISA Decoding Fetch : 0x1337dead Dispatcher Decode : ret r Code : mov r1, input mov r2, 2 Operator 1 Operator 2 Operator 3 mul r3, r1, r2 Terminator

  32. Binary Protection - VM Design (a simple one) Fetching Bytecodes - Custom ISA Decoding Fetch : 0x1337dead Dispatcher Decode : ret r Code : mov r1, input mov r2, 2 Operator 1 Operator 2 Operator 3 mul r3, r1, r2 ret r3 Terminator

  33. Binary Protection - VM Design (a simple one) Fetching Bytecodes - Custom ISA Decoding Fetch : Dispatcher Decode : Code : mov r1, input mov r2, 2 Operator 1 Operator 2 Operator 3 mul r3, r1, r2 ret r3 Terminator

  34. Virtual Machine - Standard Reverse Process Reverse and understand the virtual machine’s structure / components ● Create a disassembler and then reverse the bytecodes ● ? Bytecodes ? Create a disassembler ? Disassembly ? ? ? Start Reversing ?

  35. Our Approach Automatic Deobfuscation

  36. Our Approach - Automatic Deobfuscation We don’t care about reconstructing a disassembler ● Our goal: ●

  37. Our Approach - Automatic Deobfuscation We don’t care about reconstructing a disassembler ● Our goal: ● ○ Directly reconstruct a devirtualized binary from the obfuscated one

  38. Our Approach - Automatic Deobfuscation We don’t care about reconstructing a disassembler ● Our goal: ● ○ Directly reconstruct a devirtualized binary from the obfuscated one The crafted binary must have a control flow graph close to the original one ○

  39. Our Approach - Automatic Deobfuscation We don’t care about reconstructing a disassembler ● Our goal: ● ○ Directly reconstruct a devirtualized binary from the obfuscated one The crafted binary must have a control flow graph close to the original one ○ ○ The crafted binary must have instructions close to the original ones

  40. Our Approach - Automatic Deobfuscation Removed long secret(long x) { [transformations on x] Bytecodes return x; } FROM bool auth(long user_input) { long h = 0; VM(opcodes, &h, user_input); return (h == 0x9e3779b97f4a7c13); }

  41. Our Approach - Automatic Deobfuscation TO Obfuscated Traces

  42. Our Approach - Automatic Deobfuscation THEN FROM Simplified Traces

  43. Our Approach - Automatic Deobfuscation long secret_prime(long x) { [transformations on x] return x; } TO bool auth(long user_input) { long h = secret(user_input); return (h == 0x9e3779b97f4a7c13); }

Recommend


More recommend