Expertise in reverse engineering binaries using radare2 (r2). Use this to analyze executables (ELF, PE, Mach-O), decompile code, disassemble code, find functions, extract exports/imports, extract strings, patch binaries, and debug programs.
Radare2 (r2) is a complete framework for reverse engineering and binary analysis.
When reviewing code, follow this workflow:
aa to identify all the function prologues and aae to analyze the binary using emulation.i to get binary information.ii.iE.afl.iz.list_sessions to get a valid session. INSTEAD use use run_command to run command i to get binary information to verify there is a valid r2 session opened using r2mcp.To get the dissassembly of a function:
af.pdf to get the function disassembly.Always use r2ghidra to decompile a function.
To get the decompilation of a function:
af.pdg to get the decompiled code using r2Ghidra. capture the output as the RAW block. Do not alter spacing, names, or formatting.s moves the cursor (address) and most commands operate at the current seek.aa creates functions, basic blocks, xrefs, types, etc.f, fs, f~...) — strings, functions, symbols show up as flags.~ pattern to filter output quickly. Use ~+ to do it case-insensitive.j at the end of any command for JSON output (great for scripts): ij, aflj, izj.| Command | Description |
|---------|-------------|
| aaa | Analyze all (functions, refs, calls) |
| afl | List all functions |
| s addr | Seek to address |
| s main | Seek to main function |
| pdf | Print disassembly of current function |
| pd 20 | Print 20 instructions |
| Command | Description |
|---------|-------------|
| i | File information |
| ie | Entrypoints |
| iS | Sections |
| ii | Imports |
| iE | Exports |
| iz | Strings in data sections |
| izz | All strings in binary |
| Command | Description |
|---------|-------------|
| axt addr | Find xrefs to address |
| axf addr | Find xrefs from address |
| afx | Xrefs in current function |
| Command | Description |
|---------|-------------|
| V | Visual mode |
| VV | Graph mode |
| v | Visual panels |
| Command | Description |
|---------|-------------|
| db addr | Set breakpoint |
| dc | Continue execution |
| ds | Step instruction |
| dso | Step over |
| dr | Show registers |
| dm | Memory maps |
| Command | Description |
|---------|-------------|
| /x 9090 | Search hex bytes |
| / string | Search string |
| /R pattern | Search ROP gadgets |
| /c opcode | Search assembly pattern |
| Command | Description |
|---------|-------------|
| wa nop | Write assembly at current position |
| wx 90 | Write hex bytes |
| wao nop | Write opcode (replaces instruction) |
r2 -A binary
> i # Basic info
> iS # Check sections
> afl # List functions
> s main # Go to main
> pdf # Disassemble
r2 binary
> izz~password # Search for "password" in strings
> izz~flag # Search for "flag"
> axt @@ str.* # Find xrefs to all strings
r2 -A binary
> afl~sym. # List imported functions
> axt sym.strcmp # Find where strcmp is called
> s [address]
> pdf
r2 -w binary
> s 0x401000 # Seek to instruction
> pd 1 # View current instruction
> wa jmp 0x401050 # Patch with jump
> wao nop # Or NOP it out
r2 -d binary
> aaa
> db main # Break at main
> dc # Run
> dr # View registers
> ds # Step
> px 32 @ rsp # View stack
For large binaries, avoid re-analyzing on every command. Use one of these approaches:
Start r2 with HTTP server, then send commands via curl:
# Terminal 1: Start server (keeps session alive)
r2 -q -c 'aaa; =h 9090' binary
# Terminal 2+: Send commands without re-analyzing
curl -s "http://localhost:9090/cmd/afl"
curl -s "http://localhost:9090/cmd/pdf%20@%20main"
curl -s "http://localhost:9090/cmd/axt%200x401000"
import r2pipe
r2 = r2pipe.open("binary")
r2.cmd("aaa") # Analyze once
# Now run many commands on same session
print(r2.cmd("afl"))
print(r2.cmd("pdf @ main"))
print(r2.cmd("izz~flag"))
# Session stays open until:
r2.quit()
r2 binary
> aaa # Analyze (slow)
> Ps myproject # Save project
> q
# Later, restore instantly:
r2 -p myproject binary
> afl # No re-analysis needed
# Create pipe and start r2
mkfifo /tmp/r2pipe
r2 -q -i /tmp/r2pipe binary &
# Send commands
echo "aaa" > /tmp/r2pipe
echo "afl" > /tmp/r2pipe
aa instead of aaa for faster initial analysise anal.depth=5af @ 0x401000r2 -n binary then analyze on-demandrabin2 for quick info without loading into r2For one-off commands, use r2 with -q (quiet) and -c:
# List all functions
r2 -q -c 'aaa; afl' binary
# Disassemble main
r2 -q -c 'aaa; s main; pdf' binary
# Get strings containing "flag"
r2 -q -c 'izz~flag' binary
# Get imports
r2 -q -c 'ii' binary
# Analyze and output JSON
r2 -q -c 'aaa; aflj' binary | jq .
rabin2 -I binary # File info
rabin2 -z binary # Strings
rabin2 -i binary # Imports
rabin2 -e binary # Entrypoints
rabin2 -S binary # Sections
rasm2 -a x86 -b 64 'nop' # Assemble
rasm2 -a x86 -b 64 -d '90' # Disassemble
rasm2 -a arm -b 32 'mov r0, 1' # ARM assembly
rahash2 -a md5 binary
rahash2 -a sha256 binary
rahash2 -a all binary
rafind2 -x 4141 binary # Find hex pattern
rafind2 -s "flag" binary # Find string
e asm.syntax=att for AT&T syntaxe asm.arch=arm and e asm.bits=32 or 64e asm.bits=16e asm.arch=mipse cfg.bigendian=true/false? after any command for help: pd?, a?, s?j for JSON output: aflj, ij, izjq for quiet output: aflq@@ for iteration: pdf @@ fcn.*~ for grep: afl~main~: for column selection: afl~:0Ps name and load with Po nameSee references/REFERENCE.md for advanced usage.
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer