Queries binary data via Ghidra SQL: strings, bytes, hex patterns, data items, memory blocks, and relocations. Useful for reverse engineering and binary analysis.
Ships in ghidrasql. 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.
Read when SKILL.md points to them.
Use this skill when the user asks to:
Route to:
xrefs when string or data references matter (use the native string_refs table)analysis for higher-level suspiciousness or summarizationannotations if the next step is naming or typing the datadebugger for byte patches via UPDATE bytes| Surface | Predicate | Pushdown? | Notes |
|---|---|---|---|
strings | any | Indexed | Cheap |
data_items | exact addr = X or bounded addr range | Yes | Native defined-data iterator restricted to the window; name/type filters alone scan all defined data |
bytes | addr = X or range | Yes (streamed window) | Point/range predicates stream only the window; an unconstrained scan visits every mapped byte |
byte_search | required pattern; optional bounds / result cap | Yes (lazy pages) | 32 Ki candidate pages with overlap; SQL LIMIT and max_results stop future reads |
memory_blocks, segments | any | Indexed | Cheap, small cardinality |
relocations | any | Indexed | Cheap |
Composition views: memory_layout, memory_hexdump, memory_byte_detail, memory_byte_items, typed_data_items, relocation_map, string_hotspots. string_refs is a native table with a bounded function-reference lookup.
Lightest useful surface — strings:
SELECT printf('0x%X', addr) AS addr, length, type, encoding, content
FROM strings
WHERE content LIKE '%password%'
ORDER BY addr
LIMIT 50;
type and encoding come from Ghidra. Run SELECT DISTINCT type, encoding FROM strings; to enumerate what's present on this binary.
Bounded FlexHex byte-pattern search:
SELECT printf('0x%X', addr) AS addr, matched_hex
FROM byte_search
WHERE pattern = '48 8B ?? 4?'
AND start_addr = 0x401000
AND end_addr = 0x402000
ORDER BY addr
LIMIT 20;
end_addr is exclusive. Search runs in bounded pages, includes the overlap needed
for cross-page matches, and stops fetching pages once LIMIT or max_results is met.
Defined data in a bounded address window:
SELECT printf('0x%X', addr) AS addr, name, data_type, size, value_repr
FROM data_items
WHERE addr BETWEEN 0x401000 AND 0x401100
ORDER BY addr;
Exact addresses and BETWEEN, >=, >, <, <= bounds restrict the source
iterator. Name/type predicates alone, including the global examples below,
still enumerate all defined data. LIMIT alone does not bound that work.
Typed globals (only data items that have a Ghidra-recognised type):
SELECT printf('0x%X', addr) AS addr, name, data_type, size
FROM data_items
WHERE data_type IS NOT NULL AND data_type != ''
ORDER BY addr
LIMIT 50;
Discover the actual data_type values on this binary (don't hard-code — the set varies by binary, processor, and Ghidra version):
SELECT DISTINCT data_type
FROM data_items
WHERE data_type IS NOT NULL AND data_type != ''
LIMIT 50;
Typical results include Ghidra primitives (byte, word, dword, undefined1/2/4/8, pointer, string, unicode, TerminatedCString, TerminatedUnicode). Format-specific structures (PE, ELF, Mach-O, etc.) appear when Ghidra recognises the container — names depend on the binary in front of you. Don't hard-code — enumerate live.
Hexdump for a specific address:
SELECT *
FROM memory_hexdump
WHERE addr = 0x403000;
Memory blocks (per-segment metadata; perm flags as is_read, is_write, is_exec):
SELECT printf('0x%X', start_addr) AS start,
printf('0x%X', end_addr) AS end,
name, class, size,
is_read, is_write, is_exec
FROM memory_blocks
ORDER BY start_addr;
Relocations (note: table is named relocations, not relocation_items):
SELECT printf('0x%X', addr) AS at,
printf('0x%X', target_addr) AS target,
reloc_type, width, symbol_name
FROM relocations
ORDER BY addr;
Create a typed data item only after verifying that the target is an unused,
writable data address (replace <unused_data_addr> with that address):
INSERT INTO data_items (addr, data_type)
VALUES (<unused_data_addr>, 'dword');
Functions that reference a string — use the native string_refs table, which pre-attributes the function context:
SELECT printf('0x%X', func_addr) AS func, func_name, string_value
FROM string_refs
WHERE string_value LIKE '%error%'
ORDER BY func_addr
LIMIT 50;
For "which strings are referenced most", use string_hotspots.
imports is EmptySome PE binaries (packed, stripped, or unusually crafted) parse with imports empty but their IAT entries surface as data_items named PTR_<API>_<address>.
SELECT printf('0x%X', addr) AS addr, name
FROM data_items
WHERE name LIKE 'PTR_%'
ORDER BY name
LIMIT 50;
If this fallback returns rows, route the agent to think of those as imports for fan-in / call-target analysis.
An address at or above 0x8000000000000000 is a negative INTEGER in SQL, so
ORDER BY addr lists the high half first and bytes / byte_search stream it
first. Write high addresses as hex literals (or the negative decimal), never as a
decimal >= 2^63 (a REAL that matches nothing), and scope the high half with
BETWEEN <high hex> AND -1 -- addr >= <high hex> also includes every low
address:
-- Bytes of a kernel-half range, in address order
SELECT printf('0x%X', addr) AS addr, value, source_kind
FROM bytes
WHERE addr BETWEEN 0xFFFFF80000100000 AND 0xFFFFF800001000FF
ORDER BY addr;
-- Pattern matches in the high half only
SELECT printf('0x%X', addr) AS addr, hex(matched_bytes) AS bytes
FROM byte_search
WHERE pattern = '48 8B ?? 4?' AND addr BETWEEN 0xFFFFF80000000000 AND -1
ORDER BY addr;
byte_search's start_addr / end_addr are plain unsigned scan bounds (a
match starts at or after start_addr and before end_addr); a match must fit
inside one memory block, which may straddle 2^63. hex(matched_bytes) renders
the bytes as uppercase hex digits, as SQLite's hex() does for a BLOB. A block's
end_addr is exclusive and modulo 2^64: the block through 0xFFFFFFFFFFFFFFFF
reads end_addr = 0, and one straddling 2^63 reads an end_addr below its
start_addr; size is always the byte count.
bytes queries bounded by addr — constrained queries stream only the requested window; an unconstrained scan streams every mapped byte.strings, data_items, memory_hexdump, memory_blocks, relocations over raw byte scans.string_refs (read it as a data query, then route to xrefs if you need callers).What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
/ghidrasql:datafrom ghidrasql
npx claudepluginhub 0xeb/ghidrasql-skills --plugin ghidrasql12 skills in this plugin
/debuggerManage breakpoints and patch bytes through ghidrasql — the breakpoints table and bytes single-byte UPDATE.Other plugins' skills for the same job