agentleFS
UIhoshiUIhoshi/AgentLogic/skills/engineering/decompile-reconstruction/SKILL.md

decompile-reconstruction

Skill0 starsChanged 6 days agoMITView on GitHub

Autonomous binary/bytecode/bundle decompilation and clean-room source code reconstruction. Triggered automatically when the user provides or asks to analyze, decompile, deobfuscate, or recover readable/compilable source code or algorithms from compiled binaries (PE/ELF/Mach-O/DLL/SO), Android APKs/JARs, .NET assemblies, Python bytecode (.pyc), WASM, or bundled/minified/obfuscated JS/Electron apps.

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 3 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Do NOT wait for the user to specify a skill name.

    line 12
  2. Distinctive:

    Never guess the target format from the file extension alone, and never run an unknown binary to see what it does.

    line 27
  3. Distinctive:

    Before decompiling individual routines, build a concise evidence map of the target:

    line 44
  4. Very specific:

    Zero Hallucination Rule: Every reconstructed function MUST cite its original binary address, symbol name, or bytecode offset (e.g., // …

    line 54
  5. Very specific:

    Run the code-simplifier pass on the reconstructed source to remove dead decompiler temporaries and redundant casts.

    line 69

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Engineering Decompilation & Clean-Room Source Reconstruction (decompile-reconstruction)

This skill turns compiled binaries, bytecode packages, game/model containers, and obfuscated bundles into structured architectural maps and clean, readable, compilable source code. It synthesizes the engineering-first workflow of morluto/rea (Reverse Engineer Anything) and LaurieWired/GhidraMCP, orchestrated alongside AgentLogic's ida-reverse, ghidra-reverse, binary-ninja-reverse, go-rust-reverse, macos-reverse, apk-reverse, dotnet-reverse, js-reverse, protocol-reverse, and radare2 capabilities.

Automatic Trigger Contract (Encounter -> Auto-Use)

Do NOT wait for the user to specify a skill name. Activate this workflow automatically whenever:

  1. The user provides or points to a compiled or packaged artifact (.exe, .dll, .so, .dylib, .elf, .sys, .apk, .aab, .ipa, .jar, .dex, .pyc, .wasm, .asar, .beam, .pck, .gguf, .safetensors, .ptx, .cubin, .har, or minified/obfuscated .js) and asks:
    • what it does, how a feature/algorithm/protocol inside it works, or
    • to decompile, deobfuscate, port, or reconstruct it into clean source code.
  2. Scope Boundary (Engineering vs. Offensive Security):
    • Engineering Reconstruction (Automatic): Analyzing program logic, recovering data structures/types, deobfuscating bundles, and reconstructing clean-room source code in the local workspace runs automatically under this route.
    • Offensive Exploitation / Live Malware Execution (Restricted Manual): Never execute unknown/untrusted binaries directly on the host OS. If the task shifts to live exploitation (pwn-chain) or active penetration testing, defer to the restricted security confirmation boundary.

The 5-Stage Clean-Room Reconstruction Pipeline

Stage 1: Non-Destructive Format Triage & Toolchain Selection

Never guess the target format from the file extension alone, and never run an unknown binary to see what it does. First inspect headers/metadata, security hardening flags (PIE, NX, RELRO, Canary, CFG, Authenticode), and runtime signatures read-only, then select the highest-fidelity available decompiler:

Target Artifact ClassIdentification SignalOrdered Toolchain Priority (Use First Available)
1. Native Binary (PE/ELF/Mach-O: .exe, .dll, .so, .dylib, .sys)Native headers without CLR metadata (ELF notes, PE imports/Authenticode, Mach-O load commands)1. IDA Pro MCP (idapro_* via skills/reverse-skill/skills/ida-reverse/SKILL.md)<br>2. Ghidra MCP / Headless (ghidra-mcp or analyzeHeadless via skills/reverse-skill/skills/ghidra-reverse/SKILL.md)<br>3. Binary Ninja / Hopper / Kuna MCP (skills/reverse-skill/skills/binary-ninja-reverse/SKILL.md)<br>4. Radare2 + Ghidra Decompiler (r2 -qc "aaa; pdg @ <func>")<br>5. LLVM/Binutils Native Triage (llvm-objdump -d, nm -C, readelf, strings)
2. Stripped Go / Rust Native Binary.gopclntab / go.buildid or .cargo-auditable / rust_eh_personality / core::panicking1. go-rust-reverse Workflow (skills/reverse-skill/skills/go-rust-reverse/SKILL.md: recover pclntab symbol tables, slice/string/interface fat pointers, and Rust crate metadata)<br>2. IDA Pro / Ghidra with Go/Rust type recovery
3. .NET / C# Managed Assembly (.exe, .dll with CLR header)PE Data Directory[14] (CLR header) / mscoree.dll / #Strings1. de4dot (if obfuscated with ConfuserEx/SmartAssembly/etc.)<br>2. ilspycmd (headless C# project export: ilspycmd -p -o <out_dir> <target.dll>) or dnSpyEx / dnSpy MCP (skills/reverse-skill/skills/dotnet-reverse/SKILL.md)
4. Android APK / Flutter / JVM Bytecode (.apk, .jar, .dex, .class)ZIP magic + classes.dex, libapp.so (Flutter Dart AOT), or 0xCAFEBABE1. jadx (jadx -d <out_dir> --deobf <target.apk/jar>, see skills/reverse-skill/skills/apk-reverse/SKILL.md) or JEB MCP<br>2. blutter / reFlutter (for Flutter libapp.so Dart object pool recovery)<br>3. apktool (resources/Manifest/smali) + CFR / Vineflower (Java .jar)
5. Game Engine & Runtime Containers (Unity IL2CPP, Godot .pck, Erlang .beam)libil2cpp.so + global-metadata.dat, GDPC magic, or FOR1/BEAM1. Il2CppDumper / Cpp2IL (recover C# class/method signatures + apply to IDA/Ghidra)<br>2. gdsdecomp (GDRE Tools) (Godot .pck / .gdc bytecode recovery)<br>3. beam_disasm / erl +S (Erlang/Elixir BEAM abstract code extraction)
6. Python Bytecode / Frozen App (.pyc, PyInstaller .exe)Python magic header or MEI / PYZ archive1. pyinstxtractor / pyinstxtractor-ng (for PyInstaller containers)<br>2. pycdc (Decompyle++) or uncompyle6 (.pyc -> .py) + dis module disassembly
7. Electron / Bundled JS / Browser Extension / WASM / EVM (.asar, .crx, .js, .wasm, .bin)Electron app.asar, Chrome extension manifest.json, Webpack/Vite bundle, \0asm, or EVM opcodes1. npx @electron/asar extract (for .asar) or browser-extension-reverse<br>2. webcrack / SourceMap recovery / ast-grep structural deobfuscation (js-reverse)<br>3. wasm2wat / wasm-decompile (WABT) or Heimdall/Panoramix (EVM bytecode)
8. AI Model, GPU Kernel & Network Protocol Captures (.gguf, .safetensors, .cubin/.ptx, .pcap/.har)GGUF magic, JSON tensor header, cuobjdump/nvdisasm ELF, or PCAP/HAR1. Header & Architecture Inspector (extract GGUF/safetensors hyperparameters, tokenizer, and layer topology without loading raw weights; cuobjdump --dump-ptx / nvdisasm for GPU kernels)<br>2. protocol-reverse & derive-client (skills/reverse-skill/skills/protocol-reverse/SKILL.md: recover Protobuf/gRPC descriptors, WebSocket frames, or synthesize standalone API/RL clients from .har/.pcap)

Missing Tool Handling: If the optimal decompiler (e.g., Ghidra, ilspycmd, jadx, pycdc, webcrack) is not installed on the host, follow Module 49's single-consent prerequisite bundle (or use the highest available native fallback with explicit disclosure of the fidelity gap).

Stage 2: Structural & Symbol Survey (Map Before Deep-Dive)

Before decompiling individual routines, build a concise evidence map of the target:

  1. Exports, Entrypoints & High-Fan-In Functions: Identify main/DllMain/JNI_OnLoad, exported APIs, and functions with the highest cross-reference (xref) counts.
  2. Strings, Constants & Import Classification: Group imports and strings by domain capability (file I/O, network/HTTP, cryptography/hashing, serialization, UI/IPC).
  3. Architecture & Call Graph Summary: Record the module's subsystem layout before translating any function.

Stage 3: Evidence-Backed Pseudocode & IR Extraction

Extract raw decompiler output (C pseudocode, C#, Java, Python, or WAT) for the target call chain:

  • Zero Hallucination Rule: Every reconstructed function MUST cite its original binary address, symbol name, or bytecode offset (e.g., // Reconstructed from sub_140002A10 (0x140002A10)). Never invent functions or algorithm steps that are not backed by extracted pseudocode or disassembly.
  • Save raw extracted pseudocode or decompiler dumps into a dedicated working directory (e.g., .specify/<task>/decompiled-raw/ or project scratch directory) so raw evidence remains separate from clean reconstructed code.

Stage 4: Type, Struct & Control-Flow Recovery (Clean-Room Refinement)

Raw decompiler output is full of compiler artifacts (v1, a1, *(DWORD *)(v2 + 0x18), goto LABEL_14, state-machine switches). Transform raw pseudocode into idiomatic, maintainable source code:

  1. Struct, Enum & Type Recovery:
    • Replace raw pointer offsets (*(uint32_t *)(ctx + 0x10)) with explicit struct field definitions and typed pointers.
    • Replace magic numbers and bitwise flags with named enum or const definitions.
  2. Control-Flow Structuring (Eliminate goto & Flattened Switches):
    • Convert decompiler goto labels and while-true break cascades back into structured for/while loops, early returns, and guard clauses.
    • Unroll compiler-generated async/coroutine/iterator state machines back into readable async/await or generator functions.
  3. Semantic Renaming & Code Simplification:
    • Rename sub_xxx, v1, arg_0 to domain-meaningful identifiers based on string xrefs, API calls, and data flow.
    • Run the code-simplifier pass on the reconstructed source to remove dead decompiler temporaries and redundant casts.

Stage 5: Equivalence Verification & Closure

  1. Compilation / Static Check: Compile or typecheck the reconstructed source code (gcc/clang/cargo/tsc/dotnet build/javac/python -m py_compile) to prove it is valid, self-contained code rather than broken pseudocode.
  2. Input-Output Equivalence Proof: Where known test vectors, protocol payloads, or constants exist in the binary, run a unit test or verification script proving the reconstructed function produces identical outputs to the original binary logic.
  3. Closure Evidence: Record target_format_and_toolchain_triage and decompiled_or_reconstructed_artifact.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.