/bnsql:decompilerfrom bnsql
Decompile Binary Ninja functions via HLIL: pseudocode text, local variables, call sites. Always filter by func_addr.
Ships in bnsql. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Binary Ninja's High Level IL is the closest thing to C-like pseudocode in BN. BNSQL exposes it through one SQL function and three tables.
| Surface | Description | Required filter |
|---|---|---|
decompile(addr) UDF | Full-function decompiled text | — (single address) |
decompile(addr, limit) UDF | Limit-aware variant | — |
pseudocode table | Line-level filtering by func_addr / addr | func_addr = X |
hlil_vars table | Local variables; writable (name, type, comment) | func_addr = X |
hlil_calls table | Call sites discovered in HLIL | func_addr = X or LIMIT (lazy) |
mlil table | MLIL-SSA (IR tier below HLIL); low-IR dataflow | func_addr = X |
ir_ops + ir_v_* views | Cross-tool canonical low-IR over mlil | func_addr = X |
Filter pseudocode/hlil_vars by func_addr — they materialize every
function. hlil_calls (and the expert _hlil_ast) stream lazily, so a bounded
LIMIT query is also cheap: it decompiles only the functions actually pulled.
-- Full function as one text block
SELECT decompile(0x401000);
-- Limit to 40 lines (good for surveys)
SELECT decompile(0x401000, 40);
SELECT name, type, storage
FROM hlil_vars
WHERE func_addr = 0x401000;
SELECT DISTINCT callee_name
FROM hlil_calls
WHERE func_addr = 0x401000;
SELECT line
FROM pseudocode
WHERE func_addr = 0x401000
AND line LIKE '%CreateFile%';
SELECT DISTINCT func_at(func_addr) AS caller
FROM hlil_calls
WHERE callee_name = 'malloc';
hlil_vars is writable on name, type, comment. Apply edits inside
the mutation loop:
-- 1. Read current state
SELECT name, type FROM hlil_vars
WHERE func_addr = 0x401000 AND name = 'var_8';
-- 2. Apply mutation
UPDATE hlil_vars
SET name = 'user_buffer', type = 'char *'
WHERE func_addr = 0x401000 AND name = 'var_8';
-- 3. Re-read to verify
SELECT name, type FROM hlil_vars
WHERE func_addr = 0x401000 AND name = 'user_buffer';
-- 4. Persist
SELECT save();
A hlil_vars name/type rename/retype reflects in the same session — the
re-read at step 3 shows the new name/type with no decompile(addr, ..., refresh=1).
The write marks the function for re-analysis and the write statement's commit
flushes it once, so a batch rename in one UPDATE flushes exactly once (O(1)) and
reads never wait. Var/pseudocode comment writes are immediate metadata.
The mlil table exposes Binary Ninja IL — by default MLIL in SSA form — the
register-transfer IR tier below HLIL (LLIL → MLIL → HLIL). It is the bnsql leg of the
cross-tool low-level IR. One row per instruction. Read-only. Use it for dataflow /
SSA-level analysis; use hlil_calls / hlil_vars for high-level analysis.
Always filter by func_addr — each query materializes IL per function, so an
unfiltered scan lifts the whole binary.
| Column | Description |
|---|---|
func_addr | Containing function (required filter) |
seq | Instruction index |
addr | Source address (NULL when synthetic) |
operation | Raw native IL operation value (LLIL/MLIL/HLIL per maturity) |
op_name | Native name, e.g. MLIL_SET_VAR_SSA / LLIL_SET_REG / HLIL_ASSIGN |
canonical_op | Cross-tool canonical P-code-style op — INT_ADD, CALL, STORE, …; empty when no clean canonical |
size | Operation size in bytes |
operand_count | Number of operands |
is_ssa | 1 on the *_ssa rungs, else 0 |
maturity | Returned IL form: llil|llil_ssa|mlil|mlil_ssa|hlil|hlil_ssa |
stage | Coarse ordinal: raw(llil)|optimized(mlil)|ssa(*_ssa)|final(hlil) |
WHERE maturity=…)By default mlil is lifted at MLIL-SSA (stage='ssa', is_ssa=1). Add
AND maturity='<rung>' to re-lift the same function at a different BN IL form — llil
is the lowest / most granular, hlil the most structured. The six-rung ladder, returned by
ir_maturities:
maturity | stage | ordinal | is_default | is_ssa |
|---|---|---|---|---|
llil | raw | 0 | 0 | 0 |
llil_ssa | ssa | 1 | 0 | 1 |
mlil | optimized | 2 | 0 | 0 |
mlil_ssa | ssa | 3 | 1 | 1 |
hlil | final | 4 | 0 | 0 |
hlil_ssa | ssa | 5 | 0 | 1 |
maturity is honest under coercion and is a passthrough filter — it pushes down to the
generator, and through ir_ops, so a maturity-scoped query still lifts only the requested
function(s).
mlil_operands (5-kind operand model)Structured value operands — one row per IL operand — projected onto the 5-kind model. Join
back to mlil on op_seq = seq. Structural operands (branch targets / SSA versions /
intrinsic ids) are excluded. Same func_addr/maturity pushdown.
| Column | Description |
|---|---|
func_addr | Containing function |
op_seq | Owning instruction's seq (joins mlil.seq) |
operand_index | Operand order within the instruction |
role | in or out (the destination operand) |
kind | reg | imm | mem | var | result |
text | Best-effort rendering (may be empty) |
value | Immediate value (NULL unless an imm) |
size | Operand size (0 when BN does not expose it) |
Cross-tool low-IR views. ir_ops is the canonical projection over mlil
(func_addr, seq, addr, op = canonical or NULL, native_op = native name,
is_ssa, maturity, stage). The portable semantic views ir_v_calls, ir_v_mem_writes,
ir_v_mem_reads, ir_v_branches, ir_v_arith (func_addr, seq, addr, op)
classify the op stream with the same names / columns as the other family tools.
ir_operands is the portable 8-column projection of mlil_operands, explicitly
fixed to the default mlil_ssa rung (join on both func_addr and
ir_operands.op_seq = ir_ops.seq). For an alternate rung, join ir_ops to native
mlil_operands with the same explicit maturity. ir_maturities advertises the
ladder. Scope the operation/operand streams by func_addr; the six-row ladder itself
does not need a function filter.
-- Raw MLIL-SSA for one function (default rung)
SELECT seq, op_name, canonical_op, hex(addr) AS addr
FROM mlil
WHERE func_addr = 0x401000;
-- The lowest tier (LLIL) of the same function — more granular
SELECT seq, op_name, canonical_op FROM mlil
WHERE func_addr = 0x401000 AND maturity = 'llil';
-- Canonical low-IR ops (portable across tools)
SELECT seq, op, native_op FROM ir_ops
WHERE func_addr = 0x401000;
-- Each op with its operands (engine-agnostic)
SELECT o.seq, o.op, p.role, p.kind, p.value
FROM ir_ops o JOIN ir_operands p ON p.func_addr = o.func_addr AND p.op_seq = o.seq
WHERE o.func_addr = 0x401000 AND o.maturity = 'mlil_ssa'
ORDER BY o.seq, p.operand_index;
-- Discover the lifting ladder
SELECT * FROM ir_maturities ORDER BY ordinal;
Note (documented divergence): MLIL-SSA top-level instructions are
statement-level, so arithmetic mostly nests inside SET_VAR_SSA sources — meaning
ir_v_arith is sparse at the default rung compared to the other tools' IR. Use mlil /
_hlil_ast (or maturity='llil') for expression-level arithmetic when the semantic view
comes up empty.
annotations for the broader mutation workflow (renames, comments, types)xrefs for the surrounding call graph contexttypes for type creation and application to variablesDecompiler tables are on-demand virtual tables — each row requires
decompiling its containing function. Unconstrained queries iterate every
function and decompile each one. On a medium binary that's minutes-to-hours.
Always pin to a specific func_addr.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
11 skills in this plugin
/analysisBNSQL analysis workflows: triage, security audit, crypto/network detection, multi-table queries./annotationsEdit Binary Ninja databases: comments, renames, types, patches. Mutations require SELECT save() to persist (explicit-save model, v0.0.9+)./connectConnect to Binary Ninja databases and bootstrap sessions. Use when starting analysis, routing to other skills, or setting up CLI/HTTP/MCP connections./dataQuery Binary Ninja strings, bytes, and binary patterns. Use the byte_search table for fast byte-pattern search.npx claudepluginhub 0xeb/bnsql-skills --plugin bnsql