SlideShare a Scribd company logo
On deobfuscation
   in practice
    Vasily Bukasov
   Dmitry Schelkunov
Obfuscation applications
• Software protection against
  computer piracy

• Malware protection against
  automatic detection and to
  impede analysis of a
  malicious code
Obfuscators and protectors
• Manual obfuscation requires a lot
  of resources

• It’s much easier to use
  obfuscators and protectors which
  promise a strong obfuscation
Common code protection
     techniques
• Code encryption (out of
  scope of our report)
• Code virtualization
• Code morphing
Code virtualization
• Converts a source assembler
  code to the specially generated
  byte-code
• Inserts byte-code and byte-
  code interpreter into the source
  PE file
Code virtualization
 Byte-code mostly represents
original assembler instructions
 so its execution has the same
  effect as from the original
          instructions
Code virtualization
                   Get instruction byte-code

Byte-code
              Get instruction arguments from VM
 fetching      context or from another location
   loop
                      Process instruction

              Save result into VM context or into
                       another location
VM context

• Contains variables associated
  with processor registers
• Contains VM state
• Its location can be easily found in
  most cases
VM context location
• Dynamically allocated memory
  (VirtualAlloc, HeapAlloc)
• Global memory (access via
  spinlock)
• Stack
VM stack context layout
                      0
    Not initialized
     VM context       rSP

    Reserved area

    Stack of the
   protected code
«Virtualized» addition
void unoptimal_addition( int a, int b, int *p )
{
    int u, v, t, *r;


    u = a;
    v = b;
    r = p;


    t = u + v;
    *r = t;
}
Virtualized code execution
   Getting byte-code
Loading from VM context   This code is
  Instruction execution   asking to be
 Saving to VM context
   Getting byte-code
                          optimized 
Loading from VM context
  Instruction execution
 Saving to VM context
         etc…
Code devirtualization
• We can locate VM context
• We can get CFG in most cases
• We can use common code
  optimization algorithms to
  deobfuscate a virtualized code
Code morphing
• Used to increase resistance to
  the static analysis
• Used for the CFG obfuscation
• Used to increase VM body
  analyzing complexity
Code morphing and CFG
       obfuscation
It’s a difficult task to decompile
a machine code

Therefore protectors don’t even
try to do it 
Code morphing and CFG
       obfuscation
Data dependencies analysis is
weak in protectors


Therefore they are limited in
choice of obfuscation techniques
Code morphing common
      techniques
              Recursive templates
                 Template      Template
                 Instruction
                 Instruction   Template
Instruction
                     …
                 Instruction
                               Template
Code morphing common
         techniques
• Dead code insertion
• Garbage code insertion
• Opaque predicates
• Jump address calculation
• Code cloning
Morphed code deobfuscation

• Decompilation into IR
• IR instruction emulation
• Collecting variables values
• Emulation-based deobfuscation
  techniques
Ariadne engine
• An engine for RE
• Can be used as IDA plugin
• Enables PE format analyzing,
  disassembling and modifying
• Supports GP, FPU, MMX, SSE,
  SSE2, SSE3, SSSE3, SSE4.1,
  SSE4.2, SSE4a, VMX, SMX
Ariadne engine
• Supports assembler instructions
  translation into Ariadne
  Intermediate Representation
  (AIR)
• Supports IR instructions
  emulation
• Contains emulator-based code
  tracing mechanisms
Ariadne engine

• Contains built-in trace
  deobfuscation (AIR Wave
  Deobfuscation Technology)
AIR Wave Deobfuscation
       Technology
• Static deobfuscation
 –based on the classical compiler
  theory approaches
 –doesn’t use emulation
AIR Wave Deobfuscation
       Technology
• Dynamic deobfuscation
 –uses Ariadne IR emulator
 –calculates values of variables
 –determines in a lot of cases where a
  pointer points to
 –used for dereferenced pointers
  deobfuscation
AIR Wave Deobfuscation
      Technology
• Deobfuscation techniques
 –dead code elimination
 –variables propagation
 –constant folding
 –math simplifications
