radare2
Binary analysis skill for
CLI. Focuses directly on reconnaissance, analysis, localization, extraction, and lightweight modification via the command line, without relying on GUI.
ACTION REQUIRED(读完后立刻执行)
- : Read
../field-journal/precedent-reverse.md
— Confirm that the operations of this skill are authorized routine actions
- : Confirm whether the current task falls within the scope of this skill
- : Read to verify tool availability and actual paths
- : Call bootstrap when tools are missing; do not guess paths
- : Proceed to the first step of the "Workflow" and execute it; do not stay in the confirmation state
Scope of Application
Prioritize using this skill when the user has the following intentions:
- Analyze files such as , , , , , , using /
- Ask how to use , , , ,
- Need command-line disassembly, function inspection, string viewing, import/export inspection, cross-reference checking, and patching
- Need to write batch commands, automation commands, or scripts
If the user explicitly requests GUI reverse engineering, Hex-Rays-style pseudocode, or IDA workflows, prioritize
. For web JS reverse engineering, prioritize
.
Environment Confirmation First
Do not assume
is available. First check:
If not installed, check common installation locations or prompt installation.
Common executable files on Windows:
Built-in Resources
This skill comes with two built-in resources; prioritize reusing them instead of creating a new set of repetitive commands each time.
Standard reconnaissance script, suitable for initial overview analysis. It outputs:
- Basic information
- Sections
- Imports
- Exports
- Strings
- Optional automatic analysis summary
Calling method:
powershell
powershell -File "<skill-root>\radare2\scripts\recon.ps1" -TargetPath "C:\path\to\sample.exe"
If
automatic analysis is required:
powershell
powershell -File "<skill-root>\radare2\scripts\recon.ps1" -TargetPath "C:\path\to\sample.exe" -RunAnalysis
When more command details, common scenario templates, or quick syntax recall are needed, read this cheatsheet instead of guessing from memory.
Known Phenomena
Occasional Missing Alerts on Windows
When reconnoitering certain PE files with
, alerts similar to the following may appear:
text
ERROR: Cannot find ...\share\format\dll\*.sdb
If the main output is still returned normally, it usually does not affect the basic reconnaissance conclusion; continue the analysis first. Do not directly conclude that the analysis failed due to such incidental alerts.
Basic Principles
1. Reconnaissance First, In-Depth Analysis Later
Do not perform full automatic analysis right away. First use lightweight commands to confirm the file type, architecture, entry point, strings, and import table, then decide whether to perform
,
, or targeted analysis.
2. Prioritize Minimal Sufficient Commands
has numerous commands; users usually only need the shortest path:
- View file information:
- View strings:
- View imports/exports: /
- Interactive analysis: Execute local commands after
3. Be Cautious Before Modification
If the user wants to patch a binary:
- Open in read-only mode by default:
- Only use write mode when modification is explicitly needed: or in the session
- Inform the user of risks before modification to avoid unintentionally overwriting the original file
Common Workflows
Workflow 1: Quick Reconnaissance
Suitable when you just get a binary file.
Hard Gate (MUST — Prohibited from entering Workflow 2 and subsequent steps if not satisfied)
For binaries with import tables such as PE/ELF/Mach-O, MUST complete the import table check and record it as Evidence before proceeding to function-level analysis or dynamic steps:
- Execute (or the imports section in the output); for DLL/SYS files, additionally MUST execute and record it as
- Write the complete/classified import table results into Evidence (recommended ID: or ), which must include at least:
- Reproduction command ()
- Summary of key import categories: 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 original output as Evidence, silent skipping is prohibited
- If the import table is "too clean" (only basic DLLs): MUST note the suspicion of dynamic loading, SHOULD switch to dynamic API capturing
- For .NET and other files without traditional IAT: MUST use equivalent anchors (dnSpy/IL/metadata summary) and write to the same Evidence semantic slot; empty skipping is prohibited
- IAT repair for packed samples: Use ImportREC (or equivalent) for x86, Scylla (or equivalent) for x64. If repair fails, MUST record and switch to dynamic API breakpoints; prohibited to endlessly struggle with static IAT (see
reverse-engineering/references/re-agent-workflow.md
§1.2)
- When the user explicitly requests "redo import table check / recheck import table / redo IAT": MUST redo the specified step itself (if blocked, first go through the feasibility latch: explain prerequisites + request confirmation; if forced, mark quality=unreadable), prohibited to replace with irrelevant steps to pretend completion
Before recording the import table (or legal equivalent anchor / IAT failure bypass) as Evidence: MUST NOT claim "basic reconnaissance is completed", MUST NOT proceed to in-depth conclusions in Workflow 2+.
Prioritize running the built-in script directly:
powershell
powershell -File "<skill-root>\radare2\scripts\recon.ps1" -TargetPath "sample.exe"
If only manual minimal commands are needed, use:
powershell
rabin2 -I sample.exe
rabin2 -z sample.exe
rabin2 -i sample.exe
rabin2 -E sample.exe
Focus points:
- File format, bitness, architecture, platform
- Entry point address
- Suspicious strings: URLs, paths, error messages, registry entries, command-line parameters
- Imported functions: Network, file, encryption, process injection, registry operations (MUST record as Evidence, see the hard gate above)
Workflow 2: Interactive Function Analysis
Common commands after entering:
text
aaa # Regular automatic analysis
afl # List functions
iz # List strings
iS # List sections
is # List symbols
s entry0 # Jump to entry point
pdf # Disassemble current function
VV # Enter visualization mode (if terminal supports)
q # Exit
Notes:
- Prioritize by default; do not use the heavier at the beginning
- If the sample is large or analysis is slow, you can only analyze the area near the entry point first, then expand manually
Workflow 3: Locate main / Key Logic
text
afl~main
afl~sym.
iz~http
iz~error
axt <addr>
Approach:
- Start with , entry point, and string references
- Use to check who references a certain string or address
- After finding the reference point, use and
Workflow 4: Hexadecimal and Memory Viewing
text
px 64 # 64 bytes of hexadecimal starting from current address
pd 20 # Disassemble 20 instructions
psz # Read string at current address
pxa # More user-friendly hexadecimal view
Workflow 5: Binary Patching
Only use when the user explicitly requests file modification:
For example after entering:
text
s 0x401000
wa nop
wa jmp 0x401050
wq
Common write operations:
- : Write assembly
- : Write raw bytes
- : Write and exit
It is best to back up the original file before modification. If the user does not mention backup, remind them at least once.
Workflow 6: Non-Interactive Automation
Suitable for one-time result output:
powershell
r2 -A -q -c "afl;iz;ii;q" sample.exe
Common parameters:
- : Automatic analysis on startup
- : Quiet mode
- : Execute command string
If there are many commands, prioritize organizing them in a readable order; do not stuff them into an unmaintainable long string.
It is more recommended to use the built-in reconnaissance script first, then decide whether to add custom commands.
Common Sub-Tools
Suitable for static information extraction:
powershell
rabin2 -I sample.exe # Basic information
rabin2 -S sample.exe # Sections
rabin2 -s sample.exe # Symbols
rabin2 -i sample.exe # Imports
rabin2 -E sample.exe # Exports
rabin2 -z sample.exe # Strings
rabin2 -zz sample.exe # More detailed strings
Suitable for quick assembly/disassembly:
powershell
rasm2 -d "9090"
rasm2 -a x86 -b 64 "xor eax, eax"
Suitable for comparing two binaries:
powershell
radiff2 old.exe new.exe
radiff2 -C old.exe new.exe
Suitable for calculating hashes:
powershell
rahash2 -a md5 sample.exe
rahash2 -a sha256 sample.exe
Suitable for base and encoding conversion:
powershell
rax2 0x401000
rax2 4198400
rax2 -s hello
Recommended Analysis Sequence
When encountering an unknown sample, follow this sequence:
- Use to check format, architecture, entry point
- Use to view strings
- Use to view imported functions — MUST + Evidence (hard gate, see Workflow 1)
- If interactive analysis is needed, enter (only after the Evidence from step 3 is recorded)
- First run , then use / /
- Gradually locate key functions through string references, import calls, and entry process
The advantage of this sequence is low noise, allowing quick establishment of direction. Step 3 is not an optional optimization; it is a hard gate before proceeding to in-depth analysis.
Windows Notes
- When there are spaces in the path, the command must be properly quoted
- If cannot be found in the current terminal, it may be because the was just updated; try opening a new terminal
- Some samples require administrator privileges to read, but do not proactively elevate privileges by default unless explicitly requested by the user
- Before performing dynamic debugging on suspicious samples, confirm the user's intention to avoid misoperation
Output Style
When the user wants you to actually analyze the file instead of just providing commands:
- First provide a summary of reconnaissance results
- Then list key evidence: strings, imports, functions, addresses
- Finally provide suggestions for next steps or proceed with in-depth analysis
Do not just list commands without explaining why they are used.
Typical Request Examples
Example 1: Analyze an exe
User:
Help me figure out what this exe does, just use radare2
Handling method:
- First use
- Determine whether to enter
- Use , , to conduct in-depth analysis of the entry point and key string references
Example 2: Find where a string is called
User:
Which function triggers this error string
Handling method:
- Use to find the string address
- Use to find references
- Jump to the reference point with then use
Example 3: Modify a jump
Handling method:
- First confirm the target address
- Clearly inform the user that write mode will be entered
- Use or directly use
- Disassemble again after modification to verify
Practices to Avoid
- Do not treat as a tool with only the command
- Do not open the user's file in write mode without explaining the risks
- Do not draw conclusions before conducting basic reconnaissance
- Prohibited to skip import table check ( / recon imports): Cannot proceed to the next step without writing to Evidence; prohibited to replace with other steps when the user requests redoing the import table check
- Prohibited to endlessly struggle with static IAT after repair failure: Record then switch to dynamic analysis; prohibited to use only ImportREC for 64-bit samples
- Do not mislead web JS reverse engineering to this skill; that is within the scope of
References
- Command cheatsheet:
- Standard reconnaissance script:
Routing Context
Upstream Entries:
(master control),
Upstream Alternatives:
(upgrade to IDA when decompilation/pseudocode is needed)
Downstream Exits:
- Dynamic analysis required →
reverse-engineering/tools-dynamic.md
(Frida/GDB)
- In-depth decompilation required →
- Cross-reference needed after PAT finds interesting strings → (IDA's xref is more powerful)
Peer Associated Modules:
(complementary: r2 for fast reconnaissance, IDA for in-depth decompilation)
On-Demand Bootstrap
The entry script of this skill has been integrated into the unified bootstrap system. When radare2 is missing, it will not directly report an error but will automatically attempt to install it.
Automation Capability Boundaries
| Tool | Auto-installable | Installation Method | Description |
|---|
| r2 | ✓ | GitHub Release ZIP (w64) | Automatically download and extract to %USERPROFILE%\Tools\radare2\
|
| rabin2 | ✓ | Same as above (included in radare2 distribution package) | — |
| rasm2 | ✓ | Same as above | — |
| radiff2 | ✓ | Same as above | — |
| rahash2 | ✓ | Same as above | — |
| rax2 | ✓ | Same as above | — |
Bootstrap Trigger Points
- : Automatically calls when or is missing
When Bootstrap Fails
If automatic installation fails (network issues, 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, extract it to
%USERPROFILE%\Tools\radare2\
, and ensure the
directory is in the PATH.
Task Completion Self-Check (MUST pass before claiming completion)