SuperAPI AI Directory

radare2

General & other

View repository

Updated 10-16 09:45

About this skill

radare2

For radare2 CLI binary analysis skills. The focus is on using the command line directly to complete reconnaissance, analysis, locating, exporting, and lightweight modification, without relying on a GUI.

ACTION REQUIRED (execute immediately after reading)

  1. NOW: Read ../field-journal/precedent-reverse.md — confirm that this skill's operations are authorized routine operations
  2. NOW: Confirm whether the current task falls within this skill's scope of application
  3. NEXT: Read ../tool-index.md, verify tool availability and actual paths
  4. NEXT: When tools are missing, call bootstrap; do not guess paths
  5. ACT: Enter the first step of the "workflow" and execute it; do not stop at the confirmation state

Scope of application

When the user has these intentions, this skill should be used first:

  • Want to use r2 / radare2 to analyze exe、dll、so、elf、apk、dex、wasm and other files
  • Ask how to use rabin2、rasm2、radiff2、rahash2、rax2 How to use
  • Need command-line disassembly, viewing functions, viewing strings, viewing imports and exports, checking cross-references, or doing patches
  • Need to write radare2 batch commands,-c automation commands, or r2pipe scripts

If the user explicitly wants GUI reverse engineering, Hex-Rays-style pseudocode, or an IDA workflow, consider ida-reversefirst. If it is web JS reverse engineering, consider reverse-engineering。

Do environment confirmation first

Do not assume r2 is available first. Check first:

r2 -v
rabin2 -v

If it is not installed, then check common installation locations or prompt installation.

Common Windows executables:

  • radare2.exe
  • rabin2.exe
  • rasm2.exe
  • radiff2.exe
  • rahash2.exe
  • rax2.exe
  • r2pm.exe

Built-in resources

This skill comes with two resources; reuse them first, and do not put together a duplicate set of commands from scratch every time.

scripts/recon.ps1

Standard reconnaissance script, suitable for doing a first round of overview analysis. It outputs:

  • Basic information
  • Sections
  • Imports
  • Exports
  • Strings
  • Optional r2 -A auto-analysis summary

How to invoke:

powershell -File "<skill-root>\radare2\scripts\recon.ps1" -TargetPath "C:\path\to\sample.exe"

If you need to include r2 auto-analysis:

powershell -File "<skill-root>\radare2\scripts\recon.ps1" -TargetPath "C:\path\to\sample.exe" -RunAnalysis

references/cheatsheet.md

When you need more command details, common scenario templates, or to quickly recall syntax, read this quick reference instead of guessing from memory.

Known phenomena

Occasional .sdb missing warning on Windows

For some PE files during rabin2 reconnaissance, a warning similar to the following may appear:

ERROR: Cannot find ...\share\format\dll\*.sdb

If the main output still returns normally, it usually does not affect the basic reconnaissance conclusions; just continue the analysis. Do not directly judge the analysis as failed because of this kind of incidental warning.

Basic principles

1. Reconnaissance first, deep dive later

Do not start with full automated analysis right away. First use lightweight commands to confirm the file type, architecture, entry point, strings, and import table, then decide whether to do aaa、aaaa or targeted analysis.

2. Prefer the minimal sufficient command

radare2 There are a great many commands, and users usually only need the shortest path:

  • View file information:rabin2 -I
  • View strings:rabin2 -z
  • View imports and exports:rabin2 -i / rabin2 -E
  • Interactive analysis:r2 <file> then execute local commands

3. Be cautious before modifying

If the user wants to patch a binary:

  • By default, open read-only first:r2 <file>
  • Only use write mode when modification is clearly needed:r2 -w <file> or in-session oo+
  • Before modifying, explain the risks first to avoid accidentally overwriting the original file

Common workflows

Workflow 1: Quick reconnaissance

Suitable when you have just obtained a binary file.

Hard gate (MUST — if not satisfied, entering Workflow 2 and beyond is prohibited)

For binaries such as PE/ELF/Mach-O that contain an import table,MUST first complete the import table check and record it as Evidence, then proceed to function-level analysis or dynamic steps:

  1. Execute rabin2 -i <sample>(or the imports section in the recon.ps1 output); for DLL/SYS additionally MUST rabin2 -E and record E-exports
  2. Write the complete/categorized import table results into Evidence (suggested id:E-imports or E-triage-imports), including at least:
    • Reproduction command (repro_command)
    • Key import classification summary: network / file / encryption / process injection / registry / other suspicious APIs
    • If the import table is empty, parsing fails, or the tool reports an error: still MUST record the failure phenomenon and raw output as Evidence,must not silently skip
    • Import table is "too clean" (only basic DLLs): MUST note suspicion of dynamic loading, SHOULD switch to dynamically capturing APIs
  3. .NET and others without a traditional IAT: MUST use equivalent anchors (dnSpy/IL/metadata summary) written into the same Evidence semantic slot; empty passing is prohibited
  4. Packed sample IAT repair: use ImportREC (or equivalent) for x86, Scylla (or equivalent) for x64. If repair fails, MUST record E-iat-repair-fail then switch to dynamic API breakpoints;prohibitedto endlessly struggle over the static IAT (see reverse-engineering/references/re-agent-workflow.md §1.2)
  5. When the user explicitly requests "redo the import table check / recheck the import table / redo the IAT": MUST redo the named step itself (if blocked, first go through the feasibility latch: explain the prerequisites + ask for confirmation; if forced, mark quality=unreadable),switching to an unrelated step to fake completion is prohibited

