/bnsql:datafrom bnsql
Query Binary Ninja strings, bytes, and binary patterns. Use the byte_search table for fast byte-pattern search.
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.
| Surface | Description |
|---|---|
strings | All discovered strings (content, length, addr, type) |
string_refs | Strings joined with the functions that reference them |
| Surface | Kind | Description |
|---|---|---|
byte_search(pattern) | table (query with FROM) | Rows addr, matched_hex, matched_bytes, size — all matches |
byte_search(pattern, start, end) | table | Same columns, matches starting in [start, end) (unsigned bounds) |
search_first(pattern) | scalar | First match address (or NULL) |
hex(val) | scalar | An integer as 0x-prefixed hex (unsigned); a BLOB or TEXT as uppercase hex digits |
bytes table-- 16 bytes at 0x401000 as uppercase hex
SELECT hex(blob_concat(value)) FROM (
SELECT value FROM bytes
WHERE start_addr = 0x401000 AND n = 16
ORDER BY addr);
-- The same 16 bytes as a BLOB
SELECT blob_concat(value) FROM (
SELECT value FROM bytes
WHERE start_addr = 0x401000 AND n = 16
ORDER BY addr);
Each row is addr, value and is_initialized. A byte is initialized (is_initialized = 1, value 0-255) when it holds loaded data: bytes from the file and bytes of a data memory region added through Binary Ninja's memory map (its segment reports data length 0, but the bytes are loaded). A BSS tail, an unbacked segment and an unbacked (fill) memory region are mapped but uninitialized: is_initialized = 0 and value NULL. byte_search searches exactly the initialized bytes.
Replace 0x401000 and 16 with the desired start and byte count. start_addr and n are hidden input columns paired for bounded reads. start_addr is deliberately distinct from the visible addr column so any user predicate on addr (e.g. inside a JOIN) stays enforceable by SQLite. Use the patches table for byte patching.
An address at or above 0x8000000000000000 (a kernel image at 0xFFFFF800...)
is a negative INTEGER in addr, so ORDER BY addr lists the high half first,
then the low half. bytes and byte_search return and order such rows exactly
as SQLite would.
0xFFFFF80000100000) or the negative
decimal (-8796091973632), never as a decimal >= 2^63: SQLite reads
18446735277617577984 as a REAL and the predicate matches nothing.addr >= 0xFFFFF80000000000 also matches the whole low half. For the high half
only: addr BETWEEN 0xFFFFF80000000000 AND -1.start_addr + n read that crosses 0x7FFFFFFFFFFFFFFF still yields N
rows, and ORDER BY addr lists the part at or above 2^63 first. To
concatenate such a read in memory order, sort unsigned: ORDER BY addr < 0, addr.
A read may run up to 0xFFFFFFFFFFFFFFFF, a valid Binary Ninja address that no
segment holds (its value is NULL); the last byte a segment can hold is
0xFFFFFFFFFFFFFFFE.-- The first 16 mapped bytes of the high half, in address order
SELECT hex(addr) AS addr, value FROM bytes
WHERE addr BETWEEN 0xFFFFF80000000000 AND -1
ORDER BY addr LIMIT 16;
-- 16 bytes across 2^63, concatenated in memory order
SELECT hex(blob_concat(value)) FROM (
SELECT value, addr FROM bytes
WHERE start_addr = 0x7FFFFFFFFFFFFFF8 AND n = 16
ORDER BY addr < 0, addr);
"48 8B 05" — Exact bytes (hex)"48 ?? 05" — ?? = any byte wildcard"4?" / "?F" — single-nibble wildcard (4? matches 40–4F)-- Interesting strings
SELECT content, hex(addr) AS addr
FROM strings
WHERE length > 10
ORDER BY length DESC
LIMIT 20;
-- Password-related
SELECT content, hex(addr) AS addr
FROM strings
WHERE content LIKE '%password%';
SELECT s.content, hex(s.addr) AS str_addr,
sr.func_name, hex(sr.func_addr) AS func_addr
FROM string_refs sr
JOIN strings s ON s.addr = sr.string_addr
WHERE s.content LIKE '%error%';
-- Find all RDTSC instructions (opcode: 0F 31) — table-valued, query with FROM
SELECT printf('0x%X', addr), matched_hex FROM byte_search('0F 31');
-- Just the addresses
SELECT addr FROM byte_search('48 8B ?? 00') LIMIT 10;
-- Range-limited search
SELECT addr FROM byte_search('48 8B', 0x140001000, 0x140002000);
-- First match only (scalar)
SELECT printf('0x%X', search_first('CC CC CC'));
Order and high addresses: matches come back in addr order as SQL sorts
it, so a match at or above 0x8000000000000000 (a negative addr) comes before
the low-half matches, and ORDER BY addr LIMIT n is free. start_addr /
end_addr are plain unsigned bounds on where a match starts; to keep only
kernel-half matches filter on addr, since addr >= <high hex> includes the low
half too. search_first returns the lowest match in unsigned address order.
-- Kernel-half matches only, in address order
SELECT hex(addr) AS addr, matched_hex FROM byte_search('48 8B ?? 00')
WHERE addr BETWEEN 0xFFFFF80000000000 AND -1
ORDER BY addr;
-- Count unique functions using RDTSC
SELECT COUNT(DISTINCT func_start(addr)) AS count
FROM byte_search('0F 31')
WHERE func_start(addr) IS NOT NULL;
-- List those functions
SELECT DISTINCT func_start(addr) AS func_addr, name_at(func_start(addr)) AS func_name
FROM byte_search('0F 31')
WHERE func_start(addr) IS NOT NULL;
This is much faster than scanning all disassembly lines:
byte_search lazily scans initialized mapped bytes in bounded pages (table-valued, no JSON)func_start() is O(1) lookup in the function indexSELECT hex(blob_concat(value)) FROM (
SELECT value FROM bytes
WHERE start_addr = 0x401000 AND n = 16
ORDER BY addr);
xrefs for finding the call sites of functions that contain a found
patterndisassembly for the surrounding instruction context (disasm(addr))What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub 0xeb/bnsql-skills --plugin bnsql11 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./decompilerDecompile Binary Ninja functions via HLIL: pseudocode text, local variables, call sites. Always filter by func_addr./disassemblyQuery Binary Ninja disassembly: functions, segments, instructions, blocks. Use for code-level analysis and instruction inspection./functionsComplete bnsql SQL function reference catalog.