要点:通过read()的溢出构造rop链,获得write()函数的真实地址,再利用libc的偏移算出system和“/bin/sh”的地址,再次利用write()溢出,执行system,就能得到shell。
level3.rar.2047525b05c499c9dd189ba212bba1f8
首先查看一下开启了哪些保护:
开启了NX,栈上不能执行shellcode。
然后用IDA查看一下代码:
main:
.text:08048484 ; =============== S U B R O U T I N E =======================================
.text:08048484
.text:08048484 ; Attributes: bp-based frame
.text:08048484
.text:08048484 ; int __cdecl main(int argc, const char **argv, const char **envp)
.text:08048484 public main
.text:08048484 main proc near ; DATA XREF: _start+17↑o
.text:08048484
.text:08048484 var_4 = dword ptr -4
.text:08048484 argc = dword ptr 8
.text:08048484 argv = dword ptr 0Ch
.text:08048484 envp = dword ptr 10h
.text:08048484
.text:08048484 ; __unwind {
.text:08048484 lea ecx, [esp+4]
.text:08048488 and esp, 0FFFFFFF0h
.text:0804848B push dword ptr [ecx-4]