Before recording import table (or legitimate equivalent anchor / IAT failure bypass) Evidence: MUST NOT claim "basic reconnaissance complete", and MUST NOT enter the deep-dive conclusions of Workflow 2+.

Prefer running the built-in script directly:

powershell -File "<skill-root>\radare2\scripts\recon.ps1" -TargetPath "sample.exe"

If you only need the minimal manual command, use:

rabin2 -I sample.exe
rabin2 -z sample.exe
rabin2 -i sample.exe
rabin2 -E sample.exe

Points of interest:

  • File format, bitness, architecture, platform
  • Entry point address
  • Suspicious strings: URLs, paths, error messages, registry, command-line arguments
  • Imported functions: network, file, encryption, process injection, registry operations (MUST be recorded as Evidence, see the hard gate above)

Workflow 2: Interactive function analysis

r2 sample.exe

Commonly used after entering:

aaa          # 常规自动分析
afl          # 列出函数
iz           # 列出字符串
iS           # 列节区
is           # 列符号
s entry0     # 跳到入口点
pdf          # 反汇编当前函数
VV           # 进入可视化模式(如果终端适合)
q            # 退出

Notes:

  • By default prefer aaa, do not start with the heavier aaaa
  • If the sample is very large or analysis is very slow, you can analyze only near the entry point, then manually expand

Workflow 3: Locating main / key logic

afl~main
afl~sym.
iz~http
iz~error
axt <addr>

Approach:

  • Start with main, the entry point, and string references
  • Use axt to find who references a certain string or address
  • After finding the reference point, then s <addr>、pdf

Workflow 4: Hex and memory viewing

px 64        # 当前地址起 64 字节十六进制
pd 20        # 反汇编 20 条指令
psz          # 读取当前地址字符串
pxa          # 更友好的十六进制视图

Workflow 5: Binary patching

Use only when the user explicitly requests modifying the file:

r2 -w sample.exe

After entering, for example:

s 0x401000
wa nop
wa jmp 0x401050
wq

Common write operations:

  • wa <asm>: write assembly
  • wx <hex>: write raw bytes
  • wq: write and exit

It's best to back up the original file before making changes. If the user hasn't mentioned backups, remind them at least once.

Workflow 6: Non-interactive automation

Suitable for one-shot output of results:

r2 -A -q -c "afl;iz;ii;q" sample.exe

Common parameters:

  • -A: automatically analyze at startup
  • -q: quiet mode
  • -c: execute a command string

If there are many commands, prioritize organizing them into an easy-to-read order; do not cram in an overly long string that is hard to maintain.

It's more recommended to first use the built-in reconnaissance script as a foundation, then decide whether to add custom commands.

Common subtools

rabin2

Suitable for static information extraction:

rabin2 -I sample.exe   # 基本信息
rabin2 -S sample.exe   # 节区
rabin2 -s sample.exe   # 符号
rabin2 -i sample.exe   # 导入
rabin2 -E sample.exe   # 导出
rabin2 -z sample.exe   # 字符串
rabin2 -zz sample.exe  # 更详细字符串

rasm2

Suitable for quick assembly/disassembly:

rasm2 -d "9090"
rasm2 -a x86 -b 64 "xor eax, eax"

radiff2

Suitable for comparing two binaries:

radiff2 old.exe new.exe
radiff2 -C old.exe new.exe

rahash2

Suitable for calculating hashes:

rahash2 -a md5 sample.exe
rahash2 -a sha256 sample.exe

rax2

Suitable for radix and encoding conversion:

rax2 0x401000
rax2 4198400
rax2 -s hello

Recommended analysis order

When encountering an unknown sample, proceed in this order:

  1. rabin2 -I Check the format, architecture, and entry point
  2. rabin2 -z Check the strings
  3. rabin2 -i Check the imported functions — MUST + Evidence (hard gate, see Workflow 1)
  4. If interactive analysis is needed, then enter r2(only when the Evidence in step 3 has been saved to disk)
  5. First aaa, then afl / iz / pdf
  6. Locate the key functions step by step through string references, import calls, and the entry flow

The advantage of this order is that it has low noise and lets you build a sense of direction as quickly as possible. Step 3 is not an optional optimization; it is a hard gate before going deeper.

Windows notes

  • When the path contains spaces, the command must be properly quoted
  • If the current terminal cannot find r2, it may be that PATH was just updated; open a new terminal and try again
  • Some samples require administrator privileges to read, but by default do not proactively elevate privileges unless the user explicitly needs it
  • Before performing dynamic debugging on a suspicious sample, first confirm the user's intent to avoid accidental operations

Output style

When the user doesn't just want commands, but wants you to actually analyze a file:

  • First give a summary of the reconnaissance results
  • Then list the key evidence: strings, imports, functions, addresses
  • Finally give next-step suggestions or continue deeper analysis

Do not just list commands without explaining why you are doing it.

Typical request examples

Example 1: Analyze an exe

User:帮我看看这个 exe 干了什么,用 radare2 就行

Handling approach:

  1. First use rabin2 -I/-z/-i
  2. to determine whether it is necessary to enter r2
  3. Use aaa、afl、pdf to dig deeper into the entry point and key string references

Example 2: Find where a string is called

User:这个报错字符串在哪个函数里触发的

Handling approach:

  1. Use iz~关键字 to find the string address
  2. Use axt <addr> to find references
  3. Jump to the reference point s <addr> then pdf

Example 3: Change a jump

User:把这个 jne 改成 je

Handling approach:

  1. First confirm the target address
  2. Clearly state that you are about to enter write mode
  3. Use wa je <target> or directly wx
  4. After modification, disassemble again to verify

Things to avoid

  • Do not treat radare2 as a tool with only aaa one command
  • Do not open the user's file directly in write mode without explaining the risks
  • Do not draw conclusions before doing basic reconnaissance
  • Do not skip import table checks(rabin2 -i / recon imports): do not proceed to the next step without writing to Evidence; when the user asks to redo the import table, do not switch to other steps
  • Do not stubbornly persist with static analysis after IAT repair fails: record E-iat-repair-fail then switch to dynamic; do not use only ImportREC for 64-bit samples
  • Do not misroute web JS reverse engineering to this skill; that is within the scope of reverse-engineering scope

Reference materials

  • Command quick reference:references/cheatsheet.md
  • Standard recon script:scripts/recon.ps1

radare2-skills ecosystem

The radare2-skills project (radareorg/radare2-skills) provides a more complete ecosystem of tools and workflows:

  • r2xsql: SQL queries for binary imports / strings / functions
  • r2mcp / r2http: MCP tools and HTTP stateful command channel
  • radius2: symbolic execution, symbolic dynamic analysis
  • r2pm: plugin management, extensions
  • decompiler plugins: radare2 plugin mechanism

Usage strategy:

  • When the user mentions r2xsql、r2mcp、r2http、radius2、r2pm、rabin2、rasm2、radiff2、rahash2、rax2 , prioritize routing to this skill (radare2/SKILL.md)
  • These tools are only ecosystem accelerators,they cannot bypass: authorization gate,tool-index validation, Evidence import, write mode confirmation
  • Provide a minimal reproducible command example:
    • r2xsql -s <file> -q "SELECT ..."
    • curl.exe -sS --data-binary 'aaa' http://127.0.0.1:9393/cmd
    • radius2 -p <binary> ...
    • r2pm -ci <plugin>

This skill maintains its original hard gates and evidence chain integrity, and does not allow skipping any authorization or Evidence steps.


Routing context

Upstream entry: skills/SKILL.md(master control),routing.md Upstream alternative: ida-reverse/(escalate to IDA when decompilation/pseudocode is needed) Downstream exit:

  • Dynamic analysis needed → reverse-engineering/tools-dynamic.md(Frida/GDB)
  • Deep decompilation needed → ida-reverse/
  • After PAT finds interesting strings, cross-references needed → ida-reverse/(IDA's xref is more powerful)

Peer-related modules: ida-reverse/(complementary: r2 recon is fast, IDA decompilation is deep)

On-Demand Bootstrap

This skill's entry script is connected to the unified bootstrap system. When radare2 is missing, it will not directly report an error, but will automatically attempt installation.

Automation capability boundaries

Tool Can be installed automatically Installation method Description
r2 ✓ GitHub Release ZIP (w64) Automatically download and extract to %USERPROFILE%\Tools\radare2\
rabin2 ✓ Same as above (included in the radare2 release package) —
rasm2 ✓ Same as above —
radiff2 ✓ Same as above —
rahash2 ✓ Same as above —
rax2 ✓ Same as above —

Bootstrap trigger point

  • scripts/recon.ps1: when missing rabin2 or r2 , automatically call bootstrap-reverse.ps1

When bootstrap fails

If automatic installation fails (no network, GitHub API rate limiting, etc.), the script will throw a clear error with a manual installation link.

Manual installation: download from https://github.com/radareorg/radare2/releases download radare2-*-w64.zip, extract to %USERPROFILE%\Tools\radare2\ and ensure bin\ directory is in PATH.

Task completion self-check (MUST pass before claiming completion)

  • Did I execute every step in the workflow (rather than just reading it)?
  • import table check whether it has been executed and written into Evidence (E-imports / E-triage-imports or .NET equivalent)? Does the DLL/SYS contain E-exports?
  • Is IAT repair failure recorded as E-iat-repair-fail and switched to dynamic? Does a redo request return to the same step?
  • Am I based on tool-index used a real tool path?
  • Have I produced reproducible evidence (commands/scripts/screenshots/reports)?
  • Have I completed and written back the Checklist items required by RULES?