Re z3

From dslsdzc/rev-skills · View interactive version

Re z3 is an AI agent skill from the GitHub repository dslsdzc/rev-skills. Z3 约束求解:建模、密钥/flag 推导。触发词:z3、约束求解、solver、SMT

How to use this skill

Skill file

Z3 约束求解(建模 / 密钥与 flag 推导)

何时使用 / 何时不用

工具准备

参考 [[re-analyze/platform-tips]] 最高原则——求解本身不执行目标,但用求解结果运行目标验证时默认沙箱。

z3-solver(pip 安装)

python3

反编译产物(约束还原的原料)

操作步骤

按顺序执行,每步记录结果(约束清单 / 建模脚本 / 求解输出 / 验证结果,证据路径见 [[re-triage]])。

  1. 从反编译还原约束(比较链 / 数学关系):
  1. BitVec / Int 建模:

```python

from z3 import *

s = Solver()

inp = [BitVec(f'inp_{i}', 8) for i in range(8)] # 8 字节输入

```

  1. solver.check / model:
  1. 边界(长度 / 字符集)约束:

```python

for c in inp:

s.add(c >= 0x20, c <= 0x7e) # 可打印 ASCII(flag 场景)

s.add(inp[0] == ord('f')) # 已知格式头 flag{ 逐位固化

```

  1. 输出 flag / 密钥:

跨域联合

常见坑与陷阱

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.