reverify README

The project's README from github.com/2akouwu/reverify. As one markdown file: README.md.

Reverify

Stop your AI from making things up.
It proposes; deterministic tools check every claim against ground truth, and only what's verified counts.

PyPI Python CI Coverage OpenSSF Scorecard MIT Stars

Build with Ona

AI is confident and often wrong: it invents an API, a struct field, an offset, or what a function does, and says it like fact. Reverify makes a deterministic tool the judge — the model proposes a claim, the tool checks it against the actual artifact, and it comes back VERIFIED / REFUTED with evidence. The model never gets to assert a fact on its own.

Two things it does today:

The hardest place to prove the first point is binary reverse engineering, where hallucination is worst — so that's where the numbers come from. On 71 real Windows system files the AI's textbook answer was wrong 97% of the time; reverify caught every one and never accepted a wrong claim (0 of 71; the same gate runs in CI on Linux and macOS every push, and an independent aarch64 run found the same) (EXAMPLE.md, BENCHMARK.md; python benchmarks/prologue_prior.py).

Reverify catches the model's hallucinated prologue on kernel32.dll, then verifies the corrected claim

The problem

Language models are great at reading code and unreliable at reverse engineering. Ask a model to reconstruct a struct or an algorithm from a binary and it will confidently invent offsets, sizes, and behavior. In binary analysis this hallucination problem is far worse than in source code, and "did the model just make that up?" is the single biggest blocker to using AI for real RE.

What Reverify does

Reverify pairs a language model with a deterministic, pure-Python RE toolkit and makes the toolkit the judge. The model proposes; the tools verify. A hypothesis about a structure or an algorithm is only reported once it has been checked against the actual bytes — disassembled, pattern-matched, or executed in the emulator — so the output is grounded in the binary instead of the model's imagination.

Reverify is for authorized reverse engineering — malware analysis, CTF, interoperability research, and software you own or are permitted to analyze. See SECURITY.md.

Quick start

# Install the CLI + MCP server from PyPI:
pip install reverify        # pure-Python core; or "reverify[full]" for capstone+unicorn+lief
reverify auto sample.bin --json

# Or run straight from a checkout — pure standard library, nothing to install:
python reverify/cli.py auto sample.bin --json
python reverify/cli.py parse-pe sample.exe --json
python reverify/cli.py disasm 90505831C0C3 --arch x86_64

The verification loop

This is what the name is about. A claim is any hypothesis about the binary; the deterministic tools are the judge and hand back VERIFIED, REFUTED, or INCONCLUSIVE together with the bytes they actually observed:

reverify verify sample.bin --claim '{
  "kind": "instructions", "offset": 4096,
  "mnemonics": ["push", "mov", "sub"], "note": "function prologue"
}'
# Check a reconstructed routine actually computes what the model claimed:
reverify verify - --claim '{
  "kind": "emulate_result", "code": "b805000000b90300000001c8c3",
  "arch": "x86", "expect_registers": {"eax": 8}
}'

Claims can be batched from a JSON file (--claims-file claims.json); the CLI exits non-zero if anything is refuted, so an agent or CI job can gate on a grounded reconstruction. Claim kinds: bytes_at, u16_at / u32_at / u64_at (typed reads, no endianness math), pattern_present, string_present, instructions (mnemonics and optionally operands), emulate_result, behavior_equiv, prove_equiv, protobuf_field, import_present, export_present, section_present, and the semantic kinds function_at, calls, references, reachable_from_entry (see The semantic layer). Offsets are file offsets unless a claim says "space": "rva" or "va"; the verifier translates through the section table and echoes all three addresses in the evidence, and a refuted bytes_at reports where the expected bytes actually are. Set "observe": true (or omit expected) to have the tools read a value instead of asserting one, and "depends_on": [...] so a refuted root invalidates the claims built on it.

Grounded means informative, not just "nothing refuted"

"Every claim verified" is trivially reachable: assert that the file starts with MZ and that .text exists. So Reverify also weighs how much a verified set actually says. Each result carries a weight — zero for claims that merely restate the fact sheet the model was shown, for duplicates, for inline code/data that does not occur in the binary (self-referential), and for echoes of the tools' own previous output; otherwise it is measured from the binary itself — how often the expected content occurs in this file and how much entropy it has — so zero padding, a ubiquitous prologue, or a pattern that matches everywhere weigh almost nothing even though they verify, and emulation must actually execute non-degenerate code. A reconstruction is grounded only when nothing is refuted and the verified weight reaches --min-information (default 1.0). This follows the CORE refinement of FActScore: credit only claims that are factual, informative and non-repetitive. reverify reconstruct --samples N draws several proposals per round and lets the verifier — not the model's confidence — select among them.

EXAMPLE.md walks through one run on kernel32.dll — the model proposes the textbook prologue from prior, the verifier refutes it with the real bytes, and the model corrects to grounded, with no API key and no specific model. BENCHMARK.md is the reproducible measurement behind the numbers above.

Evidence, not claims

Everything above is checkable without trusting the author:

The ledger: state that survives a context reset

Every agent harness handles a full context window the same way — a model summarizes the transcript, the rest is dropped, and the docs warn that repeated compactions degrade accuracy. That loss is unavoidable for free-form conversation, because nothing in a transcript says which parts were state and which were chatter.