AIR Wave Deobfuscation
      Technology
• Deobfuscation techniques
 –loop unrolling
 –common subexpression
  elimination
 –pointer analysis and alias
  classification
Our results
• Many obfuscators/protectors
  provide a weak obfuscation
• Ariadne engine can be
  effectively used for
  deobfuscation
AIR Wave Deobfuscation
       Technology
Tested on …

See it for yourself 
And our thanks go…
• To Rolf Rolles for his works
  about virtualization
  obfuscation unpacking
• To Leta Group for Ariadne
  sponsorship
Ariadne engine
http://ariadne.group-ib.ru

More Related Content

PPS
On deobfuscation in practice
PDF
Deobfuscation and beyond (ZeroNights, 2014)
PPTX
JVM: A Platform for Multiple Languages
PPTX
Dependency injection
PDF
Smashing the stack with Hydra
PDF
XS Boston 2008 Paravirt Ops in Linux IA64
PPT
The Ongoing Democratization of Robotics Development
KEY
Building a Wireless Mesh Network Temperature Sensor
On deobfuscation in practice
Deobfuscation and beyond (ZeroNights, 2014)
JVM: A Platform for Multiple Languages
Dependency injection
Smashing the stack with Hydra
XS Boston 2008 Paravirt Ops in Linux IA64
The Ongoing Democratization of Robotics Development
Building a Wireless Mesh Network Temperature Sensor

Similar to Dmitry Schelkunov, Vasily Bukasov - About practical deobfuscation (20)

PDF
UVM TUTORIAL;
PDF
Hypervisors
PDF
stackconf 2020 | Replace your Docker based Containers with Cri-o Kata Contain...
PDF
OSGi Community Event 2010 - OSGi Technical Update
PPTX
Emulation-based SW protection
PPTX
Server virtualization
PDF
Invoke dynamic your api to hotspot
PPTX
Search for Vulnerabilities Using Static Code Analysis
ODP
Native client (Евгений Эльцин)
PDF
Stealing from Thieves: Breaking IonCUBE VM to RE Exploit Kits
PPT
Lec1 final
PPTX
Advanced Malware Analysis Training Session 2 - Botnet Analysis Part 1
PDF
Server Side JavaScript on the Java Platform - David Delabassee
PDF
Kernel Mode Threats and Practical Defenses
PDF
/* pOrt80BKK */ - PHP Day - PHP Performance with APC + Memcached for Windows
PDF
Getting started with RISC-V verification what's next after compliance testing
PPT
B-Sides Seattle 2012 Offensive Defense
PPTX
Reverse Engineering Malware - A Practical Guide
PDF
Typhoon Managed Execution Toolkit
UVM TUTORIAL;
Hypervisors
stackconf 2020 | Replace your Docker based Containers with Cri-o Kata Contain...
OSGi Community Event 2010 - OSGi Technical Update
Emulation-based SW protection
Server virtualization
Invoke dynamic your api to hotspot
Search for Vulnerabilities Using Static Code Analysis
Native client (Евгений Эльцин)
Stealing from Thieves: Breaking IonCUBE VM to RE Exploit Kits
Lec1 final
Advanced Malware Analysis Training Session 2 - Botnet Analysis Part 1
Server Side JavaScript on the Java Platform - David Delabassee
Kernel Mode Threats and Practical Defenses
/* pOrt80BKK */ - PHP Day - PHP Performance with APC + Memcached for Windows
Getting started with RISC-V verification what's next after compliance testing
B-Sides Seattle 2012 Offensive Defense
Reverse Engineering Malware - A Practical Guide
Typhoon Managed Execution Toolkit
Ad

More from DefconRussia (20)

