An early disassembler and decompiler. The workbench and the CLI read a corpus, a kuna export, or a program image. A function of x86-64 — its calls, branches and loops — is printed as C, with if/else, while, for and early return.
| If you want to… | Start here |
|---|---|
| See the interface with no binary | cargo run --bin ag-ui |
| Disassemble and decompile a file | Image CLI |
| Browse functions in a corpus | Corpus CLI |
| Look up a flag by the symptom it fixes | docs/options.md |
| Read one topic from the binary itself | ag docs |
The workbench on a kuna project export of a small ELF. The listing comes from the export's .asm, the cross references, strings and program summary from the kuna CLI, and the selection is shared by every pane.
The same function on the Pseudocode tab. Lines that kuna mapped to addresses are numbered and clickable, so a click on a line moves the listing to the instructions it came from.
The bundled sample project, which opens when no corpus or export is given, so the interface can be explored without a binary.
The native path: an ELF read by the engine's own loader, with no corpus and no export. The Graph tab draws the control-flow graph of the selected function, and the Bytes panel below holds the bytes of the file around the selection.
The Strings tab lists the text the image holds, with the functions that use it, and filters the list as you type.
ag-corpusreads an indexed decompilation corpus and a kuna project export, and overlays Objective-C method names.ag-clibuilds theagcommand-line tool: it reports on either source and carries its own manual and an agent skill.ag-engineholds the program image loader (ELF, PE, COFF and Mach-O, through the kuna-analysis crate), the native x86 decoder (32-bit and 64-bit, the width read from the image's language), the control-flow graph builder, the first slices of the lifter (x86-64 code with calls, branches and loops, to the AST, structured with dominators and back edges), and the C emitter.ag-imagereads a program image through the engine: its sections, its symbols, the bytes of the file, the disassembly of a function, its pseudocode, the calls between the functions, and the strings of the data sections.ag-uibuilds theag-uidesktop analysis workbench, an Iced application that reads both sources through the same data layer the CLI uses and asks the kuna CLI for what an export does not carry.
Install the Rust toolchain, then build from the repository root:
cargo buildRun the CLI with Cargo:
cargo run --bin ag -- --helpThe current CLI reads a corpus directory containing decompile-index.json and the function files referenced by that index. Pass --root to select the corpus directory.
# Summarize the corpus
cargo run --bin ag -- corpus --root ./corpus stats
# List functions, optionally filtering names with a regular expression
cargo run --bin ag -- corpus --root ./corpus list --named-only --filter 'decrypt|parse'
# Show a function by address or name
cargo run --bin ag -- corpus --root ./corpus show 0x1000
# Search function bodies with a regular expression
cargo run --bin ag -- corpus --root ./corpus grep 'memcpy|malloc'Objective-C method names can be overlaid from a method map with --methods PATH. See cargo run --bin ag -- corpus --help and cargo run --bin ag -- corpus --root ./corpus list --help for all options.
The CLI reads a program image as well: an ELF, PE, COFF or Mach-O file, parsed by the engine's own loader.
# The language, the entry point and the sections
cargo run --bin ag -- image ./sample.elf info
# The function and data symbols
cargo run --bin ag -- image ./sample.elf symbols --filter 'main|add'
# The disassembly of one function, by name or by address
cargo run --bin ag -- image ./sample.elf disasm main
# The pseudocode of one function, as C
cargo run --bin ag -- image ./sample.elf pseudocode main
# The control-flow graph of one function
cargo run --bin ag -- image ./sample.elf cfg main
# Who calls whom
cargo run --bin ag -- image ./sample.elf calls
# The strings of the image, and the functions that use them
cargo run --bin ag -- image ./sample.elf strings
# The data of the image, and the functions that use it
cargo run --bin ag -- image ./sample.elf data
# All of the above, written as a directory of JSON and text
cargo run --bin ag -- image ./sample.elf export ./sample.ag| Command | Report |
|---|---|
info |
Language, entry point, sections |
symbols |
Function and data symbols |
disasm |
One function, one instruction a line |
pseudocode |
That function as C |
cfg |
Blocks and the edges between them |
calls |
Who calls whom |
strings / data |
Text and data, and the functions that use them |
export |
The same reports as a directory |
Every subcommand takes --json for the same report as JSON.
info and symbols read any format the loader reads.
disasm decodes x86, 32-bit and 64-bit, taking the width from the image's language (x86:LE:32:... or x86:LE:64:...). Through SLEIGH it also decodes 32-bit ARM and Thumb, AArch64, 32-bit MIPS of either byte order, little-endian RISC-V of either width, PowerPC of either width and byte order with VLE and the paired-single extensions, the 16-bit MSP430, and the retro and embedded cores: the 6502, the Z80, and the little-endian SH4.
| Architecture | What you get today |
|---|---|
| ARM, Thumb, MIPS, 6502, Z80, SuperH | Decoded, walked, and listed. Not yet lifted. |
| MIPS | Operands read through the global pointer. global-pointer says where its value came from. |
| SuperH | Branch delay slots folded into the branch. |
| AArch64, RISC-V, MSP430, PowerPC | Lifted to pseudocode. RISC-V's bit-manipulation extension is disassembled but not lifted; PowerPC's paired singles and floating point are disassembled but not lifted, and its 64-bit big-endian ELFv1 function descriptors are resolved to their code. |
An image of another architecture is refused rather than printed as nonsense.
strings reads the sections that are not code and reports the text that ends in a NUL, with the functions that use it. --filter keeps only the strings whose text matches a regular expression, --utf16 reports the strings that are held as UTF-16LE, and --encoding NAME reports the strings held in one encoding: ascii, utf16le, utf16be, utf32le, utf32be, cp932, gbk or euc-kr.
pseudocode lifts one function to C through its whole control-flow graph.
- Blocks joined by fall-through are one node. Dominators and back edges become
if/else,while,do/while,for,break,continue, and earlyreturn.gotois used only where nothing else fits. - The symbolic state is split at a branch and merged at a join. A slot or register that differs between the paths becomes a declared variable assigned on each path.
- A condition comes from the
cmportestthat set the flags the branch reads. - The return type is decided from use, not presence. A caller that reads
eax/raxafter the call decides it. With no caller in the image, a value the function wrote itself decides it, rather than a callee's leftover. The function opens with a comment that says which.
On the sample:
| Function | Pseudocode |
|---|---|
add |
int add(int a, int b) { return b + a; } under // returns int: main reads eax after the call. Parameters are named by position. |
main |
C with its three calls — add, sum_to, and printf. The format-string pointer is the literal "%ld\n". |
sum_to |
for (local_14 = 1; local_14 <= a; local_14 = local_14 + 1) { local_10 = local_10 + (long)local_14; } and the accumulator is returned. |
a tail jmp |
return callee(args);, or callee(args); return; when nothing in the image reads the result. Direct, or through a GOT slot the image resolves to an import. deregister_tm_clones is // void: no caller reads the result. |
printf stub |
A thunk. The whole body is // thunk for printf. |
__do_global_dtors_aux |
void. One path leaves a callee's result in rax and the other leaves nothing. |
| refused | not lifted yet and the reason, exit code 1. An unknown instruction, flags the lifter did not see set, or a loop with two entries. |
pseudocode and export take the engine's options, --option NAME VALUE (such as --option loop-form while, repeated as needed), and ag catalog prints every option with its symptoms; the generated docs/options.md opens with the index of if the output shows X, try Y.
cfg reports the control-flow graph of a function: its blocks, and the edges between them, each edge marked fall-through or taken. The walk stops at a jmp to another function the image knows — a tail call, which calls reports — so the sample's frame_dummy is its one block and not register_tm_clones's after it. calls reports who calls whom: with a function, what it calls and who calls it; without one, the whole call graph. A jmp out of a function is a call marked (tail call), so a PLT stub names the import it jumps to.
data reports the data the image holds and the functions that use it: with a function, the data that function refers to; with a piece of data, the functions that use it.
export writes the whole analysis to a directory in one pass: info.json, symbols.json, strings.json, data.json and calls.json as the subcommands print them under --json, a functions/<address>.json and functions/<address>.asm per function, an index.json, and a README.md naming the binary, its SHA-256 and the ag version. --functions REGEX limits the per-function files; a directory that is not empty is refused without --force.
binexport FILE writes the analysis as a BinExport file — the call graph, the flow graphs, the instructions and their operands — so two versions read by ag can be compared in BinDiff. --project FILE writes the project's renames and comments with it.
dwarf FILE writes the analysis as DWARF debug information — the functions and data at their addresses under the analyst's names, and the types the analysis gives them — so the work done here can be used in a debugger without typing it in again: gdb ./program.elf -ex 'add-symbol-file program.debug'. --project FILE writes the project's renames, types, prototypes and byte-type marks with it.
gzf FILE writes the analysis for Ghidra — the processor, the memory map, the code, the functions under the analyst's names and prototypes, the types, the symbols and the comments — as Ghidra's XML program format, so the work done here can be used in Ghidra without typing it in again (File → Import File). The memory bytes are written beside it as <name>.bytes; keep the two together, as Ghidra reads the sidecar from the same directory. --project FILE writes the project's renames, types, prototypes and comments with it.
For a microcontroller, ag project ./firmware.elf svd --file fw.agproj STM32F103.svd imports the vendor's CMSIS SVD peripheral map the other way: a segment for each address block a peripheral decodes, a C structure of its registers, a label at its base and a comment at each register saying what it is and the values its fields take — so the peripheral map a debugger or another tool already knows does not have to be typed in by hand. --preview says what the map holds first, names after the file pick the peripherals, and the analyst's own names and comments stand over what the map says.
An external debug info file loads the other way too: ag project ./bin/ls save --out ls.agproj --debug-info ls.map reads a linker map, a JSON document, or a format a plugin's parser knows as the project is made, and ag project ./bin/ls debuginfo --file ls.agproj debug.json loads one into a project that exists — the names, prototypes, types and data labels another tool already knows, kept as the analyst's own, so work done in other tools is not recreated by hand. --preview says what the file holds first, --format names the parser, and the analyst's own names and comments stand over what the file says.
An IDA database loads the same way: ag ida apply program.i64 --binary ./program --project program.agproj reads the names, comments, prototypes and types an analyst worked out in IDA — from a .idb, a .i64 or a .til — into a project, so work done in IDA is not recreated by hand. ag ida info program.i64 says what a database holds first, and the analyst's own names, comments and types stand over what the database says; --no-types leaves the types out.
A library function is the same code in every program that links it, so ag funcid names it by a hash of its whole body without lifting a line. The bytes that carry an address — a branch's relative target, a RIP-relative or absolute displacement — are masked before hashing, so the same function matches at any load address, while a stack or structure offset is kept. create makes a signature file (.agsig) from a named library, match reports the functions of an image a signature knows, and apply writes what a match knows — the name, the prototype, the comment — into a project, keeping the analyst's own words. The engine ships signatures for libc, libstdc++ and libgcc; a whole-function hash is exact, so they match the build they were taken from and create makes signatures for the exact libraries a target links.
# The signature databases the engine ships
cargo run --bin ag -- funcid list
# Make signatures from a named library, then read them onto a program
cargo run --bin ag -- funcid create /lib/x86_64-linux-gnu/libc.so.6 -o libc.agsig --library libc
cargo run --bin ag -- funcid match ./program --sig libc.agsig
cargo run --bin ag -- funcid apply ./program --project program.agproj --sig libc.agsig
# Share signatures: run a server, push to it, match against it
AG_FUNCID_TOKEN=secret cargo run --bin ag -- funcid serve --store ./sigstore
AG_FUNCID_TOKEN=secret cargo run --bin ag -- funcid push libc.agsig --server http://127.0.0.1:7395
cargo run --bin ag -- funcid match ./program --server http://127.0.0.1:7395
cargo run --bin ag -- funcid pull --server http://127.0.0.1:7395 -o sigs/A signature server (ag funcid serve) is one store of signatures a team pushes to, pulls from and matches against, so a library one analyst has fingerprinted is recognised in everyone's images. A match sends the server only the hashes of the image's functions, never their bytes; a push needs the server's token. The server speaks plain HTTP, so it belongs on the loopback, a private network or behind an SSH tunnel.
A whole-function hash needs a name and an end to start from. The classic alternative is a byte-pattern library (.agpat): each function's opening bytes with the address bytes left as wildcards, a CRC of the run after them, and its length. ag funcid create … -o lib.agpat makes one, and --sig lib.agpat on match and apply tries it on every function the image knows, named or not — which names library code linked statically into a stripped program.
The fingerprint, its constraints, the file formats and the server are in docs/funcid.md, also ag docs funcid.
ag mcp serves a program image to a language model over the Model Context Protocol, on
standard input and output: the functions and strings and a search over them, the disassembly,
pseudocode and control flow of a function, its callers, callees and cross references, the
bytes at an address — and, with --project FILE, the analyst's names, comments and
bookmarks, read and written in the same project file the workbench opens.
cargo run --bin ag -- mcp ./sample.elf --project ./sample.agprojThe tools are listed in docs/cli.md.
ag run runs a script against a program image, headless: the analysis runs, the command
after -- starts with the same tools ag mcp serves on its standard input and output, and
ag run ends with the command's exit status. Any language that reads and writes lines of
JSON is a scripting language here; scripts/ag.py is the conversation as Python calls.
cargo run --bin ag -- run ./sample.elf --project ./sample.agproj -- python3 my_script.pySee docs/scripting.md.
The lift is readable at every level it passes through — lifted (the machine's
instructions with the registers each touches), low (the lifter's statements over
temporaries and slots), medium (statements over variables on the block graph) and high
(the structured body) — each with an SSA form, each item carrying the addresses it came
from, so the levels map onto each other and onto the listing. In the workbench, F7 cycles
the Listing or Graph pane through the levels and Shift+F7 toggles the SSA form; the View menu
adds each item's opcode, flag use, stack pointer and types, and makes the casts explicit.
cargo run --bin ag -- image ./sample.elf il sum_to --level medium --ssa
cargo run --bin ag -- image ./sample.elf emulate sum_to --arg 5The medium level also runs, and it compiles.
emulate |
Runs a function's statements against the image's memory, follows calls into the image, and reports what it returned and why it stopped. |
transpile |
Writes the functions as C++, a label per block and a goto for every way out, with a main to run one against the program it came from. |
The pseudocode itself reads as C, Rust, Objective-C, or Python (--option language rust): the same lift, spelled each language's way. The analyst has the last word at any one site — a guard, a folded condition, a turned-round branch, a switch — recorded in the project file.
- Dead code the lift keeps is greyed out. One variable's unused stores can be dropped on their own.
rep movsandrep stosread as__builtin_memcpyand__builtin_memset. A string put on the stack word by word, or byte by byte, reads as one__builtin_strcpy(--option builtins keepfor the stores).- A struct filled field by field through a pointer reads as one initializer (
--option struct-initializers keepfor the stores). - A call through a pointer the lift knows is the call through it (
--option indirect-calls refuseto refuse it). A Windows control-flow guard's dispatch is the call it guards. - A call to
exitor its kind ends its path. A function whose every path ends so never returns. An exit-on-error helper is noted with the condition it does not return under, at its own head and at each call.
The text's layout is the analyst's too: --option brace-style broken, ternaries expand, wrap 80, call-hints names. The workbench draws rainbow braces and indent guides. A formatter plugin has the last word on the lines.
See docs/il.md.
A loader, an architecture — one that may recover a function's blocks and lift it whole
itself, for an instruction set with delay slots or hardware loops, or a bytecode — a tool, a
rewriter, which changes a function's medium-level graph as it is lifted, for work such as
control-flow unflattening, a formatter, which changes the pseudocode's lines after they
are printed, a recognizer, which decodes the strings a function's expressions build and
shows them as comments beside the code, a renderer, which names the constants a
function's expressions use so the pseudocode shows the name in the constant's place, or a
debug info parser, which reads an external debug info file into the names, prototypes and
types a project keeps, is added without forking: in Rust, against the traits of ag_engine::plugin and
ag_image::plugin; or in any language, as a command declared in a JSON manifest in a plugin
directory (AG_PLUGINS, or ~/.config/ag/plugins) that ag finds as it starts. ag plugins
lists what is registered; ag tool runs a plugin's tool.
cargo run --bin ag -- pluginsSee docs/plugins.md.
A corpus is a directory holding decompile-index.json and one file per function. The index is JSON: a version, the target_sha256 of the binary that was analysed, the provider that produced it, and a functions array. Each entry gives the function's address and name, its status, and the byte range its body covers. The body lives in functions/<address>.c, or wherever the entry's relative_path points. The leading // comment header of a body is dropped; the signature and the locals are kept.
A kuna project export is the other layout ag reads: a .c of every function, a .h of prototypes, an .asm of every code section, and — under --stream — an index.jsonl giving each function's byte span in the .c.
The --methods map is a JSON array of records, each naming the IMP of a method, its class, its selector and its types. A class method is the instance method of the class's metaclass: the map says which it is with is_class_method, or by writing the class with a leading +. The two are told apart in the display, -[Class sel] and +[Class sel], so they are two names and not one.
Nothing is dropped in silence. A record that cannot be read is skipped and named, and two records that claim one address are both kept, with the first resolving it. ag says so on stderr, and the workbench shows it in the Problems pane.
The ag binary carries its own documentation and an agent skill, so a session with no checkout and no network can still read the reference and learn to drive the tool.
# List the embedded manual's topics
ag docs
# Print one topic
ag docs cli
# Install the agent skill where coding agents load skills
ag install-skill --agent claudeag install-skill writes the skill offline, into $CLAUDE_CONFIG_DIR/skills, $CODEX_HOME/skills or $OPENCODE_CONFIG_DIR/skills (or the project directory with --project). ag docs prints the manual: the command reference, the corpus format, the project file, the options, the intermediate languages, plugins, scripting and the workbench.
ag-ui is the desktop analysis workbench: a menu bar, a function navigator, a work surface with listing, pseudocode, graph, bytes and references, an inspector, and a bottom workspace for search results and problems. The layout follows ui/UI_PLAN.md.
# Launch with the bundled sample project
cargo run --bin ag-ui
# Launch on a corpus
cargo run --bin ag-ui -- --corpus ./corpus
# Overlay an Objective-C method map
cargo run --bin ag-ui -- --corpus ./corpus --methods ./corpus/methods.jsonThe workbench also drives a debugger — GDB on Linux, or, untested, LLDB through lldb-mi — with breakpoints set in the listing's margin and the listing following the program counter; ag debug runs the same session headless. See docs/workbench.md.
The corpus directory must contain a decompile-index.json. Without one the workbench opens a bundled sample project so the interface can be explored. ui/README.md covers the workbench in more detail.
The workbench opens a kuna project export as well:
cargo run --bin ag-ui -- --kuna ./challenge.kunaThe export fills the Listing and Pseudocode tabs on its own. With the kuna executable available, named by AG_KUNA_BIN or found on the PATH as kuna, the workbench also asks it for the cross references, the strings, the program summary, and the mapping from each line of C to the addresses it came from. Without it those panes stay empty and the Problems panel says why.
The workbench opens a program image as well:
cargo run --bin ag-ui -- --binary ./sample.elfThat is the native path: the image is parsed by the engine's own loader, the navigator lists its symbols, the inspector shows its sections and entry point, and the Listing tab holds the native x86 disassembly of the selected function, 32-bit or 64-bit as the image's language says. The Pseudocode tab holds the engine's own lifting of the selected function — the sample's add reads as C, so does its main with its three calls, its sum_to reads as a for loop, and its printf stub reads as the one line // thunk for printf — and the lines are numbered and clickable like the kuna provider's, so a click on return b + a; moves the listing to the add, a click on the printf line to the call, and a click on the for line to the loop's compare. A function the lifter refuses — such as the sample's _init, which calls through a register — leaves the tab empty, and the Problems panel says why.
Who calls what is only known once the whole program has been read, so that is worked out in the background when the image opens: the References tab says indexing… until the callers are known.
The Bytes tab shows the bytes of the file around the selection, sixteen to a row, with the address, the hex and the ASCII column, and the bytes of the selected instruction marked. The pane follows the selection, and picking a section or a named symbol in the navigator moves it there.
The Strings tab lists the text the image holds, with the functions that use it. The list filters as you type, and picking a string moves the selection to it.
The Graph tab draws the control-flow graph of the selected function: one box for each block the walk found, with the instructions in it, and an arrow for each way the code goes on. The arrow that leaves the end of a block is the fall-through, and the other one is the branch that is taken. That is the same rule ag image cfg reports by, so the workbench and the command line name an edge the same way. An arrow that skips a row goes around the blocks in between rather than through them. The graph can be dragged and zoomed, and clicking a box moves the selection to it.
The engine is under active development. Treat it as an experiment, not a production tool.
| In place | Still early |
|---|---|
| x86 decoder, 32-bit and 64-bit, with tests | Architectures that list but do not lift yet |
| Control-flow graph builder | |
Lifter and C emitter: straight-line code, calls, and if/else, while, for with state merged at each join |
What the lifter cannot read is refused with a reason |
The judgment calls are one option registry, set per run with --option and indexed by symptom in docs/options.md. The loader is kuna-analysis, a pinned git dependency. The evaluation is in docs/KUNA_CRATES_EVALUATION.md. Open work is BACKLOG.md, which mirrors the GitHub Issues tab.
Each release carries ag and ag-ui for Linux x86_64 and macOS arm64. Every file is signed with Sigstore cosign keyless signing: there is no private key, and the signature is bound to this repository's release workflow and recorded in the public Rekor log. Each archive also has a GitHub build-provenance attestation. To verify a download, for example v0.1.0:
cosign verify-blob SHA256SUMS --bundle SHA256SUMS.cosign.bundle \
--certificate-identity "https://github.com/CryptoJones/AdmiralGrace/.github/workflows/release.yml@refs/tags/v0.1.0" \
--certificate-oidc-issuer https://token.actions.githubusercontent.com
sha256sum -c SHA256SUMS --ignore-missing
gh attestation verify admiralgrace-v0.1.0-linux-x86_64.tar.gz -R CryptoJones/AdmiralGraceThe workspace declares the MIT license in Cargo.toml; the text is in LICENSE. The kuna crates it depends on are Apache-2.0, and NOTICE carries their attribution and Ghidra's.