Reverify's loop can do better for itself, because it already draws that line: the only things that matter are what the tools verified, observed, proved — and refuted. Everything else (the model's prose, its unverified guesses) was never trusted, so dropping it loses nothing. Since v0.8.0 exactly that state is written to disk as it happens:

reverify reconstruct target.exe --goal "..."   # resumes from .reverify/ automatically
reverify ledger target.exe                     # what is established, what is known false
reverify ledger --hook                         # Claude Code SessionStart hook (compact|clear|resume)

Over MCP the same happens with no setup: re_verify_claim records every grounded result, and re_ledger hands them back after the host compacts or clears its context (the server's instructions tell the agent to do so). Nothing unverified is ever stored — claim notes are excluded on purpose.

The loop that never fills up: fresh sessions with a verified hand-off

For a long task the ledger is not enough on its own — something has to decide when to drop the transcript and what the next context starts with. reverify orchestrate runs a goal as a sequence of fresh-context sessions and keeps the model in charge of the timing:

reverify orchestrate target.exe --goal "map the loader: entry, imports it really uses, exports" \
  --driver claude           # Claude Agent SDK on your Claude Code login; or openai (OPENAI_* env), or mock

A real run with the Claude Agent SDK driver on msimg32.dll (2 sessions × 4 turns, no API key): 15 grounded facts across the rollover — the real entry-point instructions, the machine type, header pointers read through typed observes — 2 guessed call-stub patterns refuted, 0 false accepts, and the second session started from the ledger, not from a summary (benchmarks/results/orchestrate-claude-msimg32-2026-09-04.json).

Any agent CLI without compaction: reverify rollover

The same rule applied to an interactive session — Claude Code, Codex CLI, Gemini CLI or OpenCode. Built-in compaction is turned off; the model hands off to files, and instead of a model-written summary the session is replaced wherever the CLI lets a hook do that (Gemini CLI, OpenCode) or a launcher owns the process. Where it does not (a plain claude or codex), reverify keeps the context lean rather than pretending to clear it: bulky tool output goes to files that stay re-readable, edits stay local, exploration goes to subagents, and the hand-off is always current. We are asking those vendors for the missing primitive.

pip install reverify
reverify rollover install          # every CLI found on PATH (or --harness claude,codex,gemini,opencode); backups kept
reverify rollover doctor           # what is wired, whether the hook commands still resolve, recent events

Then use your CLI exactly as before. The hooks do the hand-off; Gemini CLI and OpenCode also open the fresh session themselves. For Claude Code and Codex, or whenever you want the fresh session to open automatically, start the CLI through the launcher instead:

reverify rollover claude                    # same arguments as the CLI itself, e.g.
reverify rollover codex --full-auto
reverify rollover instructions --write AGENTS.md   # optional: the protocol paragraph for the model

Compare with a compactio

reverify (2akouwu/reverify)

Searching Database…

这是什么?Reverify 是一个防止 AI 智能体编造事实的工具:它用一套确定性工具把模型做出的每一条论断都对照真值加以验证,并以逆向工程作为主要的试验场。
这是独立应用,还是接入我的智能体用的东西?它同时以两种形式提供:一是 MCP 服务器,Claude Code、Cursor、Codex、Gemini CLI 等智能体可以直接调用;二是普通 CLI(reverify verify、reverify reconstruct 等),你可以自己运行。
怎么把它跑起来?把它作为 Python 包安装即可;纯 Python 核心开箱即用,无需额外配置,你可以直接运行 reverify verify,或把它作为 MCP 服务器接入你的智能体。
需要先安装 Ghidra 或其他逆向工程工具吗?不需要——确定性核心(PE/ELF/Mach-O 解析、反汇编、模式扫描、模拟执行)是纯 Python 实现,不需要 Ghidra;可选的额外组件(pip install reverify[full] 或 reverify[angr])会加入 capstone、unicorn、lief、Z3 和 angr,用于更高级的分析。
它真能抓住错误答案,还是只是走过场?真能——在 71 个真实的 Windows 系统文件上,AI 未经验证的教科书式答案有 97% 是错的,Reverify 抓出了其中每一个错误,而且从未接受过错误论断。它还会衡量一条已验证论断的信息量,因此恒真的琐碎论断不会被计入。
AI 的上下文被填满后,逆向工程会话会怎样?reverify rollover 不做有损的自动摘要,而是把会话交接给文件并开启全新上下文;持久化的账本保存已验证的事实,让下一个会话从同样的有据位置继续,不丢失已证实的状态。
它能验证二进制文件以外的东西吗?可以——reverify equiv 会让候选实现和参考实现在 Python 或 C 下跑相同的输入并检查结果是否一致,把同等的验证严谨性应用到普通的源码重写或重构上。
它会拒绝笼统地说一切正常吗?它会跟踪 VERIFIED、REFUTED、INCONCLUSIVE 三种结果,并要求最低的「信息权重」,这样「文件以 MZ 开头」这类显然为真的琐碎论断就不会被算作有意义的、有据的重构结论。
哪些编程智能体能配合 Reverify 使用?它可以在 Claude Code、Codex、Gemini CLI 和 OpenCode 中使用,并以 MCP 服务器的形式暴露自己,任何兼容 MCP 的智能体都能调用它的工具。
Creator
2akouwu
Size
0.6 MB
Stars
1.3K
Age
1mo
Commits · 90 Days