* feat(plugin): add reverse-engineering plugin v0.4.0 + project-level codegraph
Bundles a multi-platform RE toolkit as a local marketplace plugin that
clone-and-enable installs in cc-haha desktop. Covers static (Ghidra,
radare2, JADX, apktool, binwalk via Bash) and the gap a previous review
called out: dynamic debugging is the lane that matters most for
AI-driven RE, but Frida alone cannot single-step or set real
breakpoints. This commit fills that gap with three non-overlapping
dynamic lanes -- Frida (instrumentation, mobile, broad surveys), GDB
(cross-arch single-step + breakpoints, embedded firmware), LLDB (Apple
platforms, ObjC/Swift).
Architecture coverage spans MIPS / ARM (incl. Cortex-M Thumb) /
PowerPC (incl. e200 VLE) / 68k (incl. Mac Toolbox A-line traps) /
SuperH / RISC-V / x86-64 / AArch64. The agent picks the right ISA,
base address, and load configuration in skills/firmware-blob, then
hands off to skills/pe-elf-macho with per-architecture decompilation
notes (MIPS delay slots, ARM Thumb interworking, PowerPC TOC/SDA,
68k register banks, etc).
Plugin layout (.claude-plugin marketplace + plugin manifests):
plugins/.claude-plugin/marketplace.json
plugins/reverse-engineering/
.claude-plugin/plugin.json v0.4.0, GHIDRA_INSTALL_DIR + ARTIFACT_DIR userConfig
agents/reverse-engineer.md triage -> static -> optional dynamic -> report
skills/triage/ file-type identification, packing, routing
skills/pe-elf-macho/ Ghidra/r2 + per-arch notes for non-x86
skills/firmware-blob/ raw blob -> ISA + base address + Ghidra/r2 load config
skills/apk-analysis/ JADX + apktool, Android attack surface
skills/ios-analysis/ IPA bundle + Mach-O, FairPlay-aware
skills/dynamic-debug-overview/ decision matrix Frida vs GDB vs LLDB
skills/frida-dynamic/ hooks + Memory + CpuContext + Stalker + watchpoints
skills/gdb-debug/ cross-arch via gdbserver / qemu-user / qemu-system
skills/lldb-debug/ macOS / iOS device / Linux, ObjC/Swift symbols
skills/crackme-keygen/ CTF / self-owned binary; ships keygen, not patch
skills/re-report/ final structured report with IOCs + confidence
commands/triage.md /reverse-engineering:triage <path>
commands/report.md /reverse-engineering:report <sample-id>
mcp/servers.json 7 MCP servers: ghidra (pyghidra-mcp PyPI),
radare2 (npm), gdb (mcp-gdb npm), lldb
(stass/lldb-mcp git), jadx, apktool, frida
(kahlo-mcp git, all @main pinned)
hooks/hooks.json empty placeholder
scripts/validate.ts offline schema check via project's
validatePluginManifest + validatePluginContents
scripts/dev-link.ts Windows mklink /J cache -> repo source so SKILL
edits don't require version bump (--restore undoes)
scripts/smoke.ts end-to-end: marketplace register -> enable ->
update -> reload -> assert detail counts.
Counts derived from on-disk source (glob),
not hardcoded; idempotent across reruns.
README.md install, prerequisites per MCP, dynamic-capabilities
matrix, architecture coverage, quickstart with
busybox sample, dev-link / smoke workflows
Project-level MCP (clone-and-go for any contributor):
.mcp.json codegraph (npx -y codegraph serve --mcp);
project scope, picked up automatically.
Pre-existing user-level codegraph install
still wins for users who have one.
userConfig of the plugin is honest -- only knobs that actually do
something (GHIDRA_INSTALL_DIR substituted into the ghidra MCP env;
ARTIFACT_DIR resolved relative to agent cwd at run time). Earlier
ENABLE_* booleans were removed because they didn't actually toggle
anything; users disable individual MCP servers from Settings -> MCP
at runtime.
End-to-end verification (server on :3456, vite on :1420):
- bun run plugins/reverse-engineering/scripts/validate.ts
-> 0 fail / 0 warn (marketplace + plugin schema both clean)
- bun run plugins/reverse-engineering/scripts/smoke.ts
-> 13 passed / 0 failed (marketplace registration, enable, update
0.3.0->0.4.0, reload, detail assertions including 11 skill ids
matching the on-disk glob)
- GET /api/plugins/detail
-> commands=2 / agents=1 / skills=11 / mcpServers=7 / errors=[]
- GET /api/mcp
-> codegraph appears with scope=project,
configLocation=.mcp.json
- Desktop UI Settings -> Plugins
-> v0.4.0 listed in enabled group, "11 skills 1 Agent 7 MCP"
External tool prerequisites (each MCP needs its underlying tool on
PATH; users install per-MCP independently -- none required all at
once): Ghidra (Java 17+), r2, GDB (gdb-multiarch for cross-arch),
LLDB, frida-tools, JADX (Java 17+), apktool. Codegraph requires
either a local global install (npm i -g codegraph) or relies on npx
to fetch on first run.
Constraint: Cannot single-step from Frida alone -- that's the gap GDB
and LLDB fill in this commit. dynamic-debug-overview SKILL is the
canonical decision guide for which lane to use.
Confidence: high
Scope-risk: narrow (additive plugin under plugins/, additive
.mcp.json; zero changes to existing source). Plugin loads via the
existing PluginManifestSchema path -- no new server-side code added.
Tested: bun run plugins/reverse-engineering/scripts/validate.ts (pass),
bun run plugins/reverse-engineering/scripts/smoke.ts (13/13 pass), live
chrome-devtools MCP smoke against running desktop UI verifying plugin
appears with correct version + counts.
Not-tested: real underlying-tool integration (Ghidra/r2/JADX/GDB/LLDB
must be installed by the user; the plugin only validates manifest
shape and component loading). Reverse-debugging (rr) flow is
documented in skills/gdb-debug but not exercised in smoke.
* fix: detect & isolate fake tool_use leaks from non-Anthropic providers
Some third-party Anthropic-compatible gateways (mimo, lgfzer, certain
proxies) don't relay native tool_use blocks: when the model wants to
call a tool, it ends up emitting an XML-style `<tool_use ...>{...}
</tool_use>` element as plain text inside content_delta. The desktop
chat renders that as markdown, marked passes the unknown element
through as raw HTML, the browser collapses whitespace, and the user
sees garbage like `<tool_useid="..."` followed by a smushed shell
command. Worse, the model has no signal the call never executed and
follows up with apologies ("工具用错了, 重来:") and retries — every
"call" is text and nothing runs.
Three layers of defense, lowest to highest in the stack:
1. **Source-side priming reduction** (server). The specialistRouter
docstring already warned that `key="value"` attribute fragments in
model-facing strings make some gateway models switch from real
tool_use blocks into XML mode. Three model-facing nudges still
embedded `subagent_type="verification"` in their reminders — fix
them to use prose ("set the subagent_type parameter to verification")
so we stop priming the failure mode:
- src/utils/messages.ts (verification_gate_reminder)
- src/tools/TodoWriteTool/TodoWriteTool.ts
- src/tools/TaskUpdateTool/TaskUpdateTool.ts
New regression test src/utils/noKeyValueNudges.test.ts pins all
three call sites so a future "typo fix" doesn't accidentally
re-introduce the attribute form.
2. **Detection + sanitization** (desktop). New
desktop/src/lib/fakeToolUseDetection.ts extracts XML-style
`<tool_use>` blocks (closed, half-open mid-stream, multiple
consecutive retries, `name`/`id` in either order, quoted or
unquoted, inside or outside fenced code blocks) and returns
`{ cleanText, blocks[] }`. AssistantMessage uses this before
handing content to MarkdownRenderer so the user never sees the
XML garbage; copyText also uses cleanContent so users don't paste
broken markup. Fenced code blocks (```xml ... ```) are preserved
so legitimate documentation examples render as-is.
3. **Provider compatibility tracking** (desktop). New
desktop/src/stores/providerCompatStore.ts counts fake tool_use
leaks per provider id, persisted to localStorage. After 3 leaks
it fires a one-time toast suggesting the user switch providers.
Settings → Provider list shows a "工具调用异常" badge on offending
providers; saving an edit on a flagged provider re-arms the
warning (clearProvider). Above-threshold detection is silent
afterward so we don't spam — the badge stays as the persistent
signal.
The new FakeToolUseNotice component renders an inline grey card
above the assistant bubble naming the attempted tool ("Bash") and
making it clear nothing ran, so the user knows not to trust any
follow-up "Done." claim that depended on the call's output.
Verified:
- desktop: bun run lint clean
- desktop: 28 new tests + existing AssistantMessage.linkrouting (15
total) pass
- server: 31 tests across verificationGate, specialistRouter, and the
new noKeyValueNudges regression all pass
Tested: bun run lint (desktop), bunx vitest run (3 desktop suites),
bun test (3 server suites)
Confidence: high
Scope-risk: narrow
---------
Co-authored-by: cc-haha <cc-haha@users.noreply.github.com>
Co-authored-by: 你的姓名 <you@example.com>
4.5 KiB
| name | description | whenToUse | allowedTools |
|---|---|---|---|
| crackme-keygen | For CTF / crackme challenges where the deliverable is a serial, key, or input that the binary accepts. Recovers the validation logic, then either reverses it (keygen) or supplies a witness input. | When triage shows a small standalone binary (PE/ELF/Mach-O) that prompts for a license/serial/key and the user's goal is to satisfy the check. Not for malware analysis. | Bash, Read, Grep |
crackme-keygen skill
Goal: produce either (a) a single accepted input, or (b) a small program / script (a "keygen") that produces accepted inputs on demand.
This skill is built around the public framing in Binary Reverse Engineering for Agents (arxiv 2605.10597) — and follows the spirit of CTF / crackme-style challenges, not real-world license cracking. Do not use this on commercial software you don't own.
Procedure
Step 1 — Verify the brief
Before doing anything, get clarity on:
- Is this a CTF challenge, your own crackme, or your own software?
- What does the program accept as input — stdin? command-line argument? file?
- What's the success indicator — exit code 0? a "Correct!" string? a flag?
If the answer involves third-party commercial software, stop. This skill is for CTF and self-owned binaries only.
Step 2 — Reach the validation function
Use the pe-elf-macho skill to locate the function that decides accept vs
reject. Concretely: find xrefs to the failure string ("Invalid", "Wrong",
"Try again") and walk back to the comparison.
Typical shapes:
- String compare —
strcmp(input, "h4xx0r")→ the answer is the literal. - Hash compare —
compare(sha256(input), "abcd…")→ either crack the hash (rainbow / weak preimage) or replace the binary's expected hash with one of yours. - Stateful transform — input → series of arithmetic / XOR / table lookups → compared against constant. Reverse the transform.
- Per-character math — for each i,
input[i] = f(i, secret_constants). Often invertible directly. - CRC / custom checksum — find the algorithm (xrefs to the constant polynomial / table), then either invert or brute-force.
Step 3 — Decompile and rewrite as Python (or C)
Take the validation function's decompiled output and re-express the math in Python. Then either:
- Forward-solve: feed candidate inputs through your Python implementation until it accepts (only sane when input space is small).
- Backward-solve: implement the inverse so each accepted output yields an input. This is the keygen.
- Symbolic-solve: when the function is loopy XOR/arithmetic that you don't
want to invert by hand, use
z3orclaripy(angr) to ask "find input s.t. validate(input) returns 0". Suggest this to the user when control flow has many branches.
Step 4 — Confirm against the real binary
A keygen that works in your Python script but fails on the real binary is worthless. Always verify:
echo -n "<generated-input>" | $SAMPLE
# or:
$SAMPLE "<generated-input>"
echo "Exit code: $?"
If it doesn't accept, you missed an instruction. Common misses:
- Endianness in the comparison.
- Off-by-one (input length vs null terminator).
- A second check after the first (some crackmes split validation across two functions).
- A side-channel — anti-tamper hash over the binary itself, which fires only when you've tampered with it (irrelevant for keygens, but watch for it).
Step 5 — Write the keygen artefact
Place the keygen at
ARTIFACT_DIR/<sample-id>/keygen.py (or .c) and a short writeup at
ARTIFACT_DIR/<sample-id>/crackme.md:
# Crackme — <sample-id>
## Validation function
- Address: 0x401a30 (sub_401a30)
- Input: ASCII string from argv[1], length must be 16
- Algorithm: per-character XOR with rotating key derived from a constant table
at 0x402000
## Decompiled (cleaned)
```c
<short snippet>
Keygen logic
For i in 0..15: input[i] = TABLE[i] ^ ((i * 0x9E3779B9) & 0xFF)
Witness
A valid input: 5b2f04a7e91c6f3d
Verified accepted by binary: yes (exit code 0, prints "Correct!")
## Hard rules
- **No commercial license cracking.** This skill is for CTFs, crackmes, and
your own software. If asked to crack non-trivial commercial DRM, refuse.
- **The keygen is the deliverable, not the patched binary.** Don't byte-patch
the comparison — that defeats the point.
- **Always confirm against the real binary.** A keygen that works in Python
but not on disk is a regression you have to find before claiming success.