PPTX
[Defcon Russia #29] Борис Савков - Bare-metal programming на примере Raspber...
PDF
[Defcon Russia #29] Александр Ермолов - Safeguarding rootkits: Intel Boot Gua...
PPTX
[Defcon Russia #29] Алексей Тюрин - Spring autobinding
PDF
[Defcon Russia #29] Михаил Клементьев - Обнаружение руткитов в GNU/Linux
PDF
Георгий Зайцев - Reversing golang
PDF
[DCG 25] Александр Большев - Never Trust Your Inputs or How To Fool an ADC
PPTX
Cisco IOS shellcode: All-in-one
PPT
Олег Купреев - Обзор и демонстрация нюансов и трюков из области беспроводных ...
PPTX
HTTP HOST header attacks
PPTX
Attacks on tacacs - Алексей Тюрин
PPTX
Weakpass - defcon russia 23
PDF
nosymbols - defcon russia 20
PDF
static - defcon russia 20
PDF
Zn task - defcon russia 20
PDF
Vm ware fuzzing - defcon russia 20
PDF
Nedospasov defcon russia 23
PDF
Advanced cfg bypass on adobe flash player 18 defcon russia 23
PDF
Miasm defcon russia 23
PDF
Andrey Belenko, Alexey Troshichev - Внутреннее устройство и безопасность iClo...
PDF
Sergey Belov - Покажите нам Impact! Доказываем угрозу в сложных условиях
[Defcon Russia #29] Борис Савков - Bare-metal programming на примере Raspber...
[Defcon Russia #29] Александр Ермолов - Safeguarding rootkits: Intel Boot Gua...
[Defcon Russia #29] Алексей Тюрин - Spring autobinding
[Defcon Russia #29] Михаил Клементьев - Обнаружение руткитов в GNU/Linux
Георгий Зайцев - Reversing golang
[DCG 25] Александр Большев - Never Trust Your Inputs or How To Fool an ADC
Cisco IOS shellcode: All-in-one
Олег Купреев - Обзор и демонстрация нюансов и трюков из области беспроводных ...
HTTP HOST header attacks
Attacks on tacacs - Алексей Тюрин
Weakpass - defcon russia 23
nosymbols - defcon russia 20
static - defcon russia 20
Zn task - defcon russia 20
Vm ware fuzzing - defcon russia 20
Nedospasov defcon russia 23
Advanced cfg bypass on adobe flash player 18 defcon russia 23
Miasm defcon russia 23
Andrey Belenko, Alexey Troshichev - Внутреннее устройство и безопасность iClo...
Sergey Belov - Покажите нам Impact! Доказываем угрозу в сложных условиях
Ad

Recently uploaded (20)

PDF
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PPTX
observCloud-Native Containerability and monitoring.pptx
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPT
Module 1.ppt Iot fundamentals and Architecture
PPTX
Tartificialntelligence_presentation.pptx
PDF
Zenith AI: Advanced Artificial Intelligence
PDF
Hybrid model detection and classification of lung cancer
PDF
Enhancing emotion recognition model for a student engagement use case through...
PDF
STKI Israel Market Study 2025 version august
PDF
Developing a website for English-speaking practice to English as a foreign la...
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PPT
What is a Computer? Input Devices /output devices
PPTX
Final SEM Unit 1 for mit wpu at pune .pptx
PPTX
O2C Customer Invoices to Receipt V15A.pptx
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PDF
Getting started with AI Agents and Multi-Agent Systems
PDF
WOOl fibre morphology and structure.pdf for textiles
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
observCloud-Native Containerability and monitoring.pptx
NewMind AI Weekly Chronicles - August'25-Week II
Module 1.ppt Iot fundamentals and Architecture
Tartificialntelligence_presentation.pptx
Zenith AI: Advanced Artificial Intelligence
Hybrid model detection and classification of lung cancer
Enhancing emotion recognition model for a student engagement use case through...
STKI Israel Market Study 2025 version august
Developing a website for English-speaking practice to English as a foreign la...
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
What is a Computer? Input Devices /output devices
Final SEM Unit 1 for mit wpu at pune .pptx
O2C Customer Invoices to Receipt V15A.pptx
Univ-Connecticut-ChatGPT-Presentaion.pdf
Getting started with AI Agents and Multi-Agent Systems
WOOl fibre morphology and structure.pdf for textiles

Dmitry Schelkunov, Vasily Bukasov - About practical deobfuscation

  • 1. On deobfuscation in practice Vasily Bukasov Dmitry Schelkunov
  • 2. Obfuscation applications • Software protection against computer piracy • Malware protection against automatic detection and to impede analysis of a malicious code
  • 3. Obfuscators and protectors • Manual obfuscation requires a lot of resources • It’s much easier to use obfuscators and protectors which promise a strong obfuscation
  • 4. Common code protection techniques • Code encryption (out of scope of our report) • Code virtualization • Code morphing
  • 5. Code virtualization • Converts a source assembler code to the specially generated byte-code • Inserts byte-code and byte- code interpreter into the source PE file
  • 6. Code virtualization Byte-code mostly represents original assembler instructions so its execution has the same effect as from the original instructions
  • 7. Code virtualization Get instruction byte-code Byte-code Get instruction arguments from VM fetching context or from another location loop Process instruction Save result into VM context or into another location
  • 8. VM context • Contains variables associated with processor registers • Contains VM state • Its location can be easily found in most cases
  • 9. VM context location • Dynamically allocated memory (VirtualAlloc, HeapAlloc) • Global memory (access via spinlock) • Stack
  • 10. VM stack context layout 0 Not initialized VM context rSP Reserved area Stack of the protected code
  • 11. «Virtualized» addition void unoptimal_addition( int a, int b, int *p ) { int u, v, t, *r; u = a; v = b; r = p; t = u + v; *r = t; }
  • 12. Virtualized code execution Getting byte-code Loading from VM context This code is Instruction execution asking to be Saving to VM context Getting byte-code optimized  Loading from VM context Instruction execution Saving to VM context etc…
  • 13. Code devirtualization • We can locate VM context • We can get CFG in most cases • We can use common code optimization algorithms to deobfuscate a virtualized code
  • 14. Code morphing • Used to increase resistance to the static analysis • Used for the CFG obfuscation • Used to increase VM body analyzing complexity
  • 15. Code morphing and CFG obfuscation It’s a difficult task to decompile a machine code Therefore protectors don’t even try to do it 
  • 16. Code morphing and CFG obfuscation Data dependencies analysis is weak in protectors Therefore they are limited in choice of obfuscation techniques
  • 17. Code morphing common techniques Recursive templates Template Template Instruction Instruction Template Instruction … Instruction Template
  • 18. Code morphing common techniques • Dead code insertion • Garbage code insertion • Opaque predicates • Jump address calculation • Code cloning
  • 19. Morphed code deobfuscation • Decompilation into IR • IR instruction emulation • Collecting variables values • Emulation-based deobfuscation techniques
  • 20. Ariadne engine • An engine for RE • Can be used as IDA plugin • Enables PE format analyzing, disassembling and modifying • Supports GP, FPU, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, SSE4a, VMX, SMX
  • 21. Ariadne engine • Supports assembler instructions translation into Ariadne Intermediate Representation (AIR) • Supports IR instructions emulation • Contains emulator-based code tracing mechanisms
  • 22. Ariadne engine • Contains built-in trace deobfuscation (AIR Wave Deobfuscation Technology)
  • 23. AIR Wave Deobfuscation Technology • Static deobfuscation –based on the classical compiler theory approaches –doesn’t use emulation
  • 24. AIR Wave Deobfuscation Technology • Dynamic deobfuscation –uses Ariadne IR emulator –calculates values of variables –determines in a lot of cases where a pointer points to –used for dereferenced pointers deobfuscation
  • 25. AIR Wave Deobfuscation Technology • Deobfuscation techniques –dead code elimination –variables propagation –constant folding –math simplifications
  • 26. AIR Wave Deobfuscation Technology • Deobfuscation techniques –loop unrolling –common subexpression elimination –pointer analysis and alias classification
  • 27. Our results • Many obfuscators/protectors provide a weak obfuscation • Ariadne engine can be effectively used for deobfuscation
  • 28. AIR Wave Deobfuscation Technology Tested on … See it for yourself 
  • 29. And our thanks go… • To Rolf Rolles for his works about virtualization obfuscation unpacking • To Leta Group for Ariadne sponsorship