executing-plans
executing-plans
Use when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available
re-whitebox白盒加密分析:白盒实现识别、密钥提取。 触发词:白盒、whitebox、白盒加密、密钥隐藏
Independent GitHub snapshot · Automated classification · Original documentation governs
静态为主(免沙箱);涉及"表加密运行时解密"时需动态取表(默认沙箱,[[re-analyze/platform-tips]] 最高原则)。所有工具先验证再使用。
pip install numpy)RE_DECOMPILER 会话变量pip install angrpython3 -c "import angr; print(angr.__version__)"按顺序执行,每步产物(表文件/脚本/恢复密钥)存档 sha256 + 路径,供报告引用([[re-ioc]])。
白盒实现识别(查找表特征、无标准库调用的大段查表代码):
# 静态侧: 找 .rodata/.data 里的查表候选——256 条 4/8 字节条目、连续、值分布均匀
objdump -h sample.bin | grep -E 'rodata|data'
# 反编译确认: 函数体是否"state 异或常量 → 查表 → 组合"结构、有无 Crypt* / OpenSSL 符号
Ctrl+Shift+F),看引用函数的形态——"查表 + 组合"而非"轮函数 + 常数表"即为白盒候选表提取:
getBytes 整段 dump);IDA: ida_bytes.get_bytes(start, size) 导出import struct
data = open('tables.bin','rb').read()
for off in range(0, len(data), 4): # 4 字节条目(AES T 表): 每条 [S(x)<<24 | ...]
v = struct.unpack_from('<I', data, off)[0]
# 记录值分布/每字节位模式,输出供步骤 3 分析
密钥恢复(表逆向 → 密钥推导,或已知明文攻击):
T0[x] 编码了 S(x) ^ k0(x 为输入字节),末轮表编码最后一轮密钥;编码层(仿射/字节映射)简单时直接反解 k0与标准实现对照(同一算法不同实现):
from Crypto.Cipher import AES # pip install pycryptodome
key = bytes.fromhex('<候选密钥>')
c = AES.new(key, AES.MODE_ECB)
print(c.encrypt(b'hello whitebox!!').hex())
# 与样本白盒实现对同一明文/密文的输出比对
报告(密钥/算法/影响):