consider following vulnerable code/program:
#include <string.h> int main(int argc, char *argv[]) { char buf[16]; strcpy(buf, argv[1]); return 0; }
on ia-32 (x86, 32-bit) running linux nx , aslr enabled, exploit using got-overwrite technique, includes following steps:
- overflow buffer till rip
- overwrite rip address of
strcpy@plt
- use clean gadget
.text
, e.g.pop edi ; pop ebp ; ret
, return addressstrcpy
- write arguments
strcpy
:&bss
-address destination , 1 byte of/bin/sh
using.text
- repeat steps 2-4 until
/bin/sh
written&bss
- overwrite got-entry of
strcpy
system
(using offset, requires knowledge used version of libc - let's ignore here) - write
strcpy@plt
on stack, followed 4-byte chunk , address of&bss
points/bin/sh
- profit
i want exploit on x86-64 same mitigation measures enabled. more difficult imagined. following reasons:
- x86-64 register-based calling convention: function arguments passed using registers, not stack. therefore additional rop-gadgets required transfer arguments stack appropriate register. minor problem, affected following problem:
64-bit return address: rip in x86-64 points
.text
not 32-bit long. therefore null-bytes must written on stack chain function calls. 1 can write null-bytes desired using chained callsstrcpy
, taking advantage of null-terminating characterstrcpy
always writes. 1 may callstrcpy
once overwriting least significant bytes of rip.|0x00000000| (most significant bytes) |0x00deadbe| <- rip (least significant bytes) |0x41414141| |0x41414141| <- sfp | ... |
these major problems got exploiting program on x86-64 nx , aslr enabled. there techniques solve these problems? or x86-64 prevent working, shell-opening exploit?
x86-64 not prevent these type of exploits. see tutorial.
Comments
Post a Comment