When to use / when not to use
- Use: command-line/scripted analysis; low-memory (<4GB) or remote environments (GUI decompilers cannot run); quick disassembly and cross-references;
pdf/Vmode exploration; firmware/batch sample scripted analysis - Use: SSH/CI environments without a GUI (rz is pure terminal,
-q -cone-line batch processing) - Don't use: when mature GUI decompilation and type propagation are needed (use [[re-ghidra]])
- Don't use: when only preliminary triage conclusions are needed ([[re-triage]])
- Don't use: when Windows user-mode debugging is the main task ([[re-x64dbg]] / [[re-windbg]] are handier; the rz debugger has limited capabilities on Windows)
Tool preparation
See [[re-analyze/platform-tips]] -- command-line tools suit remote/low-memory environments; the platform branch's Wine/QEMU user-mode emulation experience also applies.
rizin (active fork of radare2)
- macOS:
brew install rizin - Arch:
pacman -S rizin - Fedora/RHEL(EPEL 8+):
dnf install rizin(packages available for Fedora's currently supported versions and EPEL 8/9/10); for EOL Fedora, check the distro repositories first, and if no package exists use the official release orrz-pm - Debian/Ubuntu: repository has no rizin package,
apt install rizinwill fail-- switch to the official release binaries (GitHub rizinorg/rizin releases: static tar.xz / Windows zip / macOS pkg) orrz-pm - Kali:
apt install rizin(Kali's own repository has packages, provided the official Kali sources are used) - Windows: the official release zip can be unzipped and used directly (
rz-bin.exe) - Verify:
rizin -v、rz-bin -V - Note: distro package status changes over time, check the target distro repositories before installing; success or failure is always determined by
rizin -v. When other skills need rizin installation steps, reference this matrix here rather than copying distro commands individually.
radare2 compatibility layer (legacy command system)
- Linux:
apt install radare2/dnf install radare2/pacman -S radare2 - macOS:
brew install radare2 - Windows:
choco install radare2 - Verify:
r2 -v - Note: rz and r2 commands are largely compatible (
pdf/axt/Vare the same), but plugin names and a few commands differ (noted below)
rz-ghidra decompiler plugin
- All platforms:
rz-pm -ci rz-ghidra(rizin package management, requires network and a build toolchain) - Verify: inside rizin,
pdg @ maincan output pseudo-C
Procedure
-
rizin -Afully automatic analysis:rizin -A sampleWait for the analysis-complete prompt (for large files, observe by paging with
p).-Ais equivalent toaaa(full automatic analysis: functions/cross-references/string references). For shallow analysis only, use-a x86and other on-demand parameters. Exit:q。- Enter interactive mode directly with no parameters and analyze later:
aaa; lightweight versionaa(functions + string references, first choice for large files) - Function list:
afl; single-function info:afi @ main; manually define a function:af @ 0x401000
- Enter interactive mode directly with no parameters and analyze later:
-
pdfdisassemble function:[0x00001040]> pdf @ sym.main- When stripped, first find the entry:
izz~entryoraf @ 0x401000manually define the function and thenpdf @ 0x401000 pdf= print disassembly function;pd 20= print 20 instructions;pdrprint with references- When analysis noise is mixed in, use
pdf @ <addr> | grep callto filter calls - Rename:
afn 新名字 @ 地址; comment:CCu 注释 @ 地址
- When stripped, first find the entry:
-
axtcross-references:[0x00001040]> axt @ 0x403000 # 谁引用 0x403000 [0x00001040]> axf @ sym.main # main 引用了谁String references:
izzlist all strings,axt @ str.<名称>Find reference points (strings already auto-named).- Locate chain:
izzfind key string →axt @ str.xxx→ jump to referencing functions <地址>→pdf—same idea as [[re-ida]]'s Alt+T→x→F5
- Locate chain:
-
Visualization
Vmode:[0x00001040]> Vpswitch view (disassembly/hex/graph)sfollowed by address/symbol jump (s sym.main);fdefine function;ddisassembly toggle- Graph view (function flow):
Vpresspto graph view, navigate with arrow keys—use for mapping control flow - Exit V:
q; exit rizin: thenq
-
Scripting and rz-ghidra decompilation:
# 一行命令批处理 rizin -q -c 'aaa; pdf @ sym.main; axt @ 0x403000; quit' sample# 反编译 rz-pm -ci rz-ghidra rizin -c 'aaa; pdg @ sym.check' samplepdg= Ghidra-style pseudo-C output; without the plugin, fall back topdf+ manual reconstruction.- Script file:
rizin -i script.r2 sample(or in interactive mode. script.r2); in the script, one command per line, ending withquitend
- Script file:
-
Debug mode (rz built-in debugger):
rizin -d ./sample # 以调试模式启动 rizin -d -p 1234 # attach pid[0x7f...]> db 0x401000 # 断点(db = debugger breakpoint,与 r2 相同) [0x7f...]> dc # 继续(continue) [0x7f...]> ds / dso # 单步 / 步过 [0x7f...]> dr eax=0 # 改寄存器(绕过校验常用) [0x7f...]> px @ rsp # 看栈内容 [0x7f...]> drr # 全部寄存器- Breakpoint table:
db(lists with no arguments); delete breakpoint:db- 地址; conditional breakpoint:db 地址:条件(e.g.db 0x401000:eax==1) - For differences between debugging and gdb, see [[gotchas]]; for the gdb workflow, see [[re-gdb]]
- Breakpoint table:
-
Search and memory operations:
[0x00001040]> /x 5548 # 十六进制搜索 [0x00001040]> /v 0xdeadbeef # 32 位值搜索(小端) [0x00001040]> /w "password" # 字符串搜索 [0x00001040]> /r sym.check # 引用搜索(找谁引用了符号) [0x00001040]> wx 9090 @ 0x401000 # 写字节(NOP 补丁) [0x00001040]> px 32 @ 0x401000 # 读 32 字节- File info:
rz-bin -I sample(architecture/entry/sections),rz-bin -z sample(strings),rz-bin -i sample(imports)—equivalent to r2'srabin2 -I/-z/-i
- File info:
-
Projects and exporting:
[0x00001040]> Ps project_name # 保存项目(含分析结果与标注) [0x00001040]> Po project_name # 打开项目 [0x00001040]> Pj > out.json # 导出 JSON 项目(供脚本二次处理)- Analysis annotations (renames/comments) persist with the project—next time
Poresume directly
- Analysis annotations (renames/comments) persist with the project—next time
Cross-domain combinations
- [[re-binary-core]]: low-memory/command-line alternative for workflow step 5 (
RE_DECOMPILER=radare2) - [[re-firmware]]: batch scripted analysis of firmware ELF (no GUI environment)
- [[re-ctf]]: command-line quick attack for CTF challenges
- Connect with [[re-format-elf]] to read structures; switch to [[re-ghidra]] when GUI decompilation is needed
- Dynamic debugging scenarios complement [[re-gdb]] (gdb ecosystem/plugins are more complete, rz's built-in debugger is lightweight)
Common pitfalls and gotchas
- Without
-Alittle info before: without analysis there are no function boundaries/no cross-references—first-A(oraaa), then look at symbols - Large file analysis is slow: full
aaais extremely slow on huge firmware—useaa(lightweight) oraa~limits, or only for the target sectionaf @ addrmanual analysis - Command system r2/rz differences: online tutorials are mostly for radare2 (r2); rizin (rz) is largely compatible but plugin installation (
r2pm→rz-pm) and a few command names differ—firstrz?check help before executing pdfdepends on function boundaries—when stripped,afdefine first, otherwise output is empty or misaligned- Piped output with colors/pager breaks script parsing—for batch processing use
e scr.color=0to remove color (-2only disables stderr warnings, does not remove color) - For version differences, debugger and PIE address pitfalls, see [[gotchas]]