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/shusing.text - repeat steps 2-4 until
/bin/shwritten&bss - overwrite got-entry of
strcpysystem(using offset, requires knowledge used version of libc - let's ignore here) - write
strcpy@plton stack, followed 4-byte chunk , address of&bsspoints/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
.textnot 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 characterstrcpyalways writes. 1 may callstrcpyonce 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