该技巧就是劫持栈指针到自己可以控制的内存,然后进行ROP,一般来说一下几种情形可以使用
- 栈溢出字节数较少,无法构造足够长的ROP链
- 程序开启了PIE保护,栈地址未知
- 将栈劫持到堆,利用堆漏洞
例 boverflow
分析
检查保护
qts@qts-PC:~/奇幻世界/杂题/xctf2016-qual-boverflow$ ./checksec.sh --file boverflow
RELRO STACK CANARY NX PIE RPATH RUNPATH FILE
Partial RELRO No canary found NX disabled Not an ELF file No RPATH No RUNPATH boverflow
溢出空间 0x32-0x20-4 =14字节
.text:0804851B s = byte ptr -20h
.text:08048551 mov eax, ds:stdout@@GLIBC_2_0
.text:08048556 mov [esp], eax ; stream
.text:08048559 call _fflush
.text:0804855E mov eax, ds:stdin@@GLIBC_2_0
.text:08048563 mov [esp+8], eax ; stream
.text:08048567 mov dword ptr [esp+4], 32h ; n
.t