d eprotection semi automatique de binaire
play

D eprotection semi-automatique de binaire avec Metasm : celui qui - PowerPoint PPT Presentation

Metasm Manipulation structurelle Challenge T2 2007 Conclusion D eprotection semi-automatique de binaire avec Metasm : celui qui fond dans la bouche et pas dans la main. Alexandre Gazet Yoann Guillot A. Gazet & Y. Guillot D


  1. Metasm Manipulation structurelle Challenge T2 2007 Conclusion D´ eprotection semi-automatique de binaire avec Metasm : celui qui fond dans la bouche et pas dans la main. Alexandre Gazet Yoann Guillot A. Gazet & Y. Guillot D´ eprotection semi-automatique de binaire 1/49

  2. Metasm Manipulation structurelle Challenge T2 2007 Conclusion Plan Metasm 1 Manipulation structurelle 2 Challenge T2 2007 3 Conclusion 4 A. Gazet & Y. Guillot D´ eprotection semi-automatique de binaire 2/49

  3. Metasm Les d´ esassembleurs classiques Manipulation structurelle Binding Challenge T2 2007 Backtracing Conclusion Plan Metasm 1 Les d´ esassembleurs classiques Binding Backtracing Manipulation structurelle 2 Challenge T2 2007 3 Conclusion 4 A. Gazet & Y. Guillot D´ eprotection semi-automatique de binaire 3/49

  4. Metasm Les d´ esassembleurs classiques Manipulation structurelle Binding Challenge T2 2007 Backtracing Conclusion Metasm A. Gazet & Y. Guillot D´ eprotection semi-automatique de binaire 4/49

  5. Metasm Les d´ esassembleurs classiques Manipulation structurelle Binding Challenge T2 2007 Backtracing Conclusion Metasm A. Gazet & Y. Guillot D´ eprotection semi-automatique de binaire 5/49

  6. Metasm Les d´ esassembleurs classiques Manipulation structurelle Binding Challenge T2 2007 Backtracing Conclusion D´ esassemblage La r´ ef´ erence : IDA Pro Excellent sur du code clair : binaire MS Inadapt´ e sur un binaire prot´ eg´ e Pas d’interpr´ etation du code Des hypoth` eses trop contraignantes Des hypoth` eses Les deux branches d’un saut conditionnel sont ex´ ecut´ ees Deux instructions ne se superposent pas Un appel retourne A. Gazet & Y. Guillot D´ eprotection semi-automatique de binaire 6/49

  7. Metasm Les d´ esassembleurs classiques Manipulation structurelle Binding Challenge T2 2007 Backtracing Conclusion D´ esassemblage La r´ ef´ erence : IDA Pro Excellent sur du code clair : binaire MS Inadapt´ e sur un binaire prot´ eg´ e Pas d’interpr´ etation du code Des hypoth` eses trop contraignantes Des hypoth` eses Les deux branches d’un saut conditionnel sont ex´ ecut´ ees Deux instructions ne se superposent pas Un appel retourne A. Gazet & Y. Guillot D´ eprotection semi-automatique de binaire 6/49

  8. Metasm Les d´ esassembleurs classiques Manipulation structurelle Binding Challenge T2 2007 Backtracing Conclusion Hypoth` ese : un appel retourne . t e x t :00403 E9F loc 403E9F : ; CODE XREF: .text : loc_40CDEF . t e x t :00403 E9F push ebp . t e x t :00403 EA0 push ecx . t e x t :00403 EA1 push ebp . t e x t :00403 EA2 c a l l sub 40BECD . t e x t :00403 EA7 outsb . t e x t :00403 EA8 cmp edx , esp . t e x t :00403 EAA push esp . t e x t :00403 EAB i n c e s i A. Gazet & Y. Guillot D´ eprotection semi-automatique de binaire 7/49

  9. Metasm Les d´ esassembleurs classiques Manipulation structurelle Binding Challenge T2 2007 Backtracing Conclusion Mise en ´ echec . t e x t :0040 BECD sub 40BECD proc near ; CODE XREF: .text :00403EA2 . t e x t :0040 BECD cmp eax , ebp . t e x t :0040 BECF add dword ptr [ esp +0] , 1 . t e x t :0040 BED4 te s t ebx , 1 E2h . t e x t :0040 BEDA retn 0 Ch . t e x t :0040 BEDA sub 40BECD endp A. Gazet & Y. Guillot D´ eprotection semi-automatique de binaire 8/49

  10. Metasm Les d´ esassembleurs classiques Manipulation structurelle Binding Challenge T2 2007 Backtracing Conclusion Binding D´ efinition Expression symbolique des effets d’une instruction; ` a chaque instruction est associ´ ee sa s´ emantique. Instruction ADD : a = d i . i n s t r u c t i o n . args . map r e s = Expression [ [ a [ 0 ] , :& , mask ] , :+ , [ a [ 1 ] , :& , mask ] ] binding [ : e f l a g z ] = Expression [ [ res , :& , mask ] , :==, 0] binding [ : e f l a g s ] = s i g n [ r e s ] binding [ : e f l a g c ] = Expression [ res , : > , mask ] binding [ : e f l a g o ] = Expression [ [ s i g n [ a [ 0 ] ] , :==, s i g n [ a [ 1 ] ] ] , : ’&&’ , [ s i g n [ a [ 0 ] ] , : ’!=’ , s i g n [ r e s ] ] ] binding [ i n s t r ] = { a [ 0 ] = > r e s } A. Gazet & Y. Guillot D´ eprotection semi-automatique de binaire 9/49

  11. Metasm Les d´ esassembleurs classiques Manipulation structurelle Binding Challenge T2 2007 Backtracing Conclusion Binding Instruction CALL : addrReturn = Expression [ Expression [ d i . address , :+ , d i . b i n l e n g th ] . reduce ] } binding = { : esp = > Expression [ : esp , : − , opsz ] , I n d i r e c t i o n [ : esp , opsz , d i . address ] = > addrReturn } En pratique : dword ptr [ esp ] = 0 x4010CE esp = esp − 4 Instruction RDTSC : binding = { : eax = > Expression : : Unknown , : edx = > Expression : : Unknown } A. Gazet & Y. Guillot D´ eprotection semi-automatique de binaire 10/49

  12. Metasm Les d´ esassembleurs classiques Manipulation structurelle Binding Challenge T2 2007 Backtracing Conclusion Binding Instruction CALL : addrReturn = Expression [ Expression [ d i . address , :+ , d i . b i n l e n g th ] . reduce ] } binding = { : esp = > Expression [ : esp , : − , opsz ] , I n d i r e c t i o n [ : esp , opsz , d i . address ] = > addrReturn } En pratique : dword ptr [ esp ] = 0 x4010CE esp = esp − 4 Instruction RDTSC : binding = { : eax = > Expression : : Unknown , : edx = > Expression : : Unknown } A. Gazet & Y. Guillot D´ eprotection semi-automatique de binaire 10/49

  13. Metasm Les d´ esassembleurs classiques Manipulation structurelle Binding Challenge T2 2007 Backtracing Conclusion Binding Instruction CALL : addrReturn = Expression [ Expression [ d i . address , :+ , d i . b i n l e n g th ] . reduce ] } binding = { : esp = > Expression [ : esp , : − , opsz ] , I n d i r e c t i o n [ : esp , opsz , d i . address ] = > addrReturn } En pratique : dword ptr [ esp ] = 0 x4010CE esp = esp − 4 Instruction RDTSC : binding = { : eax = > Expression : : Unknown , : edx = > Expression : : Unknown } A. Gazet & Y. Guillot D´ eprotection semi-automatique de binaire 10/49

  14. Metasm Les d´ esassembleurs classiques Manipulation structurelle Binding Challenge T2 2007 Backtracing Conclusion Backtracing, la th´ eorie D´ efinition ´ Emulation symbolique par remont´ ee du flot d’instructions. A. Gazet & Y. Guillot D´ eprotection semi-automatique de binaire 11/49

  15. Metasm Les d´ esassembleurs classiques Manipulation structurelle Binding Challenge T2 2007 Backtracing Conclusion Backtracing, la pratique Flot d’ex´ ecution : c a l l loc 40becdh ; @403ea2h e826800000 cmp eax , ebp ; @40becdh 39e8 add dword ptr [ esp +0] , 1 ; @40becfh 8344240001 te s t ebx , 1 e2h ; @40bed4h f7c3e2010000 r e t 0 ch ; @40bedah c20c00 Backtracing x dword ptr [esp] for 40bedah ret 0ch backtrace 40becfh add dword ptr [esp+0], 1 1 dword ptr [esp] => dword ptr [esp]+1 backtrace up 40becdh->403ea2h dword ptr [esp]+1 2 backtrace 403ea2h call loc 40becdh 3 dword ptr [esp]+1 ⇒ 403ea8h backtrace result : 403ea8h 4 A. Gazet & Y. Guillot D´ eprotection semi-automatique de binaire 12/49

  16. Metasm Les d´ esassembleurs classiques Manipulation structurelle Binding Challenge T2 2007 Backtracing Conclusion Metasm Listing produit : loc 403e9fh : push ebp ; @403e9fh 55 push ecx ; @403ea0h 51 push ebp ; @403ea1h 55 c a l l loc 40becdh ; @403ea2h e826800000 noreturn db 6 eh ; @403ea7h // Xrefs : 40 bedah loc 403ea8h : cmp edx , esp ; @403ea8h 39e2 push esp ; @403eaah 54 [ . . . ] − − − − − − − − − − − − − − − − − − − − − − − − // Xrefs : 403 ea2h loc 40becdh : cmp eax , ebp ; @40becdh 39e8 add dword ptr [ esp +0] , 1 ; @40becfh 8344240001 te s t ebx , 1 e2h ; @40bed4h f7c3e2010000 r e t 0 ch ; @40bedah c20c00 x: loc_403ea8h A. Gazet & Y. Guillot D´ eprotection semi-automatique de binaire 13/49

  17. Metasm Pr´ esentation Manipulation structurelle Complexification du graphe de contrˆ ole Challenge T2 2007 Insertion d’´ el´ ements neutres Conclusion D´ eprotection Plan Metasm 1 Manipulation structurelle 2 Pr´ esentation Complexification du graphe de contrˆ ole Insertion d’´ el´ ements neutres D´ eprotection Challenge T2 2007 3 Conclusion 4 A. Gazet & Y. Guillot D´ eprotection semi-automatique de binaire 14/49

  18. Metasm Pr´ esentation Manipulation structurelle Complexification du graphe de contrˆ ole Challenge T2 2007 Insertion d’´ el´ ements neutres Conclusion D´ eprotection Securitech 2006 - Challenge 10 Poeut.exe Binaire massivement obfusqu´ e IDA d´ epass´ e Metasm d´ esassemble parfaitement mais : Reordonnancement des blocs d’instructions ⇒ n´ ecessit´ e de d´ evelopper un front-end graphique yEd - Graph Editor Visualisation de graphes Utilise un fichier graphml Objets internes de Metasm les InstructionBlock A. Gazet & Y. Guillot D´ eprotection semi-automatique de binaire 15/49

  19. Metasm Pr´ esentation Manipulation structurelle Complexification du graphe de contrˆ ole Challenge T2 2007 Insertion d’´ el´ ements neutres Conclusion D´ eprotection Graphe sauvage A. Gazet & Y. Guillot D´ eprotection semi-automatique de binaire 16/49

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend