r2js
Execute arbitrary radare2 commands and r2js scripts via r2xsql when SQL surfaces are insufficient. Use for custom analysis passes, ESIL emulation, anything…
от radareorg★ 23 звезды на GitHub
Установить r2js в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
When to use
Pick this skill when SQL alone can't answer the question:
- r2 commands not surfaced as tables (e.g. ESIL emulation,
aae*,agCcall-graph dump,p8raw-byte read at an address,wxto patch bytes, …) - multi-step r2 scripts where each step depends on r2 state, not just table data
- custom analyses written in r2js (
#!js) — typed JS that runs inside r2 with full SDK access - pivoting from SQL results back into r2 (e.g. drop temporary flags so the next SQL query sees them)
How r2xsql exposes raw r2 access
The plugin shares its host radare2's RCore through LibrBackend. There is
no r2xsql CLI or internal r2pipe backend. Send raw commands directly to the
host through the same transport that carries sql and sqlj:
| transport | syntax |
|---|---|
| r2 console | you are already at an r2 prompt: type the command, e.g. pdf @ entry0 |
r2 HTTP (=h) |
POST /cmd/ with the command as the body, e.g. -d 'pdf @ entry0' — no SQL escape hatch needed, it is the same endpoint the SQL goes to |
| in-r2 plugin | the host RCore * is the r2 shell already |
| r2js inside r2 | r2cmd("aflj") returns JSON; round-trip via SQL |
| temp flags bridge | r2js writes flags, SQL reads them via flags table |
Recommended pattern: do the analysis pass in r2js, persist its results as r2 flags / comments, then query those from SQL.
Recipe — emulate a function and capture register state
// my_emulate.r2.js
const target = 0x401000;
r2cmd(`s ${target}`); // seek
r2cmd("aei; aeim; aeip"); // init ESIL, mem, ip
for (let i = 0; i < 50; i++) r2cmd("aes"); // step 50 instructions
const regs = r2cmd("arj"); // dump registers as JSON
const rax = JSON.parse(regs).rax;
r2cmd(`CC ESIL: rax=${rax.toString(16)} after 50 steps @ ${target}`);
Then SQL-side:
SELECT text FROM comments WHERE text LIKE 'ESIL:%';
Recipe — bridge query → r2js → query
SQL: find candidate addresses.
SELECT addr FROM funcs WHERE cc > 25;r2js: feed each address into a custom pass that doesn't fit SQL:
const addrs = [0x401000, 0x402000]; // from step 1 addrs.forEach(a => { r2cmd(`s ${a}`); const summary = r2cmd("agCd"); // some non-tabular output r2cmd(`f sym.complex_${a.toString(16)} 1 ${a}`); // tag it });SQL: re-query and the tags are visible:
SELECT name, addr FROM flags WHERE name LIKE 'sym.complex_%';
Raw hex byte patching → use the patches table, not r2js
r2xsql has a SQL write surface for this: INSERT INTO patches(addr, patched_bytes) VALUES(...) stages a raw hex patch, UPDATE patches SET committed = 1 WHERE addr = ... commits it (see the data skill's
patches section for the full column set and the commit/undo scoping
caveats — commit is table-wide, undo is stack-top-only). Reach for r2js
only when patches can't express what you need, such as a string or
zero-terminated write (wz). For an assembled instruction, use
INSERT INTO patches(addr, asm_text) VALUES (0x401234, 'nop').
r2cmd("wz example @ 0x401234"); // direct zero-terminated string write
r2cmd("Ps demo"); // save the analysis project
Caveats
- Raw r2 commands bypass the SQL table layer. You're responsible for parsing
whatever r2 prints. C++ embedders can use
Session::raw_cmdfor this; plugin users send commands to radare2 itself. - r2js scripts run inside r2 (not inside r2xsql) — they don't see the SQL database directly. Bridge via flags/comments as above.
- Use the r2 console, an external r2pipe client's
cmd(), or radare2'sPOST /cmd/endpoint. Send the raw command as-is; there is no.r2cmdwrapper. External r2pipe clients remain supported as radare2 transports.
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
- 01
Bash - 02
Read
FAQ
Что делает скилл r2js?
Execute arbitrary radare2 commands and r2js scripts via r2xsql when SQL surfaces are insufficient. Use for custom analysis passes, ESIL emulation, anything r2's tables don't expose, or to bridge SQL queries with r2 SDK behavior.
Как установить скилл r2js?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл r2js запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
AnthropicCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
discernment-nudge
AnthropicAfter you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
data-consolidate
AnthropicJoins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
inspection-to-capa
AnthropicRuns the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…