首页
社区
课程
招聘
[原创]Writeup:第二题:巳时·绿光幽语
发表于: 2天前 66

[原创]Writeup:第二题:巳时·绿光幽语

2天前
66

题面大意:文件分段加密、硬件密钥碎片等叙事,实际考点是 运行时还原被 XOR 加密的函数字节码

解包后可见:

说明:真正逻辑不在 main.pyc

运行后在 %TEMP%\_MEI* 中检查提取文件,发现提示字符串与 my_function 出现在:

进一步用 Python 3.13 从 DLL 中 marshal.loads 提取 frozen 模块,确认挑战代码被注入到:

即:PyInstaller 引导阶段 import os 时,会执行写在 frozen os 模块末尾的挑战逻辑;main 随后直接退出。

挑战流程大致如下:

相关常量(摘录):

提示模板显示目标函数形如:

在 Python 3.13 中:

因此:

对密文做 XOR:

得到循环密钥流:

即 6 字节 key:

验证:用该 key 解密 enc_code / enc_consts 可分别还原合法字节码与 恭喜成功!

(若平台要求 flag{...} 包装,按赛方格式提交即可。)

关键技巧:PyInstaller + 魔改 frozen stdlib;业务逻辑可藏在 python3xx.dll 的 marshal 代码对象中,而不是入口 main.pyc

步骤 做法
解包 PyInstaller → 发现 main 为空壳
定位 运行时字符串落在 python313.dll / frozen os
分析 key 循环 XOR 还原 co_code + co_consts
求解 已知明文 XOR 直接得到 yb6tcr
pyinstxtractor-ng.exe .\题目.exe
import sys
sys.exit(0)
python313.dll
<frozen os>
enc_code = b'\xecbmucryb6tcr*c\x03ucryb6tCr\x1eb'          # 26 bytes
enc_consts = b'\x9f\xe3\x9b\x91\xf5\xee\x9f\xea\xa6\x91\xe9\xed\x96\xde\xb7'  # 15 bytes
def my_function():
    print("恭喜成功!")
known_code = bytes.fromhex('95005b0100000000000000005301350100000000000020006700')
known_consts = '恭喜成功!'.encode('utf-8')

ks_code = bytes(a ^ b for a, b in zip(enc_code, known_code))
ks_consts = bytes(a ^ b for a, b in zip(enc_consts, known_consts))
yb6tcryb6tcryb6t...
yb6tcr

冰与火的战歌:Windows内核攻防实战高级班!从零到实战,融合AI与Windows内核攻防全技术栈,打造具备自动化能力的内核开发高手。

收藏
免费 0
打赏
分享
最新回复 (0)
游客
登录 | 注册 方可回帖
返回