Introduction
binscout is headless, agent-first binary analysis. Open a binary — ELF, PE, Mach-O, COFF, LE, or flat raw bytes — and get functions, control-flow graphs, cross-references, strings, symbols, and IR out.
There are two interfaces over the same engine:
binscout, a JSON CLI: every command prints exactly one JSON value to stdout.binscout-mcp, an MCP server over stdio with 30 tools, one per capability (plusblocks/block_insnsfor bounded inspection,diagnostics,callees/callersfor transitive reachability,slicefor backward reachability,structure/pseudofor approximate views,bytesfor the hexdump view with typed values,search_bytes,crypto_scan,ir_coverage,flirt_hints,difffor function-level binary diff, and annotation transfer).
Annotations (function renames, free-text comments) live in a redb
sidecar next to the binary. The analyzed binary is never written.
Start with Installation, then the CLI reference.
Installation
Requires a Rust toolchain (stable).
From crates.io:
cargo install binscout
From the Git repository (latest master):
cargo install --git https://github.com/mimi1vx/binscout
Or from a checkout:
git clone https://github.com/mimi1vx/binscout
cd binscout
cargo install --path .
This installs two binaries: binscout (the JSON CLI) and binscout-mcp
(the MCP server). Verify with:
binscout --help
CLI reference
binscout [--db PATH] [--raw --arch ARCH --base ADDR [--entry ADDR]] [--fat-arch ARCH] [--pdb PATH] [--debug-file PATH] <command> <binary> [args]
--db overrides the sidecar database (default <binary>.rsdbg.redb).
--raw selects explicit raw mapping for firmware/blob workflows:
--arch is one of x86_64, x86_32, aarch64, arm32, thumb,
riscv32, riscv64, mips32, ppc32, ppc64;
--base (and optional --entry) parse as addresses. --arch/--base/--entry
without --raw are errors, as are unknown arches, unmapped or
misaligned entries, and base-plus-length overflow. Without --raw,
container auto-detection (and the raw x86-64-at-0 fallback) is
unchanged, and explicit raw mode never falls back to another mode on
failure.
--fat-arch selects a slice of a fat Mach-O container: x86_64,
x86_32, aarch64, arm32 (plus lipo aliases like arm64,
case-insensitive); it is required for fat inputs, which error
listing the available archs without it, and rejected for thin
(non-fat) inputs. --raw and --fat-arch
are exclusive. Different slices never share cached snapshots.
--pdb PATH attaches a PDB file (local path only, never fetched from
the network): public and procedure symbols seed function starts and
names for PE binaries (other containers reject it, as does --raw,
which has no image base). --debug-file PATH attaches an external
linked DWARF object (a dSYM DWARF file or an unstripped copy; local
path only, never fetched): DW_TAG_subprogram rows seed starts, ends,
and names for container and --raw opens alike. Embedded DWARF parses
automatically. Debug inputs join the snapshot identity: the same
sidecar opened with and without them re-analyzes instead of replaying
stale layouts. project_info/stats report the attached row count as
debug_funcs.
See JSON protocol for the output contract.
| Command | Example | Output |
|---|---|---|
load | binscout load fw.elf | project info (protocol, mode, arch, base, diagnostic totals, analysis_revision, debug_funcs); caches the analysis snapshot |
functions | binscout functions fw.elf --query main --limit 50 | function rows, renames resolved; --query is a case-insensitive substring over the resolved name, --caller/--callee keep call-graph neighbors of the function containing that address, --range LO HI keeps entries in the inclusive bounds; page with --offset/--limit under the protocol-1 page envelope with an exact total; rows carry the compact calls_count instead of the calls target array |
func | binscout func fw.elf 0x400000 | compact metadata: entry, name, block/insn/call counts, discovery reasons |
blocks | binscout blocks fw.elf 0x400000 --offset 0 --limit 50 | block summaries (id, start/start_hex, end/end_hex, insns count, succs) of the containing function by block start, under the page envelope |
block-insns | binscout block-insns fw.elf 0x400000 0x400000 --limit 50 | that block’s instructions in address order, under the page envelope; the block must belong to the function |
disasm | binscout disasm fw.elf 0x400000 32 | decoded instructions (addr = hex or decimal, then byte count); the valid prefix plus error_at for the first bad opcode, ranges cap at 1 MiB |
bytes | binscout bytes fw.elf 0x400000 --len 32 [--as u16] [--endian be] | raw bytes at addr (--len capped at 1 MiB, BSS tails read as zeros) with VA/file provenance (file_off null for zero-fill, section null when section-less) plus bytes_hex and typed values (u8/u16/u32/u64/ptr/cstr/utf16, le/be byte order); --as-type ADDR renders the struct fields of the stored type hint at ADDR over the range start (--len must cover the struct size) |
cfg | binscout cfg fw.elf 0x400000 | block nodes plus (from, to) edges; inferred_edges holds provenance-marked indirect-jump resolutions (single-slot absolutes and guarded scaled-index tables; raw-only, same-function); query_addr echoes the requested address |
structure | binscout structure fw.elf 0x400000 | approximate control-flow structure: syntactic loops (back-edge headers with latches) and ifs (two-successor branch sites with then/else targets) plus an approximation warning; query_addr echoes the requested address |
pseudo | binscout pseudo fw.elf 0x400000 | approximate pseudo-C of one function: one lossy C-like line per IR row plus assembled text, with an approximation warning; query_addr echoes the requested address |
callees | binscout callees fw.elf 0x400000 --depth 5 | transitive callees out to --depth hops (direct are depth 1), ordered by entry with shortest distance, under the page envelope |
callers | binscout callers fw.elf 0x400000 --depth 5 | transitive callers out to --depth hops, ordered by entry with shortest distance, under the page envelope |
slice | binscout slice fw.elf 0x400000 --depth 5 | backward slice of an address: every instruction that can reach it via xref edges (any kind) and intra-function CFG predecessors out to --depth hops (direct are depth 1, default 8, past the 64-hop cap is an Invalid error), ordered by address with shortest distance, under the page envelope; unmapped roots are a NotFound error |
diagnostics | binscout diagnostics fw.elf --kind decode-failure --func 0x400000 | provenance records (unresolved indirect sites, decode failures) ordered by (kind, addr) under the page envelope; --kind is one of unresolved-indirect-jump, unresolved-indirect-call, decode-failure, --func keeps only that function’s sites; queries never write a sidecar |
search-bytes | binscout search-bytes fw.elf "48 8B ??" --range 0x400000 0x401000 | paged ??-wildcard matches (addr/addr_hex, file_off, section, len) ordered by virtual address; --section is an exact section-name match, --range LO HI is half-open [LO, HI); scans cap at 256 MiB of mapped bytes with an explicit Limit error |
crypto-scan | binscout crypto-scan fw.elf --name aes-sbox --section .rdata | paged crypto-constant matches (addr/addr_hex, name, file_off, section, len, xrefs_count) for the static table (AES S-box/T-table, SHA-1/256 round constants, MD5/CRC-32 tables, expand 32-byte k, Blowfish P-array, TEA delta, LE/BE word orders); --name keeps one constant, --section is an exact section-name match; unreferenced short hits (notably tea-delta) read as indicative only |
xrefs | binscout xrefs fw.elf --to 0x400000 --kind code | cross-references filtered by --to/--from/--kind (code, data, string, import, inferred-code), paged with --offset/--limit under the protocol-1 page envelope (items) with an exact total; rows carry listing context (from_func/from_func_name, to_name, to_string for string-kind rows) |
strings | binscout strings fw.elf --pattern SAVE --min-len 6 | filtered strings by address (--pattern substring or regex: expression, --min-len, --section, --include-code; executable-memory hits hidden by default; paged by --start/--limit under the protocol-1 page envelope with an exact total, --offset deprecated; --decode xor:<byte>, xor:0x<HEXKEY> (rolling multi-byte key), add:<byte>, rot:<0-7>, or bare base64 re-extracts over a read-only in-memory transform with original offsets; --with-xrefs adds the bounded per-row xrefs reference list) |
stack-strings | binscout stack-strings fw.elf --offset 0 --limit 50 | recovered stack-constructed strings: runs of mov [rsp/rbp+off], imm within one block, reassembled with function and address, paged under the page envelope; read-only, never writes the binary or the sidecar |
symbols | binscout symbols fw.elf | imports, exports, and symbol-table code addresses (symbols: one name/address/address_hex row per defined text symbol, locals included, deduplicated by address); Mach-O imports carry the address/address_hex of their __stubs/__auth_stubs entry (null when unmapped), and each mapped stub seeds its own import-named function; symbol addresses seed symbol-reasoned functions named below debug-info and exports and above stubs |
sections | binscout sections fw.elf | section table: name, vaddr, in-memory/file sizes, Shannon entropy (bits per byte), permissions |
ir | binscout ir fw.elf 0x400000 32 | P-code-inspired lift of the range (error_at on trailing bad bytes, ranges cap at 1 MiB) |
ir-coverage | binscout ir-coverage x86_64 [fw.elf 0x400000 32] | machine-readable lift coverage for one arch (x86_64, x86_32, aarch64, arm32, thumb, riscv32, riscv64, mips32, ppc32, ppc64); no binary is opened without the range, which adds decoded/lifted/unlifted counts from actual lifts plus a bounded mnemonic summary |
flirt-hints | binscout flirt-hints fw.elf [--addr 0x400000] [--sigs sigs.json] | FLIRT-like library hints (read-only): corpus signature matches over each function’s leading bytes, paged under the protocol-1 envelope; --addr keeps only the containing function’s hints; --sigs adds a user signature file (our JSON, as emitted by sig-gen, or an IDA .pat file by extension); suggested names stay hints, querying never writes a sidecar |
sig-gen | binscout sig-gen fw.elf | Emit a JSON signature document for the binary’s named functions (masked leading bytes with len/crc): the --sigs input that flirt-hints reads back; read-only, never writes the binary or a sidecar |
go-funcs | binscout go-funcs fw.elf --offset 0 --limit 50 | Recover Go functions from the pclntab table (linker names plus exact entry/end ranges) for stripped Go binaries, paged under the page envelope; empty table reads as an empty page; read-only, never writes the binary or the sidecar |
stats | binscout stats fw.elf | storage stats: binary size, sidecar DB size, analysis counts |
headers | binscout headers fw.exe | header metadata: triage staples (PE timestamp/mitigations/Rich/imphash/PDB/version-info/delay-load/forwarders, ELF interp/needed/RUNPATH/RELRO/NX/PIE/build-id, Mach-O load commands/dylibs/min-OS/codesign/entitlements/UUID) plus sha256/md5; computed on demand, never persisted; querying never writes a sidecar |
annotate | binscout annotate fw.elf 0x400000 --rename main --comment "entry" | read/write annotation at an address |
type-hint | binscout type-hint fw.elf 0x400000 --json '{"kind":"struct","name":"Foo","size":8,"fields":[]}' | read/write the structured struct-layout hint at an address (--json stores, empty --json clears the hint; --get or bare reads {"addr", "addr_hex", "hint"}); same any-address, 8 KiB-cap, immediate-persist rules as comment |
define-func | binscout define-func fw.elf 0x401000 [--mode thumb] | assert “there is code here”: store a user function seed and re-analyze so the function materializes; any address accepted, undecodable seeds inert; --mode arm/thumb selects the 32-bit ARM decode (other arches reject it) |
undefine-func | binscout undefine-func fw.elf 0x401000 | assert “this isn’t a function”: exclude the seed and re-analyze; the row is kept as data |
annotations-export | binscout annotations-export fw.elf | portable annotation document (revision, sha256, size, mapping, sorted rows); read-only, never creates a sidecar |
annotations-import | binscout annotations-import fw.elf --input doc.json [--overwrite] | atomically merge a document; returns row/change counts, default fails on conflicts |
diff | binscout diff old.elf new.elf [--db-a A.redb --db-b B.redb] [--offset N --limit N] [--transfer-renames] | function-level diff between two binaries (matched/added/removed/changed with match reason, plus BinDiff-style neighbour propagation); each list pages under the protocol-1 envelope; --transfer-renames embeds the side-B rename document for annotations-import; both projects open read-only, never creating or modifying a sidecar; per-side --db-a/--db-b instead of the global --db, the global --raw mapping or --fat-arch selection (if any) applies to both |
diff-func | binscout diff-func old.elf new.elf ADDR_A ADDR_B [--db-a A.redb --db-b B.redb] | block- and instruction-level delta between two functions (blocks match by hash then by position, each matched block carries a bounded edit script); addresses snap to their containing entries; read-only like diff |
patch | binscout patch fw.elf 0x400000 --asm "jmp 0x401020" [--out fix.json --format json] | assemble replacement bytes at one x86 or aarch64 address and export the patch (va/va_hex, file_off null when not file-backed, old_hex, new_hex, size_ok); --asm takes one of nop, ret, int3, jmp ADDR, call ADDR on x86 (encoded at the address) or one of nop, ret, brk #IMM, b ADDR, bl ADDR on aarch64 (address 4-aligned, byte count a multiple of 4), --bytes takes whitespace-separated hex pairs; shorter replacements NOP-pad to the instruction boundary (x86), longer ones report size_ok: false; --out writes a json (default) or ips patch file that must differ from the binary; overflowing or non-file-backed patches refuse the file write; never writes the binary or the sidecar |
Paged lists cap at 1024 rows. Addresses accept 0x-hex or decimal
strings. func/cfg/blocks snap any address inside the function to
its containing entry (NotFound when in no function); block-insns
additionally requires its block to be a block start belonging to that
function. annotate without flags reads; --rename "" clears
the rename, omitting --comment leaves the comment alone. rename only
accepts known function entries; comment accepts any address.
define-func/undefine-func persist a seed row and re-analyze
immediately (printing {"addr", "addr_hex", "mode", "excluded"}), so the
snapshot’s derived rows always match its stored seeds; the seed set joins
analysis with the user discovery reason (see JSON
protocol).
Structured struct-layout hints (type-hint:{...}, see JSON
protocol) pass through --comment opaquely, e.g.
--comment 'type-hint:{"kind":"struct","name":"Foo","size":24,"fields":[]}'.
sections rows carry name, vaddr (the flat virtual address the loader
mapped the section at), size (in-memory bytes), file_off/file_size
(locating the raw bytes in the file), entropy (Shannon entropy of the
file-backed bytes in bits per byte, 0.0 for virtual-only sections;
values over ~7.2 with a tiny import table mark a possibly-packed section),
and readable/writable/executable.
On PE, vaddr = IMAGE_BASE + RVA: .text at RVA 0x1000 in a
0x400000-based image lives at 0x401000, with file_off pointing at its
PointerToRawData. Raw blobs have no section table and report [].
Cache identity
Snapshots are keyed by binary content, loader mapping (auto versus explicit raw arch/base/entry), and analysis revision. The same bytes opened under a different mapping re-analyze rather than reuse layouts; opening a sidecar that holds annotations under an incompatible mapping fails with a separate-DB error instead of remapping them:
$ binscout func fw.bin --db fw-mapped.redb 0x0
{"error":"storage: mapping mismatch: project db holds 1 annotation(s) under explicit raw x86_64 base 0x400000, but current open requests auto; use a separate --db PATH for this mapping (annotations are never remapped)"}
Sidecars written by older schema versions rebuild the same way: the binary re-analyzes. See Sidecar format.
JSON protocol
Every command prints exactly one JSON value to stdout and exits 0.
A runtime failure prints a single {"error": "...", "kind": "..."}
value and exits 1, so stdout is always valid JSON. (Clap usage errors
for unknown flags/subcommands still go to stderr with exit 2.) kind
is the machine-readable Error discriminant
(not_found, invalid, limit, unsupported, storage, io):
branch on it instead of parsing error, which keeps the human message
unchanged.
Real example — opening the repo’s tests/fixtures/raw-x64.bin:
$ binscout load tests/fixtures/raw-x64.bin --db /tmp/blob.redb
{"analysis_revision":15,"annotations":0,"arch":"x86_64","base":null,"base_hex":null,"binary":"tests/fixtures/raw-x64.bin","blocks":1,"content_hash":3978597713856454298,"content_hash_hex":"0x3736d18a8e985e9a","db_path":"/tmp/blob.redb","debug_funcs":0,"diagnostics":0,"diagnostics_omitted":0,"diagnostics_truncated":false,"entry":null,"entry_hex":null,"format":"raw","functions":1,"inferred_omitted":0,"inferred_truncated":false,"insns":3,"mode":"auto","protocol":1,"reason":null,"size":3,"strings":0,"supported":true,"version":"0.8.0","xrefs":0}
content_hash_hex is the exact 0x-hex twin of content_hash
(for f64-precision clients); both appear on project_info and
stats alongside content_sha256 on stats.
mode is "auto" or "raw"; base/base_hex are null in auto
mode. protocol is the wire revision below; analysis_revision is
the engine revision that produced the snapshot. diagnostics counts
retained provenance records (diagnostics_truncated plus
diagnostics_omitted when the 100,000-record cap drops rows);
inferred_truncated/inferred_omitted do the same for the
indirect-jump resolver’s edge budget.
Stability guarantees
These stability guarantees hold across wire revisions:
- One JSON value on CLI stdout per command. Runtime failure:
{"error": "...", "kind": "..."}on stdout, exit 1 (thekindvalues are frozen below; new variants only add rows). Clap usage errors (unknown flags/subcommands, unparsable numbers): stderr, exit 2. - The analyzed binary is never written. The only write target is the
redbsidecar (default<binary>.rsdbg.redb, overridable with global--db PATHon the CLI or thedbparameter on MCP tools).loadopens and saves a snapshot; every other read command opens without saving and never creates a sidecar;rename/commentpersist immediately, as dodefine-func/undefine-func(which re-analyze first so derived rows match the stored seeds). Failed validations never write. - MCP tools return one JSON document as text per call; failures are
tool errors, never silent empty results. Calls serialize behind one
lock because
redballows a single open handle per file per process. Thebatchtool is the exception that proves the rule: it still returns one document, but per-op failures are{"error"}elements of itsresultsarray (same message text the single tool would report) while only envelope misuse stays a tool error. See MCP tools.
Addresses
Address inputs accept 0x-prefixed hex (0x401000, case-insensitive
prefix) or plain decimal (4198400); surrounding whitespace is trimmed.
Anything else is an Invalid error.
Address outputs pair every integer field with its canonical 0x-hex
twin: addr/addr_hex, entry/entry_hex, from/from_hex,
vaddr/vaddr_hex, and so on. The hex form is lowercase with no
leading zeros (0x401000, 0x0 for zero). The integer keeps numeric
range queries working; the string keeps joins unambiguous. Optional
addresses stay null on both sides instead of inventing an address.
Three versions
- Crate
version(e.g."0.3.0"): the shipped software, also served via CLI--versionandproject_info. - Wire
protocol(integer, currently1): the JSON shape contract defined on this page. It appears inproject_info,stats, and every page envelope. Additive fields do not bump it; any shape change or removal does. - Sidecar schema: an internal storage detail recorded in the sidecar
metatable only. It never appears on the wire and evolves independently of both versions above.
Page envelope
New and revised paged queries share one envelope:
{"protocol": 1, "total": 0, "offset": 0, "limit": 50, "next_offset": null, "items": []}
| Field | Type | Meaning |
|---|---|---|
protocol | integer | Wire revision (see above). |
total | integer | Exact count of filter-matched rows before paging. |
offset | integer | Requested offset, echoed back. |
limit | integer | Effective limit: the requested limit clipped to the 1024-row cap. |
next_offset | integer or null | Offset for the next page, or null when there is none. |
items | array | This page’s rows, in deterministic address order. |
Rules:
- Filtering happens before paging, so
offset/limitapply to dense matching rows andtotalis the filtered count. - Rows order by primary address ascending: functions by entry, blocks
by start, instructions by address, byte-search matches by virtual
address, diagnostics by (
kind,addr). next_offsetis null when the page is exhausted (offset + limit >= total) or when the effective limit is zero; otherwise it isoffset + limitusing the effective limit.- A clipped request reports the clipped
limit, sonext_offsetarithmetic stays consistent (--limit 5000returns"limit": 1024). - An offset past the end is not an error: it returns the echoed
offset,items: [], andnext_offset: nullwith the exacttotal. - A zero limit returns the exact
total,items: [], andnext_offset: null. Pattern/filter validation still applies, so a zero-limit request with an invalid filter errors rather than returning an empty page.
Empty page — a query with no matches (diagnostics on a clean
analysis):
{"protocol": 1, "total": 0, "offset": 0, "limit": 50, "next_offset": null, "items": []}
Zero limit — the count is exact but no rows come back (blocks on a
3-block function with --limit 0):
{"protocol": 1, "total": 3, "offset": 0, "limit": 0, "next_offset": null, "items": []}
Clipped limit — --limit 5000 on 2500 byte-search matches caps at
1024 rows (first row shown, remainder omitted here):
{"protocol": 1, "total": 2500, "offset": 0, "limit": 1024, "next_offset": 1024, "items": [
{"addr": 4198400, "addr_hex": "0x401000", "file_off": 4096, "section": ".text", "len": 3}
]}
Final page — the last row of 3 (--offset 2 --limit 50;
2 + 50 >= 3, so next_offset is null):
{"protocol": 1, "total": 3, "offset": 2, "limit": 50, "next_offset": null, "items": [
{"id": "block@0x401000+0x401020", "start": 4198432, "start_hex": "0x401020", "end": 4198440, "end_hex": "0x401028", "insns": 4, "succs": [4198440]}
]}
Breaking-change boundary (protocol 1)
Intentional breaking changes, each with migration notes:
funcreturns compact metadata instead of the full block-with-instructions dump (before/after below). Useblocksplusblock_insnsfor bounded inspection;cfgremains the explicit full-graph export and can still be large.- Paged queries (
functions,strings,stack_strings,go_funcs,xrefs,blocks,block_insns,diagnostics,search-bytes,callees,callers,slice,flirt_hints) use the envelope above. project_infoandstatsgain additive fields only (protocol, mapping identity, diagnostic totals,content_hash_hexalongsidecontent_hash); no existing field changes.
Before — func today embeds every instruction of every block:
{"id": "func@0x401000", "entry": 4198400, "entry_hex": "0x401000",
"containing_entry": 4198400, "containing_entry_hex": "0x401000",
"name": "main",
"blocks": [{"id": "block@0x401000+0x401000", "start": 4198400, "start_hex": "0x401000",
"end": 4198403, "end_hex": "0x401003",
"insns": [/* every decoded instruction */], "succs": []}],
"edges": [], "calls": [4198400]}
After — func is a bounded summary. blocks/insns are counts,
calls is a count (not the unbounded target array),
inferred_edges counts provenance-marked indirect-jump resolutions in
that function, and reasons is the sorted, deduplicated discovery
vocabulary (entry, export, symbol, direct-call, prologue,
debug — DWARF/PDB rows, see below — user for agent-defined seeds,
see define-func below; pdata, tls-callback, init-array,
function-starts, and pointer cover the remaining table-derived and
opt-in seed sources).
The redundant containing_entry twin is dropped; any interior address
still snaps to the canonical entry:
{"id": "func@0x401000", "entry": 4198400, "entry_hex": "0x401000",
"name": "main", "blocks": 1, "insns": 3, "calls": 0,
"inferred_edges": 0, "reasons": ["entry"], "noreturn": false}
Function rows (the functions list, func detail, and
func-meta) carry an additive noreturn
bool: true when no path from the entry reaches a return. Calls to
known-noreturn imports (exit, abort, ExitProcess, and similar)
cut the fall-through CFG edge and record a noreturn-cut diagnostic;
wrappers around them propagate to a bounded fixpoint.
Explicitly unchanged in this contract (no style churn): the
functions list pages under the envelope with --offset/--limit
(--envelope/envelope are accepted but ignored, compact
calls_count rows, see migration); xrefs pages
under the envelope with items (rows gain the additive from_func/
from_func_hex/from_func_name/to_name/to_string context fields,
no existing field changes); the strings list pages under the
envelope with --start/--limit (--offset stays a deprecated
alias that warns on stderr; --envelope/envelope are accepted but
ignored; --with-xrefs adds the bounded per-row xrefs reference list, omitted
without the flag);
symbols exports keep their shape while imports carry additive
address/address_hex (the call pointer: the Mach-O __stubs entry,
the PE IAT slot, the ELF GOT slot named by .rela.plt/.rel.plt
R_*_JUMP_SLOT relocations; null when unmapped), disasm/block-insns
rows carry an additive import name when the instruction calls through an
import slot or stub plus the additive target_name/comment/string
listing annotations (target display name with a func@0x... fallback
for code targets, the annotation at the row address, and the referenced
string preview), and pseudo lines carry the same additive import
name plus the same target_name/comment/string fields, with callee
names and string literals rendered into the line text; xrefs gains the additive import kind for call sites through
an import slot or stub (alongside the retained data/code rows); a third additive array, symbols, carries one
name/address/address_hex row per defined text symbol from the
object symbol tables (locals included, deduplicated by address, Thumb
bit cleared on ARM). Symbol addresses seed analysis as
symbol-reasoned functions; per-address naming resolves export >
debug > symbol > stub import, with annotation renames winning over all
four at display time. Debug-info rows (DWARF DW_TAG_subprogram from
embedded sections or --debug-file, PDB publics/procedures from
--pdb) seed debug-reasoned functions with exact names and optional
ends; project_info/stats report their count as debug_funcs. sections, disasm/ir with error_at and the 1 MiB
range cap; cfg node/edge shape (plus the additive query_addr echo of
the requested address on cfg/structure/pseudo); annotate read/write semantics
(rename only on known function entries, comment on any address,
empty string clears, 8 KiB text cap); all exit codes and error
channels. The 0.9.0 alignment of the grandfathered list shapes
shipped at protocol 1: same envelope, additive rows, no bump.
Query contracts
B is the binary path; every binary-taking operation also accepts the
common --db PATH / db sidecar override and the raw-mapping options.
Raw mapping
Opt-in firmware/raw workflow. CLI global flags (like --db):
binscout [--db PATH] [--raw --arch ARCH --base ADDR [--entry ADDR]] [--fat-arch ARCH] <command> B [...]
MCP: optional raw: {"arch": ..., "base": ..., "entry"?} object on
every binary-taking tool. arch is one of x86_64, x86_32,
aarch64, arm32, thumb, riscv32, riscv64, mips32, ppc32, ppc64; base/entry parse as addresses.
arch and base are required in raw mode; raw-only options without
--raw/raw are errors, as are unknown arches, unmapped or
misaligned entries, and base-plus-length overflow. Without raw mode,
auto-detection and the raw x86-64-at-0 fallback are unchanged.
Explicit raw mode never falls back to another mode on failure.
project_info reports the effective mapping: mode ("auto" or
"raw") plus base/base_hex (null in auto mode); arch,
format, and entry/entry_hex keep their current fields.
$ binscout --raw --arch x86_64 --base 0x400000 load tests/fixtures/raw-x64.bin --db /tmp/raw.redb
{"analysis_revision":15,"annotations":0,"arch":"x86_64","base":4194304,"base_hex":"0x400000","binary":"tests/fixtures/raw-x64.bin","blocks":1,"content_hash":3978597713856454298,"content_hash_hex":"0x3736d18a8e985e9a","db_path":"/tmp/raw.redb","debug_funcs":0,"diagnostics":0,"diagnostics_omitted":0,"diagnostics_truncated":false,"entry":null,"entry_hex":null,"format":"raw","functions":1,"inferred_omitted":0,"inferred_truncated":false,"insns":3,"mode":"raw","protocol":1,"reason":null,"size":3,"strings":0,"supported":true,"version":"0.8.0","xrefs":0}
Same bytes under a different mapping never reuse cached layouts: the open re-analyzes. A sidecar holding annotations opened under an incompatible mapping fails with a separate-DB error instead of remapping them (see CLI reference).
Fat Mach-O containers need --fat-arch ARCH (CLI) or fat_arch
(MCP, on every binary-taking tool): x86_64, x86_32, aarch64,
arm32, plus lipo aliases like arm64, case-insensitive.
Without it a fat input errors listing the available archs; --raw
and --fat-arch are exclusive. Supplying --fat-arch/fat_arch
for thin (non-fat) input is an Invalid error, never silently
ignored. Slice spellings canonicalize (arm64 ≡ aarch64,
x86-64 ≡ x86_64, case-insensitive), so either spelling shares
one snapshot. project_info reports mode
"fat" with a null base, and slices never share snapshots.
blocks / block_insns
binscout blocks B ADDR [--offset N] [--limit N]
binscout block-insns B ADDR BLOCK [--offset N] [--limit N]
MCP tools blocks (binary, db?, raw?, addr, offset?,
limit?) and block_insns (plus block: the block start address).
ADDR snaps to its containing function (NotFound when in no
function); BLOCK must be a block start belonging to that function
(NotFound otherwise). blocks pages BlockSummary rows
(id, start/start_hex, end/end_hex, insns count, succs)
by start; block_insns pages that block’s instructions in address
order. Both use the page envelope; per-page work scales with the
page, never with whole-function size. Every instruction row carries
the render-time listing annotations (never stored, omitted when
absent): target_name (branch target’s display name, else the data
target’s; rename wins over symbol-table and import names, code targets
fall back to func@0x...), comment (the annotation at the row
address), and string (the referenced string preview, escaped and
clipped to 64 characters). An adrp pair split by a page boundary
resolves from the page’s own rows only.
callees / callers
binscout callees B ADDR [--depth N] [--offset N] [--limit N]
binscout callers B ADDR [--depth N] [--offset N] [--limit N]
MCP tools callees/callers (binary, db?, raw?, addr,
depth?, offset?, limit?). ADDR snaps to its containing
function (NotFound when in no function); depth bounds the walk to
that many call edges (direct neighbors are depth 1, zero yields an
empty page, past the 64-hop cap is an Invalid error). Items order by
entry with the shortest distance in depth plus the rename-resolved
name and the entry/entry_hex twins, paged under the envelope;
querying never writes a sidecar.
slice
binscout slice B ADDR [--depth N] [--offset N] [--limit N]
MCP tool slice (binary, db?, raw?, addr, depth?,
offset?, limit?). Any mapped address is a valid
root (data/string targets lie in no function, which is still a valid
root, not an error); unmapped roots are a NotFound error. depth
bounds the reverse walk over xref edges of every kind plus
intra-function CFG predecessors to that many hops (direct
predecessors are depth 1, zero yields an empty page, past the 64-hop
cap is an Invalid error); it defaults to 8 when omitted.
Items order by address with the shortest distance in depth, each
carrying addr/addr_hex, the containing function (func/func_hex,
null when in no function) plus its rename-resolved name, paged under
the envelope; querying never writes a sidecar.
structure
binscout structure B ADDR
MCP tool structure (binary, db?, raw?, addr). ADDR snaps to
its containing function (NotFound when in no function). The result
carries entry/entry_hex plus structure: syntactic loops
(back-edge targets as header/header_hex with sorted latches) and
ifs (two-successor CBranch sites with cond and taken/fallthrough
then_target/else_target twins) with a top-level warning
(approximate ...; not a decompiler). Loops are direct-CFG back edges
found by one deterministic DFS; ifs need a CBranch lift plus exactly
two direct successors; inferred single-slot edges never participate.
Read-only: querying never writes a sidecar.
pseudo
binscout pseudo B ADDR
MCP tool pseudo (binary, db?, raw?, addr). ADDR snaps to
its containing function (NotFound when in no function). The result
carries entry/entry_hex plus pseudo: one lossy C-like lines row
per IR lift (addr/addr_hex, text, propagated warning) and the
assembled text ({addr:#x}: {text} rows) with a top-level warning
(approximate ...; not a decompiler). Data operations keep operand
strings verbatim inside assignments or OP(args) calls; control renders
as goto/if/call/return over direct targets (indirect sites keep
operands, except indirect calls through a known import, which render
under the import name). Direct call/branch targets render under their
display name (call strcpy();, rename wins over symbol-table and
import names, code targets fall back to func@0x...); data references
append their string preview as // "..." and annotations append as
// .... Lines also carry the additive target_name/comment/
string fields (omitted when absent). Read-only: querying never writes
a sidecar.
diagnostics
binscout diagnostics B [--kind KIND] [--func ADDR] [--offset N] [--limit N]
MCP tool diagnostics (binary, db?, raw?, kind?, func?,
offset?, limit?). kind is one of unresolved-indirect-jump,
unresolved-indirect-call, noreturn-cut, decode-failure; anything else is an
Invalid error. func snaps to its containing function and keeps
only that function’s sites (NotFound when in no function). Items
order by (kind, addr); each row carries kind, addr/addr_hex,
and the containing function entry (or null) plus kind-specific
detail. Filtering precedes pagination under the page envelope, and
querying never writes a sidecar. Compact func rows carry the
reasons set; project_info/stats gain diagnostics (retained
record count), diagnostics_truncated (bool),
diagnostics_omitted (rows dropped at the record cap), and
analysis_revision. Zero retained diagnostics is not proof of
complete recovery.
flirt-hints
binscout flirt-hints B [--addr ADDR] [--sigs SIGS] [--offset N] [--limit N]
MCP tool flirt_hints (binary, db?, raw?, addr?, sigs?,
offset?, limit?). Each row pairs a function entry (entry/entry_hex) with
the matched corpus signature id, its suggested_name, and the
reason that keeps the row a hint rather than an identity. addr
snaps to its containing function and keeps only that function’s hints
(NotFound when in no function). sigs adds a user signature file:
our JSON document (as emitted by sig-gen, validated: len/crc
must agree, patterns cap at the 32-byte match window, unset arch means
any-x86) or an IDA .pat file (by extension; head bytes and primary
name only, crc/references/tail ignored). Suggested names are never applied:
renaming stays an explicit rename/annotate write. Querying never
writes a sidecar.
sig-gen
binscout sig-gen B
MCP tool sig_gen (binary, db?, raw?). Emits the JSON signature
document for the binary’s named functions ({"version": 1, "signatures": [{"name", "arch", "bytes", "len", "crc"}]}): masked
leading bytes (?? where a call/jump displacement or a mapped-memory
data address varies per build), the rename-resolved name, and the
len/crc integrity pair that --sigs revalidates. Unnamed,
too-short, or all-masked functions are skipped; identical shapes keep
only the lowest entry’s name. Read-only: never writes the binary or
the sidecar.
go-funcs
binscout go-funcs B [--offset N] [--limit N]
MCP tool go_funcs (binary, db?, raw?, offset?,
limit?). Recovers Go functions from the pclntab table (f0/f1/fa/fb magics for Go 1.18+ back
to 1.2, little-endian): linker names plus exact entry/end ranges from
functab/funcnametab, in functab order, paged under the envelope.
Prefers the .gopclntab section and otherwise scans readable segments
for the magic, so stripped (section-less) binaries still resolve; 1.18+ PCs anchor at
the .text VA (or the lowest executable segment). No located
table reads as an empty items page, not a bare []; a located-but-corrupt table (or a big-endian table)
errors. Read-only: never writes the binary or the sidecar.
ir-coverage
binscout ir-coverage ARCH [B ADDR LEN]
MCP tool ir_coverage (arch, binary?, db?, addr?, len?):
no binary is opened unless a range is given, and a range requires all
of binary/addr/len. The response names the arch, the
implemented opcode families, the explicitly partial mappings, and the
limitations (operand strings, flags, stack/calling-convention
effects, no SSA/PHI production); unknown mnemonics stay a NOP with
a warning, distinguishable from a genuine NOP. With a range, it
adds per-range decoded/lifted/unlifted counts from actual lift
results plus a bounded mnemonic summary. (ARCH is positional on the
CLI because --arch is the global raw-mapping flag.)
xrefs
binscout xrefs B [--to ADDR] [--from ADDR] [--kind KIND] [--offset N] [--limit N]
MCP tool xrefs (binary, db?, raw?, to?, from?, kind?,
offset?, limit?). kind is one of code, data, string,
import, inferred-code (case-insensitive); anything else is an
Invalid error. Filtering precedes pagination under the page
envelope with items; an offset past the end is a normal
empty page. Every row carries the stored triple (from/from_hex,
to/to_hex, kind) plus additive listing context, so agents skip
the follow-up lookups: from_func/from_func_hex (the entry of the
function containing from, null when in no function) with its
rename-resolved from_func_name, to_name (the rename-resolved
display name of the target: function or import; code targets fall back
to func@0x..., unresolvable data targets stay null), and to_string
(the truncated string preview, only for string-kind rows). The
context builds once per call and rows reuse the sorted xref storage
plus binary searches, so per-page work scales with the page.
$ binscout xrefs tests/fixtures/pe32-basic.exe --to 0x402100 --kind string --limit 2 --db /tmp/p.redb
{"items":[{"from":4198403,"from_func":4198400,"from_func_hex":"0x401000","from_func_name":"basic_entry","from_hex":"0x401003","kind":"String","to":4202752,"to_hex":"0x402100","to_name":null,"to_string":"SAVE%d.GAM is invalid"},{"from":4198408,"from_func":4198400,"from_func_hex":"0x401000","from_func_name":"basic_entry","from_hex":"0x401008","kind":"String","to":4202752,"to_hex":"0x402100","to_name":null,"to_string":"SAVE%d.GAM is invalid"}],"limit":2,"next_offset":null,"offset":0,"protocol":1,"total":2}
strings
binscout strings B [--pattern P] [--min-len N] [--section S] [--include-code] [--with-xrefs] [--decode SPEC] [--start N] [--limit N]
MCP tool strings (binary, db?, raw?, pattern?, min_len?,
section?, include_code?, decode?, with_xrefs?, start?,
limit?). Rows page under the envelope with an exact total.
Without --with-xrefs rows are the string hits
(offset, vaddr/vaddr_hex, encoding, value, section,
executable); with it, every row additionally carries xrefs: the
instructions referring to that string’s start, each with
from/from_hex, kind, and the containing function
(from_func/from_func_hex plus its rename-resolved
from_func_name). The list is the same rows
xrefs --to <vaddr> --kind string reports, capped at 64 refs per row
in (from, kind) order, so one call replaces the strings then
xrefs --to --kind string round-trip. --decode and --with-xrefs
compose: decoded hits keep their original offsets, and references
resolve against the original xref set at the same addresses.
search-bytes
binscout search-bytes B PATTERN [--section S] [--range LO HI] [--offset N] [--limit N]
MCP tool search_bytes (binary, db?, raw?, pattern,
section?, range_lo?, range_hi?, range_start?, range_end?,
offset?, limit?). range_lo/range_hi bound the inclusive
[lo, hi] range; range_start/range_end bound the half-open
[lo, hi) range. Give exactly one pair per call: mixing the pairs is
an error, and each pair must be given together. functions offers
the same two spellings with the same inclusive/half-open meanings,
over entries rather than match addresses; see migration.
PATTERN is a positional whitespace-separated full-byte token
string, each two hex digits (case-insensitive) or a ?? wildcard
(e.g. 48 8B ?? ??). Empty, all-wildcard, odd-length, non-hex, or
over-4096-byte patterns are Invalid errors. --range is half-open
[LO, HI) over virtual addresses (unlike the inclusive --range on
functions); --section is an exact section-name match. Matches
report addr / addr_hex, file_off (null when unavailable),
section (null when unmapped to a named section), and match len,
ordered by virtual address with overlapping matches included. Gaps
between mappings are never bridged, virtual BSS is never
materialized, and scans past 256 MiB of unique file-backed mapped
bytes fail with Limit instead of truncating silently. Results page
under the envelope (capped at 1024 rows); the exact total may
require a full bounded scan.
$ binscout search-bytes fw.bin 90 --range 0x0 0x2
{"items":[{"addr":0,"addr_hex":"0x0","file_off":0,"len":1,"section":null},{"addr":1,"addr_hex":"0x1","file_off":1,"len":1,"section":null}],"limit":50,"next_offset":null,"offset":0,"protocol":1,"total":2}
bytes
binscout bytes B ADDR --len N [--as VIEW] [--endian le|be]
MCP tool bytes (binary, db?, raw?, addr, len, as?,
endian?). Reads len bytes at addr with the same 1 MiB range cap
as disasm/ir (empty and over-cap ranges error; unmapped ranges
are NotFound): BSS/zero-fill tails read as zeros. as selects the
typed values decoding (u8 default; u16, u32, u64, ptr
for pointer-width integers, cstr for one NUL-terminated lossy UTF-8
string, utf16 for one NUL-terminated lossy UTF-16 string);
endian (le default, be) orders multi-byte units. Trailing
partial units are dropped. Integer views (u8/u16/u32/u64/ptr)
carry values_hex: the exact 0x-hex twin of each decoded values
entry (absent on the cstr/utf16 string views). file_off is the range start’s file
offset (null when the start byte is zero-fill or otherwise
unbacked); section is the covering file-backed section name (null
for zero-fill and section-less ranges); bytes_hex is the range as
continuous lowercase hex. The provenance converts either direction
(file_off_of for VA-to-offset, va_of_file_off for the reverse;
raw mappings use the blob offset). Querying never writes a sidecar.
$ binscout bytes fw.elf 0x401000 --len 3 --as u16 --endian be
{"addr":4198400,"addr_hex":"0x401000","bytes_hex":"5589e5","file_off":512,"len":3,"section":".text","values":[21897],"values_hex":["0x5589"]}
headers
binscout headers B
MCP tool headers (binary, db?, raw?). On-demand header
metadata: triage staples plus file hashes, parsed from the container
bytes on every call and never persisted. Reads never save or create a
sidecar. The top level carries protocol, the detected container
format (pe/elf/macho/coff/le/raw), size, sha256 (the
project’s content identity) and md5 (hex, e.g. for VirusTotal
lookups); exactly one of pe/elf/macho is non-null. Unknown
fields degrade to null/empty rather than erroring, and every string
clips to 256 characters with per-list caps, so hostile headers cannot
blow up the document (additive-only: the wire protocol is unchanged).
pe:timestamp(TimeDateStamp),subsystemplussubsystem_name,dll_characteristicsplus decodedaslr(DYNAMIC_BASE),dep(NX_COMPAT),cfg(GUARD_CF) andhigh_entropy_vamitigations,rich(present, up to 256entriesofcomp_id/count,md5over the unmasked entries),imphash(lowercaselibrary.namepairs in table order, comma-joined, MD5-hashed; ordinal-only imports render aslibrary.N; null when there are no imports),authenticode(present,size),pdb(path,guid,age, null when no CodeView record),version_info(present,file_versionlike"1.2.3.4"),delay_load(libraries with boundedfunctionspluscount) andexport_forwarders(name/forwardrows for RVAs landing inside the export directory).elf:interp(PT_INTERP, null for static binaries),needed(DT_NEEDED),runpath/rpath,relro(none/partial/full:PT_GNU_RELROplusDF_BIND_NOW/DF_1_NOWfor full),nx(PT_GNU_STACKwithout the execute flag; false when the segment is absent),pie(ET_DYNwith an interpreter),build_id(hex, fromPT_NOTE),stripped(no.symtabsection).macho:commands(load-command names in order),dylibs(LC_LOAD_DYLIB-family names),platform,min_os/sdk(LC_BUILD_VERSIONpreferred, elseLC_VERSION_MIN_*),uuid,code_signature(present,size) andentitlements(present,size, from slot 5 of the signature superblob). Fat containers report the slice matching the loaded arch.
MD5 and imphash/Rich hashes are fingerprints, never security controls,
and are implemented inline so no new dependency enters the supply chain;
tlsh/ssdeep stay out for the same reason (new deps need a
deny.toml review first).
annotations-export / annotations-import
binscout annotations-export B
binscout annotations-import B --input PATH [--overwrite]
MCP tools annotations_export (binary, db?, raw?) returning
the document, and annotations_import (binary, db?, raw?,
document, overwrite?) taking it. The export is read-only and
capped at 16 MiB serialized:
{"revision": 1, "sha256": "…64 hex…", "size": 3,
"mapping": {"mode": "auto"},
"annotations": [{"addr": 4198400, "rename": "main"}],
"func_seeds": [{"addr": 4198404, "excluded": false}]}
Rows sort by address and only nonempty annotations appear; unset
fields are omitted (no nulls). Seed rows export in func_seeds,
including excluded rows (excluded: true; the row’s mode, if any,
is "arm" or "thumb"). Host paths and analysis snapshots are
excluded. Under explicit raw mapping the document records
"mapping": {"mode": "explicit", "arch": "x86_64", "base": 4194304, "entry": null}. Import validates the whole document before a single
atomic write: identity (sha256 + size + mapping) must match
exactly, duplicate addresses and oversized documents are rejected,
rename targets must be known function entries while comments and
seed rows keep the any-address contract (seed modes are restricted to
32-bit ARM projects). Importing changed seeds re-analyzes before
saving, so derived rows match the stored seeds. Default merge fails on
differing existing field values (equal values are idempotent);
--overwrite replaces supplied fields only, absent fields leave
existing values alone, and empty strings clear. Untouched annotations
remain; a failure in the last row leaves the DB unchanged. Import
returns merge counts:
{"rows": 2, "changed": 1}
define-func / undefine-func
binscout define-func B ADDR [--mode arm|thumb]
binscout undefine-func B ADDR
MCP tools define_func (binary, db?, raw?, addr, mode?)
and undefine_func (binary, db?, raw?, addr). define-func
asserts “there is code at ADDR” (shellcode, firmware vectors,
obfuscated code, missed callbacks): the address joins the
authoritative seed set with the user discovery reason, and the
project re-analyzes immediately so the function materializes when the
bytes decode. undefine-func asserts “this isn’t a function”: the
address is excluded from seeding (kept as data) and the project
re-analyzes. Both accept any address — undecodable seeds are inert,
never errors — and both persist a full snapshot rewrite at once, so
the stored seeds hash always matches the derived rows. --mode
selects the 32-bit ARM decode for the seed’s function (thumb
decodes Thumb code inside an arm32 project and vice versa); other
architectures reject it. On success both print the seed row:
{"addr": 4198404, "addr_hex": "0x401004", "mode": "thumb", "excluded": false}
Type-hint comments (hint only, no type system)
Struct-layout/sizeof metadata travels in the comment channel as a
type-hint:-prefixed JSON comment, e.g.
type-hint:{"kind":"struct","name":"Foo","size":24, "fields":[{"name":"a","offset":0,"size":8}]}. Hints store via
annotate --comment / comment / set_type_hint under the same
any-address, 8 KiB-cap rules as any comment, survive export/import as
opaque strings, and are never validated against the binary: a wrong
hint misleads exactly like a wrong free-text comment. Readers parse
them with annotations::parse_type_hint / Project::type_hint_at
(wire JSON in and out via annotations::parse_type_hint_json /
annotations::type_hint_json / Project::set_type_hint_json);
ordinary comments without the prefix decode to “no hint”, never an
error. Free text may follow the hint’s first line. Raw type-hint:
comments written before the dedicated surface keep working: they read
back through type-hint --get / get_type_hint unchanged.
The dedicated surface is binscout type-hint B ADDR --json '{...}'
to store (empty --json clears the hint, leaving plain comments
alone) and binscout type-hint B ADDR --get to read (bare
type-hint reads too; --json with --get is an error); MCP mirrors
it with set_type_hint (hint string, empty clears) and
get_type_hint. Both return {"addr", "addr_hex", "hint"} where
hint is the wire {"kind":"struct",..} object or null, and both
persist exactly like comment. bytes B ADDR --len N --as-type H
renders the hint stored at H as struct fields over the range start
(--len must cover the struct size; extra bytes read normally; each
field carries its own addr/addr_hex twins, bytes_hex, and the
endian-decoded integer value with its exact 0x-hex twin
value_hex (both null past 8 bytes). pseudo and
disasm do not consume hints yet: [reg+off] stays unannotated until
the structured-IR work this rendering depends on lands.
Inferred edges (indirect-jump resolver)
Two conservative indirect-jump patterns resolve to real edges,
both in explicit raw mappings with targets on executable mapped
bytes in the same function: a single-slot absolute indirect jump
(x86-32 jmp m32 through an absolute slot, x86-64 jmp m64
through a RIP-relative slot), and a guarded scaled-index table
(jmp [index*scale+base], x86-only: scale 4 on x86-32, scale 8
on x86-64) behind a direct conditional bound-check guard within
4 decoded predecessors. Everything else — unguarded indexes,
cross-function targets, truncated or unmapped slots,
non-executable targets, container (non-raw) binaries — keeps
its unresolved-indirect-jump diagnostic and stays edgeless, e.g.:
{"addr": 4194304, "addr_hex": "0x400000", "detail": "indirect jump without a direct target; the site stays edgeless", "func": 4194304, "func_hex": "0x400000", "kind": "unresolved-indirect-jump"}
Resolved edges carry their provenance separately from direct flow:
cfg lists them in inferred_edges (never in edges), compact
func counts them in inferred_edges, and xrefs tags them
inferred-code alongside the Data xref into the slot:
{"containing_entry": 4194304, "containing_entry_hex": "0x400000", "edges": [], "entry": 4194304, "entry_hex": "0x400000", "inferred_edges": [[4194304, 4194322]], "nodes": [{"end": 4194310, "end_hex": "0x400006", "insns": 1, "start": 4194304, "start_hex": "0x400000", "succs": []}, {"end": 4194325, "end_hex": "0x400015", "insns": 3, "start": 4194322, "start_hex": "0x400012", "succs": []}]}
{"items": [
{"from": 4194304, "from_hex": "0x400000", "kind": "Data", "to": 4194314, "to_hex": "0x40000a"},
{"from": 4194304, "from_hex": "0x400000", "kind": "inferred-code", "to": 4194322, "to_hex": "0x400012"}]}
Caps: one edge per single-slot site and 2–8 consecutive valid
slots per table site (a singleton run is a stray pointer; a run
still valid at 8 slots is open-ended, so the site stays
unresolved rather than partially recovered); 100,000 recovered
edges per project. When
the project budget exhausts, the site stays unresolved with its
diagnostic retained and the excess counted in inferred_omitted
with inferred_truncated set — never silently clipped from the
inferred graph.
Import call sites
Indirect calls through a PE IAT or ELF GOT slot (call [slot],
jmp [slot], including bnd-prefixed and CET-endbr PLT shapes)
and direct calls to ELF PLT stubs (sym@plt functions) or PE import
thunks resolve to import-kind xrefs whose to is the import’s slot
address — the same address the symbols import row carries:
{"items": [
{"from": 4198400, "from_hex": "0x401000", "kind": "Data", "to": 4202496, "to_hex": "0x402100"},
{"from": 4198400, "from_hex": "0x401000", "kind": "Import", "to": 4202496, "to_hex": "0x402100"}]}
The data row (indirect sites) and the code row (direct stub
calls) are retained alongside, so import rows are purely additive;
xrefs --to <slot> --kind import lists exactly the import’s
callers. disasm/block-insns rows and pseudo lines at such
sites carry the additive import name. Import rows share the
1,000,000-per-kind xref budget with their own cap. Uncalled PLT
stubs seed no function: with no caller there is nothing to xref.
patch
binscout patch B ADDR --asm "jmp 0x401020" | --bytes "90 90" [--out fix.json --format json]
MCP tool patch (binary, db?, raw?, addr, asm?/bytes?,
out?, format?). Assembles replacement bytes at one x86 or
aarch64 address
and exports the patch without writing the binary. Exactly one of
asm (x86: one of nop, ret, int3, jmp ADDR, call ADDR;
aarch64: one of nop, ret, brk #IMM, b ADDR, bl ADDR;
encoded
at the address so branch displacements are exact) or bytes
(whitespace-separated hex pairs) is required. The first decode at
the address sets the instruction boundary: shorter replacements
NOP-pad to it, longer ones report size_ok: false. Aarch64
replacements must be a multiple of 4 bytes at a 4-aligned address.
file_off is
the file offset (null when the address is not file-backed);
non-x86/non-aarch64 binaries are Unsupported, undecodable or unmapped
addresses error. out writes the patch as json (default: the
preview fields plus arch) or ips (PATCH + one 24-bit-offset
record + EOF); the path must differ from the binary, and
overflowing or non-file-backed previews refuse the file write. The
binary and the sidecar are never written; patch is rejected in
batch.
$ binscout patch fw.elf 0x401000 --bytes "90 90"
{"va":4198400,"va_hex":"0x401000","file_off":512,"old_hex":"5589e5","new_hex":"9090","size_ok":true}
Errors and validation
Library variants, their machine-readable kind, and their surfaces.
Every MCP tool error carries {"kind": ...} in the JSON-RPC error
data, so agents branch on kind instead of parsing the message:
not_found (retry with a snapped address), limit (narrow the
query), unsupported (give up).
Error | kind | CLI | MCP |
|---|---|---|---|
NotFound (not found: …) | not_found | {"error", "kind"}, exit 1 | resource_not_found |
Unsupported (unsupported: …) | unsupported | {"error", "kind"}, exit 1 | internal_error |
Invalid (invalid opcode: …) | invalid | {"error", "kind"}, exit 1 | invalid_params |
Limit (limit exceeded: …) | limit | {"error", "kind"}, exit 1 | invalid_params |
Storage (storage: …) | storage | {"error", "kind"}, exit 1 | internal_error |
Io (io: …) | io | {"error", "kind"}, exit 1 | internal_error |
Validation rules: bad addresses, unknown xref/diagnostic kinds,
overlong or uncompilable string patterns, malformed byte-search
patterns, unmapped or over-cap (> 1 MiB) decode/byte ranges, unknown
functions/blocks, rename of a non-entry, seed modes off 32-bit ARM,
over-8 KiB annotation text, raw-option misuse, and annotation identity/conflict
failures all error as above without writing. Clipping a limit to 1024 rows,
paging past the end, and zero limits are normal pages, not errors.
Non-numeric --offset/--limit values never reach validation:
clap rejects them on stderr with exit 2.
Migration guidance
This release changes the default func response, adds bounded
inspection views, and ships explicit raw mapping, fat Mach-O slice
selection, Mach-O stub-to-import mapping, ARM64 adrp-pair resolution,
diagnostics,
IR coverage, byte search, a hexdump view with typed values (bytes),
annotation transfer, and a raw-only
indirect-jump resolver (single-slot absolutes plus guarded
scaled-index tables). Everything below runs as shown against
the current binaries.
Tool count and versions
The MCP server exposes 41 tools: project_info, load, functions,
func, blocks, block_insns, diagnostics, disasm, bytes, cfg,
structure, pseudo, callees, callers, slice,
xrefs, strings, symbols, stats, sections, headers, ir,
ir_coverage, flirt_hints, sig_gen, go_funcs, rename, comment, annotation,
set_type_hint, get_type_hint,
define_func, undefine_func, search_bytes, crypto_scan,
annotations_export, annotations_import, diff, diff_func, stack_strings, batch. The CLI has the same
capabilities as 36 subcommands (load covers project_info;
annotate covers rename/comment/annotation); the MCP load tool is the
sidecar-warming counterpart of the CLI load.
Three versions move independently:
- Crate
version(e.g."0.3.0"): the shipped software. - Wire
protocol(currently1): the JSON shape contract. It appears inproject_info,stats, and every page envelope. - Sidecar schema (currently 5) and analysis revision (currently 5): internal storage details. They never appear on the wire; a stored mismatch re-analyzes instead of replaying layouts.
func before and after
func used to embed every instruction of every block plus the full
edge list and call-target array. It now returns compact metadata;
page the details with blocks and block_insns, or export the
full graph explicitly with cfg (which can still be large):
$ binscout --raw --arch x86_64 --base 0x400000 func blob.bin --db /tmp/blob.redb 0x400000
{"blocks":2,"calls":0,"entry":4194304,"entry_hex":"0x400000","id":"func@0x400000","inferred_edges":1,"insns":4,"name":null,"reasons":["entry"]}
$ binscout --raw --arch x86_64 --base 0x400000 blocks blob.bin --db /tmp/blob.redb 0x400000
{"items":[{"end":4194310,"end_hex":"0x400006","id":"block@0x400000+0x400000","insns":1,"start":4194304,"start_hex":"0x400000","succs":[]},{"end":4194325,"end_hex":"0x400015","id":"block@0x400000+0x400012","insns":3,"start":4194322,"start_hex":"0x400012","succs":[]}],"limit":50,"next_offset":null,"offset":0,"protocol":1,"total":2}
$ binscout --raw --arch x86_64 --base 0x400000 block-insns blob.bin --db /tmp/blob.redb 0x400000 0x400000
{"items":[{"addr":4194304,"addr_hex":"0x400000","branch_target":null,"branch_target_hex":null,"bytes":[255,37,4,0,0,0],"mem_target":4194314,"mem_target_hex":"0x40000a","mnem":"jmp","ops":["qword ptr [0x40000a]"],"size":6}],"limit":50,"next_offset":null,"offset":0,"protocol":1,"total":1}
reasons names how the function was discovered (entry,
export, direct-call, prologue); it is evidence, not a
confidence score. Any address inside the function snaps to its
containing entry. blocks and block_insns share the page
envelope (protocol, total, offset, limit, next_offset,
items) with diagnostics and search-bytes; limits clip to
1024 rows.
Raw mapping and cache identity
Firmware and blob workflows pass the mapping explicitly on every
binary-taking command (CLI flags or the MCP raw object):
$ binscout --raw --arch x86_64 --base 0x400000 load tests/fixtures/raw-x64.bin --db /tmp/blob.redb
{"analysis_revision":15,"annotations":0,"arch":"x86_64","base":4194304,"base_hex":"0x400000","binary":"tests/fixtures/raw-x64.bin","blocks":1,"content_hash":3978597713856454298,"content_hash_hex":"0x3736d18a8e985e9a","db_path":"/tmp/blob.redb","debug_funcs":0,"diagnostics":0,"diagnostics_omitted":0,"diagnostics_truncated":false,"entry":null,"entry_hex":null,"format":"raw","functions":1,"inferred_omitted":0,"inferred_truncated":false,"insns":3,"mode":"raw","protocol":1,"reason":null,"size":3,"strings":0,"supported":true,"version":"0.8.0","xrefs":0}
arch is one of x86_64, x86_32, aarch64, arm32, thumb,
riscv32, riscv64, mips32, ppc32, ppc64;
arch and base are required in raw mode, and raw-only options
without --raw/raw are errors — as are unknown arches, unmapped
or misaligned entries, and base-plus-length overflow. Without raw
mode, container auto-detection is unchanged.
Cache identity covers binary content, loader mapping, and analysis
revision: the same bytes opened under a different mapping
re-analyze rather than reuse layouts. A sidecar holding
annotations opened under an incompatible mapping fails instead of
remapping them — keep one --db PATH per mapping:
$ binscout func blob.bin --db /tmp/blob.redb 0x0
{"error":"storage: mapping mismatch: project db holds 1 annotation(s) under explicit raw x86_64 base 0x400000, but current open requests auto; use a separate --db PATH for this mapping (annotations are never remapped)"}
Old sidecars (schema before 5, analysis revision before 5)
rebuild the same way: annotations carry over, the binary
re-analyzes. Diagnosing a stale cache never requires deleting
anything by hand — load rewrites it.
Diagnostics: what absence does not mean
diagnostics pages provenance records — unresolved-indirect-jump,
unresolved-indirect-call, decode-failure — filtered by --kind
and containing-function --func. Querying never writes a sidecar.
Zero retained records is not proof of complete recovery: records
cap at 100,000 per project (diagnostics_truncated plus
diagnostics_omitted count the dropped rows), and hard analysis
budgets still fail with Limit rather than masquerading as a
successful partial analysis.
IR coverage: implemented versus complete
ir-coverage needs no binary: it names the implemented opcode
families, the explicitly partial mappings, and the standing limits
(operand strings reused verbatim, unmodeled flags, unmodeled
stack/calling-convention effects, no SSA/PHI production). Unknown
mnemonics lift to NOP with a warning, distinguishable from a
genuine NOP:
$ binscout ir-coverage x86_64 fw.bin 0x0 3 --db fw.redb
{"arch": "x86_64", "range": {"addr": 0, "addr_hex": "0x0", "decoded": 3,
"error_at": null, "lifted": 3, "truncated": false, "unlifted": 0,
"unlifted_mnemonics": []}, ...}
With a range it adds decoded/lifted/unlifted counts from
actual lifts plus a bounded mnemonic summary. A range requires
all of BINARY ADDR LEN together. Implemented families are not
semantically complete — listed mnemonics lift without warning,
but the bounds above still apply.
Byte-pattern search
PATTERN is positional: whitespace-separated full-byte tokens,
each two hex digits or a ?? wildcard. Empty, all-wildcard,
odd-length, non-hex, or over-4096-byte patterns are Invalid
errors. --range LO HI is half-open [LO, HI) over virtual
addresses (unlike the inclusive --range on functions);
--section is an exact section-name match:
$ binscout search-bytes fw.bin "68 00 21 ?? 00" --section .text
{"items":[{"addr":4198403,"addr_hex":"0x401003","file_off":515,"len":5,"section":".text"},{"addr":4198408,"addr_hex":"0x401008","file_off":520,"len":5,"section":".text"}],"limit":50,"next_offset":null,"offset":0,"protocol":1,"total":2}
Matches include overlaps, order by virtual address, and never
bridge mapping gaps; virtual BSS is never materialized. Scans
past 256 MiB of unique file-backed mapped bytes fail with
Limit instead of truncating silently.
Annotation transfer
annotations-export prints one JSON document to stdout
(read-only, never creates a sidecar); annotations-import
reads it from --input (MCP takes the document directly).
Identity is sha256 + size + mapping, and the whole document
validates before a single atomic write — a failure in the last
row leaves the DB unchanged:
$ binscout annotate fw.bin --db fw.redb 0x401000 --rename main
{"addr":4198400,"addr_hex":"0x401000","comment":null,"name":"main"}
$ binscout annotations-export fw.bin --db fw.redb
{"annotations":[{"addr":4198400,"rename":"main"}],"mapping":{"mode":"auto"},"revision":1,"sha256":"e70b2763e393b6d267d8e3b18f2d121018aa0c3b272cc7684d6d5d5f5fc23587","size":2048}
$ binscout annotations-import fw.bin --db fresh.redb --input doc.json
{"changed":1,"rows":1}
Only nonempty annotations appear and unset fields are omitted.
rename targets must be known function entries; comments keep
the any-address contract. Default merge fails on differing
existing field values (equal values are idempotent);
--overwrite replaces supplied fields only, absent fields leave
existing values alone, and empty strings clear. Documents cap at
16 MiB serialized; duplicate addresses, malformed identity, and
unsupported revisions are rejected.
Inferred edges: scope and provenance
The resolver handles two patterns — a single-slot
absolute indirect jump (x86-32 jmp m32 through an absolute
slot, x86-64 jmp m64 through a RIP-relative slot) in an
explicit raw mapping, with the slot value landing on executable
mapped bytes in the same function, and a guarded scaled-index
table (jmp [index*scale+base], x86-only: scale 4 on x86-32,
scale 8 on x86-64) behind a direct conditional bound-check guard
within 4 decoded predecessors. Unguarded indexes,
cross-function targets, truncated or unmapped slots,
non-executable targets, and container (non-raw) binaries all
keep their unresolved-indirect-jump diagnostic and stay
edgeless:
$ binscout --raw --arch x86_64 --base 0x400000 diagnostics blob.bin --db /tmp/blob.redb --kind unresolved-indirect-jump
{"items":[{"addr":4194304,"addr_hex":"0x400000","detail":"indirect jump without a direct target; the site stays edgeless","func":4194304,"func_hex":"0x400000","kind":"unresolved-indirect-jump"}],"limit":50,"next_offset":null,"offset":0,"protocol":1,"total":1}
Resolved edges stay separated from direct flow: cfg lists them
in inferred_edges (never edges), func counts them, and
xrefs tags them inferred-code next to the Data xref into
the slot:
$ binscout --raw --arch x86_64 --base 0x400000 cfg jump.bin --db /tmp/jump.redb 0x400000
{"containing_entry":4194304,"containing_entry_hex":"0x400000","edges":[],"entry":4194304,"entry_hex":"0x400000","inferred_edges":[[4194304,4194322]],"nodes":[{"end":4194310,"end_hex":"0x400006","insns":1,"start":4194304,"start_hex":"0x400000","succs":[]},{"end":4194323,"end_hex":"0x400013","insns":1,"start":4194322,"start_hex":"0x400012","succs":[]}],"query_addr":4194304,"query_addr_hex":"0x400000"}
$ binscout --raw --arch x86_64 --base 0x400000 xrefs jump.bin --db /tmp/jump.redb
{"items":[{"from":4194304,"from_func":4194304,"from_func_hex":"0x400000","from_func_name":null,"from_hex":"0x400000","kind":"Data","to":4194314,"to_hex":"0x40000a","to_name":null,"to_string":null},{"from":4194304,"from_func":4194304,"from_func_hex":"0x400000","from_func_name":null,"from_hex":"0x400000","kind":"inferred-code","to":4194322,"to_hex":"0x400012","to_name":"func@0x400012","to_string":null}],"limit":50,"next_offset":null,"offset":0,"protocol":1,"total":2}
Caps are one edge per single-slot site and 2–8 consecutive
valid slots per table site (a singleton run is a stray pointer;
a run still valid at 8 slots is open-ended, so the site stays
unresolved rather than partially recovered); 100,000 per project;
exhaustion keeps the site unresolved with inferred_truncated
set and the excess in inferred_omitted.
0.9.0: page envelope everywhere
functions, strings, stack_strings, go_funcs, and xrefs
now always return the protocol-1 page envelope (protocol,
total, offset, limit, next_offset, items) on the CLI,
the MCP tools, and batch ops. Before (0.8.0 defaults) and after,
same queries:
$ binscout functions fw.exe --limit 1
[{"blocks":1,"calls":[],"entry":4198400,"entry_hex":"0x401000","id":"func@0x401000","insns":5,"name":"basic_entry","noreturn":false}]
$ binscout functions fw.exe --limit 1
{"items":[{"blocks":1,"calls_count":0,"entry":4198400,"entry_hex":"0x401000","id":"func@0x401000","insns":5,"name":"basic_entry","noreturn":false}],"limit":1,"next_offset":null,"offset":0,"protocol":1,"total":1}
$ binscout strings fw.exe --limit 1
[{"encoding":"Ascii","executable":false,"offset":52,"section":".rdata","vaddr":4202548,"vaddr_hex":"0x402034","value":"basic.dll"}]
$ binscout strings fw.exe --limit 1
{"items":[{"encoding":"Ascii","executable":false,"offset":52,"section":".rdata","vaddr":4202548,"vaddr_hex":"0x402034","value":"basic.dll"}],"limit":1,"next_offset":1,"offset":0,"protocol":1,"total":4}
$ binscout xrefs fw.exe --to 0x402100 --limit 1
{"total":4,"xrefs":[{"from":4198403,"from_func":4198400,"from_func_hex":"0x401000","from_func_name":"basic_entry","from_hex":"0x401003","kind":"Data","to":4202752,"to_hex":"0x402100","to_name":null,"to_string":null}]}
$ binscout xrefs fw.exe --to 0x402100 --limit 1
{"items":[{"from":4198403,"from_func":4198400,"from_func_hex":"0x401000","from_func_name":"basic_entry","from_hex":"0x401003","kind":"Data","to":4202752,"to_hex":"0x402100","to_name":null,"to_string":null}],"limit":1,"next_offset":1,"offset":0,"protocol":1,"total":4}
What moved:
functionsrows trade the unboundedcallstarget array forcalls_count. Direct callees remain onecalleesquery away (depth1 orders the same targets by entry with their distance).stringskeeps--start/--limit(--offsetstays a deprecated alias that warns on stderr); the rows now page under the envelope with an exacttotal.stack_stringsandgo_funcsgain--offset/--limitand page under the envelope (empty table still reads as an emptyitemspage, not a bare[]).xrefsmoves from the old total-plus-xrefswrapper toitems(row fields unchanged).--envelopeon the CLI andenvelopeon the MCP tools are accepted but ignored: output is always the envelope. The CLI flag is hidden; MCPenvelope: falsewarns on stderr and still returns the envelope.
Range names carry semantics on functions and search_bytes
(MCP tools and batch ops): range_lo/range_hi is inclusive
(lo <= x <= hi), range_start/range_end is half-open
(start <= x < end). Give exactly one pair per call: mixing the
pairs is an error, and each pair must be given together. The
per-tool CLI --range semantics are unchanged: inclusive
LO..=HI over entries on functions (see above), half-open
[LO, HI) over match addresses on search-bytes (see
Byte-pattern search).
Additive and already shipped (no migration needed): cfg,
structure, pseudo (and the library func_detail) echo the
requested address in query_addr/query_addr_hex; the MCP
annotation tool reads the current rename/comment row (CLI
annotate without flags parity), read-only. The type-hint API
stays a comment-channel convention (see
JSON protocol); it is out of scope for this track.
MCP tools
binscout-mcp serves 43 tools over stdio (newline-delimited JSON-RPC).
Each takes binary plus an optional db path, an optional raw
mapping object or fat_arch slice selection, and optional pdb /
debug_file debug inputs (diff takes
binary_a/binary_b plus optional db_a/db_b with one shared
raw/fat_arch selection and default debug options; batch takes one
envelope plus a list of read-only ops) and returns one JSON
document as text; failures are tool errors. Attach it to any MCP client:
{
"mcpServers": {
"binscout": { "command": "/path/to/binscout-mcp" }
}
}
| Tool | Parameters | Does |
|---|---|---|
project_info | binary | Open a binary and report arch, format, entry, mapping (mode, base), diagnostic totals, and analysis_revision; read-only, never saves the snapshot — call load once to persist the sidecar so later opens replay it instead of re-analyzing |
load | binary | Persist the analysis snapshot to the project DB (binary untouched); CLI load parity, warms the sidecar so later opens replay it instead of re-analyzing |
functions | binary, query/caller/callee/range_lo/range_hi or range_start/range_end, offset/limit | List functions with rename-resolved names, filtered (query case-insensitive substring; caller/callee addresses resolving to call-graph neighbors; exactly one range pair: range_lo + range_hi bounding entries inclusive, or range_start + range_end bounding them half-open) and paged under the protocol-1 page envelope with an exact total; rows carry the compact calls_count instead of the calls target array (use callees at depth 1 for the targets; the envelope parameter is accepted but ignored) |
func | binary, addr | Compact metadata of one function: entry, name, block/insn/call counts, discovery reasons |
blocks | binary, addr, offset?/limit? | Block summaries of the containing function by block start, under the page envelope |
block_insns | binary, addr, block, offset?/limit? | That block’s instructions in address order, under the page envelope; block must belong to the function |
disasm | binary, addr, len | Disassemble len bytes at addr with the binary architecture; the valid prefix plus error_at for the first bad opcode (ranges cap at 1 MiB) |
bytes | binary, addr, len, as?/endian?/as_type? | Raw bytes at addr (len caps at 1 MiB, BSS tails read as zeros) with VA/file provenance (file_off null for zero-fill, section null when section-less) plus bytes_hex and typed values (u8/u16/u32/u64/ptr/cstr/utf16, le/be byte order) with the exact 0x-hex twin values_hex on integer views (absent on string views); as_type takes a stored type-hint address and renders its struct fields over the range start (len must cover the struct size) |
cfg | binary, addr | Control-flow graph of one function: block nodes plus block edges; inferred_edges holds provenance-marked indirect-jump resolutions (single-slot absolutes and guarded scaled-index tables; raw-only, same-function); query_addr echoes the address passed in addr |
structure | binary, addr | Approximate control-flow structure of one function: syntactic loops (back-edge headers with latches) and ifs (two-successor branch sites with then/else targets) plus an approximation warning; addr snaps to its containing function, query_addr echoes it |
pseudo | binary, addr | Approximate pseudo-C of one function: one lossy C-like line per IR row plus assembled text, with an approximation warning; addr snaps to its containing function, query_addr echoes it |
callees | binary, addr, depth?/offset?/limit? | Transitive callees out to depth hops (direct are depth 1), ordered by entry with shortest distance, under the page envelope; addr snaps to its containing function |
callers | binary, addr, depth?/offset?/limit? | Transitive callers out to depth hops, ordered by entry with shortest distance, under the page envelope; addr snaps to its containing function |
slice | binary, addr, depth?/offset?/limit? | Backward slice of addr: every instruction that can reach it via xref edges (any kind) and intra-function CFG predecessors out to depth hops (direct are depth 1, default 8, zero yields an empty page, past the 64-hop cap is an Invalid error), ordered by address with shortest distance, under the page envelope; any mapped address is a valid root (unmapped roots are a NotFound error) |
diagnostics | binary, kind?, func?, offset/limit | Provenance records (unresolved indirect sites, decode failures) ordered by (kind, addr) under the page envelope, filtered by kind and containing-function func; queries never write a sidecar |
xrefs | binary, to/from/kind, offset/limit | Cross-references filtered by endpoint and kind (code, data, string, import, inferred-code), paged under the protocol-1 page envelope (items) with an exact total; rows carry listing context (from_func/from_func_name, to_name, to_string for string-kind rows) |
strings | binary, pattern/min_len/section/include_code/decode/with_xrefs, start/limit | Extracted strings ordered by address, filtered and paged under the protocol-1 page envelope with an exact total; executable-memory hits hidden unless pattern, section, or include_code is given (offset is a deprecated alias of start, warning on stderr; the envelope parameter is accepted but ignored); decode (xor:<byte>, xor:0x<HEXKEY> rolling multi-byte key, add:<byte>, rot:<0-7>, or bare base64) re-extracts over a read-only in-memory transform with original offsets; with_xrefs adds the bounded per-row xrefs reference list |
stack_strings | binary, offset?/limit? | Recovered stack-constructed strings: runs of mov [rsp/rbp+off], imm within one block, reassembled with function and address, paged under the protocol-1 page envelope; read-only, never writes the binary or the sidecar |
symbols | binary | Imports, exports, and symbol-table code addresses of the binary (symbols: one name/address/address_hex row per defined text symbol, locals included, deduplicated by address); Mach-O imports carry the address/address_hex of their __stubs/__auth_stubs entry (null when unmapped), and each mapped stub seeds its own import-named function; symbol addresses seed symbol-reasoned functions named below exports and above stubs |
sections | binary | Section table: name, virtual address (IMAGE_BASE + RVA on PE), in-memory/file sizes, Shannon entropy (bits per byte), permissions |
ir | binary, addr, len | Lift len bytes at addr to P-code-inspired IR (error_at on trailing bad bytes, ranges cap at 1 MiB) |
ir_coverage | arch, binary?/addr?/len? | Machine-readable lift coverage for one arch (implemented families, partial mappings, limitations); no binary is opened without the range, which adds decoded/lifted/unlifted counts from actual lifts plus a bounded mnemonic summary |
flirt_hints | binary, addr?, sigs?, offset?/limit? | FLIRT-like library hints: corpus signature matches over each function’s leading bytes, paged under the protocol-1 envelope; addr keeps only the containing function’s hints; sigs adds a user signature file path (our JSON, as emitted by sig_gen, or an IDA .pat file by extension); suggested names stay hints, querying never writes a sidecar |
sig_gen | binary | Emit a JSON signature document for the binary’s named functions (masked leading bytes with len/crc): the sigs input that flirt_hints reads back; read-only, never writes the binary or the sidecar |
go_funcs | binary, offset?/limit? | Recover Go functions from the pclntab table (linker names plus exact entry/end ranges) for stripped Go binaries, paged under the protocol-1 page envelope; empty table reads as an empty items page; read-only, never writes the binary or the sidecar |
stats | binary | Storage stats: binary size, sidecar DB size, and analysis counts |
headers | binary | Header metadata: triage staples (PE mitigations/imphash/PDB, ELF interp/needed/RELRO/NX/PIE, Mach-O load commands/codesign) plus sha256/md5; computed on demand, never persisted |
rename | binary, addr, name | Rename a function in the project DB (binary untouched); empty name clears |
annotation | binary, addr | Read the annotation at one address (rename/comment with addr twins; nulls when unset); read-only, never creates or modifies the sidecar; CLI annotate without flags parity |
comment | binary, addr, comment | Comment any address in the project DB (binary untouched); empty comment clears; structured struct-layout hints (type-hint:{...}, see JSON protocol) pass through opaquely |
set_type_hint | binary, addr, hint | Store a structured struct-layout hint at any address from wire JSON ({"kind":"struct","name":..,"size":..,"fields":[..]}) in the project DB (binary untouched); empty hint clears the hint, plain comments are left alone |
get_type_hint | binary, addr | Read the structured struct-layout hint at one address ({"addr", "addr_hex", "hint"} with the wire object or null; corrupt hints error, plain comments read as null); read-only, never creates or modifies the sidecar |
define_func | binary, addr, mode? | Assert “there is code here”: store a user function seed and re-analyze so it materializes; mode (arm/thumb) selects the 32-bit ARM decode, other arches reject it |
undefine_func | binary, addr | Assert “this isn’t a function”: exclude the seed (kept as data) and re-analyze |
search_bytes | binary, pattern, section?/range_lo?/range_hi? or range_start?/range_end?, offset?/limit? | Paged ??-wildcard byte-pattern matches ordered by virtual address (exactly one range pair: range_lo + range_hi bound the inclusive [lo, hi] range, range_start + range_end bound the half-open [lo, hi) range); scans cap at 256 MiB of mapped bytes with an explicit Limit error |
crypto_scan | binary, name?/section?, offset?/limit? | Paged crypto-constant matches (addr/addr_hex, name, file_off, section, len, xrefs_count) for the static table (AES/SHA/MD5/CRC-32 tables, ChaCha sigma, Blowfish P-array, TEA delta, LE/BE word orders) |
annotations_export | binary | Emit the portable annotation interchange document; read-only, never creates a sidecar |
annotations_import | binary, document, overwrite? | Atomically merge a document; returns row/change counts, default fails on conflicts |
diff | binary_a, binary_b, db_a?/db_b?, raw?/fat_arch?, offset?/limit?, transfer_renames? | Function-level diff between two binaries (matched/added/removed/changed with match reason, plus BinDiff-style neighbour propagation); each list pages under the protocol-1 envelope; transfer_renames embeds the side-B rename document for annotations_import; both projects open read-only, never creating or modifying a sidecar; the shared raw/fat_arch selection (if any) applies to both |
diff_func | binary_a, binary_b, addr_a, addr_b, db_a?/db_b?, raw?/fat_arch? | Block- and instruction-level delta between two functions (blocks match by hash then by position, each matched block carries a bounded edit script); addresses snap to their containing entries; read-only like diff |
patch | binary, addr, asm?/bytes?, out?/format? | Assemble replacement bytes at one x86 or aarch64 address and export the patch (va/va_hex, file_off null when not file-backed, old_hex, new_hex, size_ok) without writing the binary; exactly one of asm (x86: one of nop, ret, int3, jmp ADDR, call ADDR; aarch64: one of nop, ret, brk #IMM, b ADDR, bl ADDR, at a 4-aligned address with a byte count that is a multiple of 4, encoded at the address) or bytes (whitespace-separated hex pairs); shorter replacements NOP-pad to the instruction boundary (x86), longer ones report size_ok:false; out writes a json (default) or ips patch file that must differ from the binary; overflowing or non-file-backed patches refuse the file write; rejected in batch |
batch | binary, db?/raw?/fat_arch?/pdb?/debug_file?, ops (1–32) | Up to 32 read-only ops over one open project, run in order; returns {"results": [{"ok"} | {"error"}]} with per-op limits unchanged and total output capped at 1 MiB (see below) |
Addresses are 0x-hex or decimal strings. kind filters accept
code, data, string, import, and inferred-code
(case-insensitive);
stored rows keep the historical Code/Data/String spelling while
inferred rows serialize as kebab-case inferred-code. One server process
keeps a 4-entry LRU of open projects keyed by binary, sidecar,
mapping, and debug inputs and revalidated by file length plus mtime, so repeat calls skip
re-analysis; each entry has its own lock and each sidecar file its own
handle mutex, so calls on different binaries proceed concurrently while
calls sharing a binary or sidecar serialize (redb allows a single open
handle per file per process).
Errors
Failures are tool errors carrying the JSON-RPC code plus
data: {"kind": ...}: invalid_params for bad inputs and over-cap
ranges (kind invalid or limit — narrow the query),
resource_not_found for unknown functions and addresses (kind
not_found — retry with a snapped address), and internal_error for
unsupported inputs plus sidecar and filesystem failures (kind
unsupported, storage, or io — give up or retry nothing). See
JSON protocol for the full variant table.
Batch
One MCP round trip for the func → cfg → pseudo → xrefs
per-function loop: the envelope opens the binary once and every op runs
in order under that entry lock, so results come back positionally in
results:
{"binary": "fw.elf", "ops": [
{"tool": "func", "params": {"addr": "0x401000"}},
{"tool": "xrefs", "params": {"to": "0x402000"}},
{"tool": "func", "params": {"addr": "0xdead"}}
]}
{"results": [
{"ok": {"entry": 4198400, "entry_hex": "0x401000", "blocks": 1, "insns": 3, "calls": 0}},
{"ok": {"protocol": 1, "total": 0, "offset": 0, "limit": 50, "next_offset": null, "items": []}},
{"error": "not found: no function contains 0xdead"}
]}
Rules:
- Ops carry only tool-specific parameters: the envelope owns the binary
identity, so
binary/db/raw/fat_arch/pdb/debug_file(anddiff’sbinary_aand friends) are rejected insideparams. (ir_coveragetakesarchplus optionaladdr/len; the binary always comes from the envelope.) - Read-only tools only:
load,rename,comment,set_type_hint,define_func,undefine_func, andannotations_importare rejected per op (writes stay explicit top-level calls), as are the two-binarydiffanddiff_func,patch, nestedbatch, and unknown names. Per-op failures are{"error"}elements with the same message text the single tool would report; only envelope misuse (empty or over-32 op lists, open failures) is a tool error. - Per-op row and range limits apply unchanged; the sum of the
compact-serialized results caps at 1 MiB. The op that would overflow
returns a limit error and every later op returns a skipped error, so
a 32-wide
cfgfan-out degrades from the tail instead of failing the call.
Raw mapping and inferred edges
Every binary-taking tool accepts an optional raw object
(arch/base/entry?) with the same rules as the CLI flags:
arch and base are required in raw mode, and raw-only options
without raw are errors. Fat Mach-O containers take an optional
fat_arch string with the same arch names as the CLI flag; without
it a fat input errors listing the available archs, and with it a thin
input errors. func returns the compact metadata shape;
cfg separates direct edges from provenance-marked
inferred_edges. Inferred edges come from the indirect-jump
resolver: single-slot absolute jumps plus guarded scaled-index
tables (x86-only, 2–8 consecutive valid slots per table site),
raw mappings only, same-function targets only. Anything the
resolver cannot prove keeps its unresolved-indirect-jump
diagnostic and stays edgeless. See
JSON protocol for the full request/response
definitions.
Find main
Goal: locate the program’s real entry logic — the startup entry point
versus the application main — using only headless queries.
Use this when opening an unfamiliar binary: confirm where execution starts, list candidate mains, and pick the function worth renaming and reading first.
Chain
load → symbols → functions --query → func → callers /
callee filter → flirt-hints (optional) → cfg / blocks →
annotate --rename.
Each step narrows the candidate set; stop as soon as one function explains the entry’s callees.
1. Open and read the entry
$ binscout load fw.exe
$ binscout symbols fw.exe
load reports arch, format, entry / entry_hex, mode, and
diagnostic totals, and caches the snapshot. symbols returns
{"imports": [...], "exports": [...]} — exports often name the
candidate mains directly (for example, basic_entry in the
pe32-basic.exe fixture at entry 0x401000).
MCP: project_info (binary), then symbols (binary).
2. List name candidates
$ binscout functions fw.exe --query main --limit 50
$ binscout func fw.exe 0x401000
--query is a case-insensitive substring over the rename-resolved
name. No match is not an error — it is an empty list, meaning the
binary strips names or calls it something else; fall through to step 3.
func returns compact metadata (entry / entry_hex, name,
blocks / insns / calls counts, inferred_edges count,
reasons such as entry, export, direct-call, prologue).
Any address inside the function snaps to its containing entry;
an address in no function is NotFound.
MCP: functions (binary, query: "main"), then func (binary,
addr).
3. Confirm via the callgraph
$ binscout callees fw.exe 0x401000 --depth 1
$ binscout callers fw.exe 0x401000 --depth 5
$ binscout functions fw.exe --callee 0x401000 --limit 50
The entry’s direct callees (depth 1) are the startup-called
functions — the real main is usually among them. Conversely,
callers of a candidate main should lead back toward the entry or
a CRT startup wrapper. The --caller / --callee filters on
functions keep call-graph neighbors of the function containing
that address without a second round trip. Results page under the
protocol-1 envelope (protocol, total, offset, limit,
next_offset, items) ordered by entry with shortest distance;
direct neighbors are depth 1.
MCP: callees / callers (binary, addr, depth?, offset?,
limit?); functions with caller / callee.
4. Exclude library startup (optional)
$ binscout flirt-hints fw.exe --addr 0x401000
flirt-hints pairs each function entry with a corpus signature
id, its suggested_name, and the reason it stays a hint. A hit
saying “this looks like CRT startup” is evidence to keep looking,
not a rename: suggested names are never applied automatically.
MCP: flirt_hints (binary, addr?, offset?, limit?).
Querying never writes a sidecar.
5. Read, then name it
$ binscout cfg fw.exe 0x401000
$ binscout blocks fw.exe 0x401000 --limit 50
$ binscout annotate fw.exe 0x401000 --rename main --comment "entry via callees of startup"
cfg is the explicit full-graph export (block nodes plus
(from, to) edges; inferred_edges holds raw-only same-function
single-slot resolutions). blocks pages the same function safely
when the graph is large. annotate without flags reads; --rename
writes only on known function entries (empty string clears),
--comment accepts any address.
MCP: cfg (binary, addr), blocks (binary, addr),
then rename (binary, addr, name) / comment (binary,
addr, comment).
Failure modes
func/cfg/blockson an address in no function:NotFound— the address is data, a string, or unmapped, not code.functions --querywith no hits: empty list, not an error — pivot tocalleesof the entry instead of guessing names.flirt-hintswith no hits: empty page — the corpus does not cover this compiler/CRT, not proof of hand-written code.
See CLI reference for flag details and JSON protocol for the page envelope.
Trace string
Goal: go from an interesting string (“SAVE”, an error message, a URL, a registry key) to the code that uses it, and from there to the function worth reading.
Use this when a string names the behavior under investigation and the question is “what code touches this?”.
Chain
strings --pattern → xrefs --to --kind string → func →
block-insns / disasm → slice ADDR → callers.
Each step moves one hop: text, to reference site, to containing function, to backward reachability.
1. Find the string
$ binscout strings fw.exe --pattern SAVE --min-len 6
--pattern is a case-sensitive substring (or a regex: expression);
--min-len drops short noise, --section keeps one section exactly
(such as .rdata). Hits in executable memory are hidden unless
--pattern, --section, or --include-code is given. Page with
--start / --limit (--offset is a deprecated alias that warns).
For single-byte-obfuscated text, --decode xor:<byte>, add:<byte>,
or rot:<0-7> (0x-hex or decimal byte) re-extracts over a
read-only in-memory transform with original offsets; the binary is
never written. Rolling multi-byte keys (--decode xor:0x<HEXKEY>
with 4+ hex digits) and base64-blob plaintext (--decode base64)
work the same way.
$ binscout strings fw.exe --pattern "regex:GAM.*invalid"
$ binscout strings fw.exe --decode xor:0x42 --pattern SAVE
$ binscout strings fw.exe --decode xor:0xDEADBEEF --pattern SAVE
$ binscout strings fw.exe --decode base64 --pattern token
MCP: strings (binary, pattern?, min_len?, section?,
include_code?, decode?, with_xrefs?, start?, limit?).
--with-xrefs skips step 2 for the common case: each string row
carries its referencing instructions directly.
2. Find who references it
$ binscout xrefs fw.exe --to 0x402100 --kind string
xrefs filters by --to / --from / --kind (code, data,
string, import, inferred-code, case-insensitive) and pages under
the protocol-1 page envelope (items) with an exact total. Rows carry from / from_hex,
to / to_hex, and kind, plus listing context: from_func /
from_func_hex with its rename-resolved from_func_name,
to_name (function or import display name), and to_string (the
string preview on string-kind rows). A string typically has string-kind
rows from the referencing instructions (the pe32-basic.exe
fixture references its SAVE%d.GAM is invalid marker twice from
.text) plus data-kind rows where the address is materialized.
MCP: xrefs (binary, to, kind: "string", offset?,
limit?).
3. Land in the containing function
$ binscout func fw.exe 0x401000
$ binscout block-insns fw.exe 0x401000 0x401000 --limit 50
$ binscout disasm fw.exe 0x401000 32
func snaps any address inside the function to its containing entry
(NotFound when in no function) and returns counts plus discovery
reasons. block-insns pages that block’s instructions in address
order — the block must belong to the function. disasm decodes
len bytes at addr with the binary architecture, returning the
valid prefix plus error_at for the first bad opcode (ranges cap at
1 MiB). Use ir with the same ADDR LEN shape when the question is
about effects rather than bytes.
MCP: func (binary, addr), block_insns (binary, addr,
block), disasm / ir (binary, addr, len).
4. Walk backward to the decision
$ binscout slice fw.exe 0x401003 --depth 5
$ binscout callers fw.exe 0x401000 --depth 5
slice returns every instruction that can reach ADDR via xref edges
(any kind) plus intra-function CFG predecessors, out to --depth
hops (direct predecessors are depth 1), ordered by address with
shortest distance under the page envelope. Any address is a valid
root — data and string targets lie in no function. callers climbs
from the sink function toward its callers out to --depth hops.
Depth past the 64-hop cap is an Invalid error; zero yields an
empty page.
MCP: slice (binary, addr, depth?), callers (binary,
addr, depth?).
5. Mark the sink
$ binscout annotate fw.exe 0x401000 --comment "handles SAVE marker; reached via string xref"
comment accepts any address; rename only known function entries.
Querying (strings, xrefs, slice, callers) never writes a
sidecar — only annotate (or MCP rename / comment) persists.
Failure modes
stringswith no hits: widen--pattern(substring, not glob), lower--min-len, or drop--sectionbefore concluding the string is absent or obfuscated.xrefs --towithtotal: 0: the string is unreferenced dead data — check--kind datawithout the kind filter before assuming the address is wrong.slicepast the depth cap:Invalid— lower--depthand page outward instead.
See CLI reference for flag details and JSON protocol for the page envelope.
Audit imports
Goal: enumerate what a binary depends on from the outside world — imported DLLs/APIs, exported surface, and the indirect-call sites where that outside world is actually reached.
Use this for a first-pass dependency and attack-surface review: which external functions the binary can call, which exports it exposes, and where import-like indirect calls occur.
Chain
symbols → xrefs --to <slot> --kind import → func / disasm
per caller → callers → annotate --comment.
Each import carries its call pointer in address/address_hex
(the __stubs/__auth_stubs entry on Mach-O, the IAT slot on PE,
the GOT slot on ELF; null when unmapped), so import callers are one
xrefs query away. disasm rows and pseudo lines at call sites
carry the same import name for ground-truth reading.
1. Enumerate the external surface
$ binscout symbols fw.exe
$ binscout sections fw.exe
symbols returns {"imports": [...], "exports": [...]}. Each
import carries its library and name plus the call pointer in
address/address_hex (the __stubs/__auth_stubs entry on Mach-O,
the IAT slot on PE, the GOT slot on ELF; null when unmapped);
ordinal-only imports carry
ordinal plus unresolved: true, and recognized C++ manglings
additionally carry demangled. ELF PLT stubs additionally seed
sym@plt functions. Exports name the callable surface
the binary exposes to others. sections returns the section table
(name, vaddr, in-memory/file sizes, readable / writable /
executable); on PE, vaddr = IMAGE_BASE + RVA. Raw blobs have no
table and report []. Flag writable-and-executable sections on
sight.
MCP: symbols (binary), sections (binary).
2. List each import’s callers
$ binscout xrefs fw.exe --to 0x402038 --kind import
$ binscout xrefs fw.exe --to 0x402038
--to takes the import’s slot address straight from symbols;
--kind import keeps only the import rows (unfiltered, the
indirect sites also show their data row and direct PLT/thunk
calls their code row). For unmapped imports (null address) and
for the full indirect-call inventory including non-import sites,
fall back to diagnostics --kind unresolved-indirect-call
(optionally --func 0x401000 for one function): import calls have
no direct target, so they appear there too. Each diagnostics row
carries kind, addr / addr_hex, the containing function
(func / func_hex, null when in no function), and kind-specific
detail. --kind accepts only
unresolved-indirect-jump, unresolved-indirect-call, and
decode-failure; --func snaps to its containing function and keeps
only that function’s sites (NotFound when in no function). Rows
order by (kind, addr) under the page envelope. Querying never
writes a sidecar. Zero retained records is not proof of complete
recovery — records cap at 100,000 per project.
MCP: diagnostics (binary, kind: "unresolved-indirect-call", func?, offset?, limit?).
3. Ground each site in code
$ binscout func fw.exe 0x401010
$ binscout disasm fw.exe 0x401010 16
$ binscout xrefs fw.exe --from 0x401010
func identifies the containing function and its discovery
reasons. disasm shows the calling instruction and its operands
(the valid prefix plus error_at on trailing bad bytes; ranges cap
at 1 MiB). xrefs --from lists what that site points at — look for import-kind
rows into the slot (plus the retained data-kind slot row) alongside
the unresolved call. disasm rows and pseudo lines at the site
carry the import name directly.
Use ir with the same ADDR LEN shape when comparing call shapes
across sites.
MCP: func (binary, addr), disasm (binary, addr, len),
xrefs (binary, from).
4. Find who can reach the risky call
$ binscout callers fw.exe 0x401010 --depth 5
$ binscout search-bytes fw.exe "FF 15 ?? ?? ?? ??" --section .text
callers orders transitive callers by entry with shortest distance
under the page envelope; direct callers are depth 1. search-bytes
is the optional pattern complement: whitespace-separated full-byte
tokens with ?? wildcards (empty, all-wildcard, or malformed
patterns are Invalid), --section for an exact section match and
--range LO HI as half-open [LO, HI); scans cap at 256 MiB of
mapped bytes with an explicit Limit error.
MCP: callers (binary, addr, depth?), search_bytes
(binary, pattern, section?, range_start?, range_end?).
5. Record the verdict
$ binscout annotate fw.exe 0x401010 --comment "indirect call: audit IAT slot for TESTDLL.dll ordinals"
$ binscout annotations-export fw.exe
comment accepts any address (empty string clears); rename only
known function entries. annotations-export emits the portable
handoff document (read-only, never creates a sidecar).
Failure modes
symbolswith empty imports: statically linked or raw blob — pivot tostringsfor embedded library markers anddiagnosticsfor the indirect-site inventory.diagnostics --funcoutside any function:NotFound— the site address is data, not code; query without--funcinstead.- Ordinal-only imports (
unresolved: true) with nodemangled: expected, not a parse failure — there is no name to demangle.
See CLI reference for flag details and JSON protocol for the page envelope.
Architecture
One engine, two interfaces. Data flows one way — loader, disassembler,
IR, analysis, database — and both the CLI (binscout) and the MCP server
(binscout-mcp) are thin adapters over it.
- Loader (
loader): sniffs ELF, PE, Mach-O, COFF, and LE, falling back to flat raw bytes when nothing matches: unrecognized input opens as x86-64 at base 0, LE images analyze as 32-bit x86. Fat Mach-O containers analyze one explicitly selected slice (--fat-arch/fat_arch; slices never share snapshots). Mach-O__stubs/__auth_stubsentries pair with imports in bind order under all-or-none guards, so each mapped stub carries its import’s address. Explicit base/architecture mapping goes throughopen_raw, exposed as CLI--raw --arch ARCH --base ADDR [--entry ADDR]and the MCPrawobject on every binary-taking tool. Produces segments, sections, imports/exports, and printable strings (ASCII, UTF-16LE/BE over the ASCII subset, UTF-8 runs holding non-ASCII text, and script-consistent UTF-16LE runs over non-ASCII BMP letters with degenerate-run and ASCII-shadow guards).strings --decodere-extracts over a read-only view: single-bytexor/add/rot, rolling multi-bytexor:0x<HEXKEY>, or barebase64blob-plaintext detection. Inputs over 512 MiB are rejected before parsing. - Disassembler (
disasm): x86_64 and 32-bit x86 via iced-x86, AArch64, 32-bit ARM, and Thumb via yaxpeax-arm. Each instruction becomes anInsnwith its bytes, mnemonic, operand strings, and resolved branch/data targets (including typed absolute-slot targets for single-slot indirect jumps, which the resolver below consumes). An AArch64adrpdecodes to its 4K page base; an adjacent same-blockadrp+add/ldrpair resolves to the final address for xref recovery, IR, and pseudo rendering. On 32-bit ARM each row records its decode mode (thumb); an adjacent same-blockmovw+movtpair resolves the same way, and ARM literal-pool loads resolve their pool word plus the pointer stored there. - IR (
ir): lifts one instruction to one P-code-inspiredIrInsn(COPY,LOAD,BRANCH,CALL, …). Unknown mnemonics becomeNOPwith a warning instead of failing, so analysis proceeds over partial lifts.ir_coveragereports the implemented opcode families, explicit partial mappings, and limits (operand strings, flags, stack/calling-convention effects, no SSA/PHI) without opening a binary; with a range it adds decoded/lifted/unlifted counts from actual lifts. - Analysis (
analysis): recursive descent from the entry point and export addresses over decoded instructions, plus a prologue scan for functions unreachable from those seeds. Mach-O stub entries seed their own functions under their import’s name. Builds per-function CFGs, a callgraph, and code/data/string cross-references. Records discoveryreasonsper function (entry,export,direct-call,prologue), retains bounded diagnostics (unresolved indirect sites, decode failures; 100,000-record cap with truncation counts), and resolves single-slot absolute indirect jumps and guarded scaled-index tables in raw mappings to provenance-markedinferred-codeedges and xrefs (one edge per single-slot site, 2–8 slots per table site, 100,000 per project; unprovable sites stay unresolved and edgeless). On 32-bit ARM, seeds carry their decode mode (Thumb-bit addresses,$a/$tmapping symbols, Thumb-function marks), directblxtargets and resolvedbx-register constants switch state, and switch targets start their own function so no function spans both modes. Where anadrp+add/ldrpair resolves, the second instruction also carries aDataxref at the final address alongside the page-base row. Analysis revision 5; older snapshots re-analyze. - Search (
search): bounded literal/??-wildcard scan over mapped file-backed bytes (pattern cap 4096 bytes, 256 MiB scan cap, 1024-row pages; gaps never bridged, BSS never materialized). - Annotations (
annotations): versioned JSON export/import (revision 1, SHA-256 + size + mapping identity, 16 MiB document cap, atomic all-or-nothing merge with fail-on-conflict default). - Database (
db): caches the snapshot and the user annotations in aredbsidecar; see Sidecar format. Cache identity covers content, loader mapping, and analysis revision — a changed binary, a different raw mapping, or an older schema (current version 5) re-analyzes instead of replaying layouts.
Format support
| Format | Entry | Layout | Imports | Function seeds |
|---|---|---|---|---|
| ELF linked | e_entry | segments at link VAs | dynamic table; GOT slots via .rela.plt | entry, exports, symbols, init arrays |
ELF relocatable (.o) | none | synthetic: mapped sections in file order from 0x10000, 16-aligned; relocations patched | undefined symbols referenced from executable code, each with a synthetic stub address | symbols, direct-call targets, prologue scan |
| PE | entry RVA + ImageBase | sections at ImageBase + RVA | IAT slots | entry, exports, symbols, .pdata, TLS callbacks |
| Mach-O | LC_MAIN/LC_UNIXTHREAD | segments at vmaddr | __stubs/__auth_stubs entries | entry, exports, symbols, stubs, function starts |
COFF relocatable (.obj) | none | synthetic, same as ELF .o | same as ELF .o | symbols, direct-call targets, prologue scan |
| LE | bundle entry | objects at reloc_base | fixup targets (#ordinal, @0xoff) | entry, exports, prologue scan |
| Raw | --entry or none | one RWX segment at --base | none | entry or first byte, prologue scan |
Sidecar format
Analysis results and annotations persist in a redb database next to the
binary: .rsdbg.redb appended to the full file name by default
(foo.exe → foo.exe.rsdbg.redb), overridden per-invocation with
--db PATH (CLI) or the db parameter (MCP tools). The analyzed binary
itself is only ever read.
On open, the stored content hash, loader mapping (auto versus
explicit raw arch/base/entry), explicit debug inputs (--pdb /
--debug-file content identity), and analysis revision are compared
against the request; a mismatch means the snapshot is discarded and
the binary re-analyzes. Annotations and user seeds carry over by address
when the mapping is unchanged (a debug-input mismatch re-analyzes but
never errors). A sidecar holding annotations or seeds
opened under an incompatible mapping fails with a separate-DB error
instead of remapping them. A sidecar written by an older schema version (current
version 8, analysis revision 11) behaves the same way: annotations and
seeds carry over and the binary re-analyzes. Metadata, annotations, and
user seeds persist as JSON rows; derived rows (functions, xrefs, strings)
persist as chunked compact binary blobs with integer chunk keys, while
diagnostics stay key-only rows with tuple keys.
User seeds hash into the snapshot identity (seeds_hash in the
metadata): every seed change re-analyzes before saving, so derived rows
always match the stored seeds.
| Table | Key | Value |
|---|---|---|
meta | string | schema version, path, hash, size, arch, format, entry, mapping, analysis revision, seed identity |
binaries | 0 | snapshot metadata |
functions | entry address | function row (name, callees, discovery reasons, decode-arch override) plus its block layouts (address range plus per-instruction sizes, successors, inferred successors) |
xrefs | chunk index | cross-reference blob chunk (fixed (from, kind, to) entries: direct, import, and inferred-code kinds) |
strings | chunk index | extracted-string blob chunk |
diagnostics | (addr, kind) | key-only provenance row (unresolved indirect sites, noreturn cuts, decode failures) |
annotations | address | rename and/or comment |
func_seeds | address | user function seed (decode mode, excluded flag) |
Block layouts store address ranges plus per-instruction sizes, not rendered instructions: the open path re-decodes each recorded address from the binary, so snapshots stay small no matter how large the disassembly grows. Function bodies pack a function with its blocks so no per-block key repeats the entry address. Xrefs and strings pack many entries per small chunked blob row, holding row visits to the dozens on cache-hit opens; only diagnostics stay key-only, holding the whole row in the key.
Delete the sidecar to drop cached analysis and annotations; it is rebuilt
on the next load.
Size and upkeep
binscout stats <binary> reports the binary size (size), the sidecar
size (db_size, 0 before the first load), and the analysis counts
(functions/blocks/insns/xrefs/strings/annotations), so the
storage cost of a snapshot stays visible. Snapshots store block address
ranges rather than rendered instructions, so sidecars stay proportional
to the binary; CI caps the synthetic fixtures at 5 MiB to catch snapshot
bloat.
save rewrites every table, so repeated re-analysis can leave free pages
behind. There is no separate vacuum step: redb has no VACUUM command.
Call binscout::db::compact_db (wrapping redb::Database::compact) to
reclaim the space when a sidecar grows unexpectedly.
Never commit sidecars. Keep them out of version control:
*.rsdbg.redb
Performance
Repeated MCP-style investigation passes are cheap on small inputs and dominated by response serialization on large ones. This chapter records the method and the measured numbers behind that statement. Nothing here is a speedup claim, a deadline, or a CI gate.
Method
The harness is tests/mcp_workflow_perf.rs. Every test is #[ignore]:
default cargo test never runs it, and no assertion depends on
wall-clock speed. The one functional assertion is exact equality of the
canonical workflow output across scenarios. Canonical run:
cargo test --release --test mcp_workflow_perf -- --ignored --nocapture
Debug builds run the same harness but are slower and not comparable to the release numbers below.
Each test performs one warm-up rep (discarded), then 6 measured reps,
and prints min/median/mean/max of wall time (via std::time::Instant)
plus serialized response bytes. The workflow under test is one agent
investigation pass using the bounded views:
project_info → functions → func → blocks → block_insns → xrefs → strings
mapped to project_info, functions_resolved(0, 1024),
func_meta, func_blocks_page(_, 0, 1024),
func_block_insns_page(_, first_block, 0, 1024),
query_xrefs(None, None, None, 0, 1024), and
query_strings(&StringsFilter::default()). Every response is serialized
to JSON; the byte count covers the path-free canonical output so
fresh/cached runs are comparable exactly.
Three scenarios isolate the stages without any measurement hook in
src/:
- cold/no-sidecar: fresh fixture bytes and a nonexistent sidecar per rep — open time covers file read, content hash, and full analysis.
- saved-sidecar/new-process: one analyzed project is saved, then
each rep opens a new
Projectover the same paths — open time covers file read, hash, sidecar read, and layout replay, with no analysis. - repeated/same-process: one open, then repeated workflow passes — measures in-memory queries plus serialization only.
Fixtures
Both are deterministic and synthetic; no proprietary binary is involved.
- small:
pe32-basic.exebuilder fixture, 2048 file bytes — 1 function, 1 block, 5 instructions, 4 xrefs, 4 strings. - large: raw x86-64 blob at base
0x1000(nop× 1500,jmp +0× 1200,ret; the same shape as thefunction_pagesstress fixture) — 3901 file bytes, 1 function, 1201 blocks, 2701 instructions, 1200 xrefs, 0 strings (a code-only blob has no string hits; thestringsstep still runs and returns empty).
Results
Platform: macOS 27.0.1, arm64 (Apple Silicon), rustc 1.99.0,
cargo test --release, 1 warm-up + 6 measured reps per cell.
Response bytes are the serialized canonical workflow output.
| Fixture | Scenario | Open ms (median, min–max) | Workflow ms (median, min–max) | Total ms (median) | Response bytes |
|---|---|---|---|---|---|
| small | cold/no-sidecar | 0.06 (0.05–0.08) | 0.03 (0.03–0.04) | 0.10 | 2,461 |
| small | saved-sidecar/new-process | 0.06 (0.06–0.06) | 0.02 (0.02–0.03) | 0.08 | 2,461 |
| small | repeated/same-process | — | 0.02 (0.02–0.02) | 0.02 | 2,461 |
| large | cold/no-sidecar | 1.47 (1.40–1.55) | 2.82 (2.75–2.86) | 4.28 | 368,129 |
| large | saved-sidecar/new-process | 1.35 (1.33–1.37) | 2.82 (2.69–2.84) | 4.16 | 368,129 |
| large | repeated/same-process | — | 2.87 (2.74–2.91) | 2.87 | 368,129 |
Repeated runs vary ±10–15% run to run (machine noise); the table shows one representative run, not best-of-N.
Fresh and cached canonical outputs agree exactly in every rep of every scenario (asserted by the harness); only host paths differ.
Read plainly: at these scales the whole pass costs single milliseconds. On the small fixture everything is near timer resolution — the only sound reading is “negligible”, and it covers only these ≤3.9 KB fixtures. On the large fixture the workflow pass (~2.9 ms serializing ~368 KB: 1201 block rows, 1024 instruction rows, 1200 xrefs) exceeds either open path (~1.4–1.5 ms), and saved-sidecar reopen costs about the same as cold analysis — layout replay is not observably cheaper than reanalysis for a 3.9 KB input. Real-world binaries (megabytes, not kilobytes) behave differently: see the real-size spot check below, not this table.
MCP server cache
One binscout-mcp process keeps a 4-entry LRU of open projects keyed
by binary, sidecar, and mapping and revalidated by file length plus
mtime (see docs/book/src/mcp-tools.md). The first call for a binary
pays the full open; repeat calls only stat plus query. The regression
test tests/mcp_cache.rs:second_functions_call_is_ten_times_faster
drives two functions calls in one server session over a ~2.9 MB raw
x86-64 blob (900k nop into ret, one function, 900_001 decoded
instructions, plus 2M unreachable padding bytes) and asserts the
cached call is at least 10x faster than the first.
Platform: macOS 27.0.1, arm64 (Apple Silicon), rustc 1.99.0.
Client-side round-trip per functions call (one warm-up-free first
call, faster of two cached repeats):
| Build | First call (open + analyze + query) | Cached call (stat + query) | Ratio |
|---|---|---|---|
| debug | 6211.5 ms | 2.4 ms | ~2550x |
release (--release) | 719.0 ms | 0.2 ms | ~4600x |
Same-session outputs agree exactly (asserted by the test); no sidecar
is written by either call. The ratio is structural — full analysis
versus a stat plus HashMap lookup — not a tuned benchmark, so it
holds with wide margin on any machine: analysis scales with input
size while the hit path does not touch the binary at all (a companion
test keeps the binary chmod 000 after the first call and the cached
call still succeeds byte-identically).
Real-size spot check
A 6.5 MB Mach-O binary shows where the fixture table stops applying.
One representative release run, peak RSS via /usr/bin/time -l;
no assertion depends on these numbers and they are not a CI gate:
| Scenario | Wall time | Peak RSS |
|---|---|---|
| fresh load (no sidecar: file read, hash, full analysis) | 1.31 s | 760 MB |
| cache hit (sidecar replay, no analysis) | 0.42 s | 403 MB |
At real sizes the open dominates and costs seconds plus hundreds of megabytes resident, with replay about 3x faster than fresh analysis but still far from free. The “negligible” reading above covers only the ≤3.9 KB fixtures; size MCP timeouts, sidecar-warming strategy, and memory headroom from this spot check instead.
Limitations
- No in-process peak RSS. The harness has no platform memory API
without a new dependency, so resident size is an external step, e.g.
/usr/bin/time -l target/release/binscout <args>(macOS reportsmaximum resident set size). The harness records no RSS; the only RSS numbers here are the external spot-check readings above. - Warm page cache. Reps run back-to-back on one machine, so “cold” means no-sidecar, not cold-boot I/O. File read/hash costs are best-case.
- Timer resolution. Small-fixture cells sit at tens of microseconds; treat the distribution as order-of-magnitude only.
- No generalization. Two synthetic fixtures plus one single-run spot check do not predict real binaries. Do not cite these numbers as guarantees, do not encode them as CI timing assertions, and do not claim any speedup from them.
Contributing
The full guide lives in CONTRIBUTING.md. The short version — the gate for any change:
cargo test # full suite (unit + CLI/MCP e2e over fixtures)
cargo clippy --all-targets -- -D warnings
cargo fmt --check
cargo doc --no-deps # warning-free (`#![warn(missing_docs)]` is on)
Work is tracked with br/bd issues; file bugs and feature requests as
issues first and keep changes small and scoped. Commits follow
Conventional Commits: feat:
bumps minor, fix: bumps patch. New behavior needs a test; new public
API needs rustdoc. The project is dual-licensed MIT OR
Apache-2.0 — new files carry no headers, the license applies repo-wide.