2.2.1 Radare2

简介

IDA Pro 昂贵的价格令很多二进制爱好者望而却步,于是在开源世界中催生出了一个新的逆向工程框架——Radare2,它拥有非常强大的功能,包括反汇编、调试、打补丁、虚拟化等等,而且可以运行在几乎所有的主流平台上(GNU/Linux、Windows、BSD、iOS、OSX……)。Radare2 开发之初仅提供了基于命令行的操作,尽管现在也有非官方的GUI,但我更喜欢直接在终端上运行它,当然这也就意味着更高陡峭的学习曲线。Radare2 是由一系列的组件构成的,这些组件赋予了 Radare2 强大的分析能力,可以在 Radare2 中或者单独被使用。

这里是 Radare2 与其他二进制分析工具的对比。(Comparison Table

安装

  1. $ git clone https://github.com/radare/radare2.git
  2. $ cd radare2
  3. $ ./sys/install.sh

更新

  1. $ ./sys/install.sh

卸载

  1. $ make uninstall
  2. $ make purge

命令行使用方法

Radare2 在命令行下有一些小工具可供使用:

  • radare2:十六进制编辑器和调试器的核心,通常通过它进入交互式界面。
  • rabin2:从可执行二进制文件中提取信息。
  • rasm2:汇编和反汇编。
  • rahash2:基于块的哈希工具。
  • radiff2:二进制文件或代码差异比对。
  • rafind2:查找字节模式。
  • ragg2:r_egg 的前端,将高级语言编写的简单程序编译成x86、x86-64和ARM的二进制文件。
  • rarun2:用于在不同环境中运行程序。
  • rax2:数据格式转换。

radare2/r2

  1. $ r2 -h
  2. Usage: r2 [-ACdfLMnNqStuvwzX] [-P patch] [-p prj] [-a arch] [-b bits] [-i file]
  3. [-s addr] [-B baddr] [-M maddr] [-c cmd] [-e k=v] file|pid|-|--|=
  4. -- run radare2 without opening any file
  5. - same as 'r2 malloc://512'
  6. = read file from stdin (use -i and -c to run cmds)
  7. -= perform !=! command to run all commands remotely
  8. -0 print \x00 after init and every command
  9. -a [arch] set asm.arch
  10. -A run 'aaa' command to analyze all referenced code
  11. -b [bits] set asm.bits
  12. -B [baddr] set base address for PIE binaries
  13. -c 'cmd..' execute radare command
  14. -C file is host:port (alias for -c+=http://%s/cmd/)
  15. -d debug the executable 'file' or running process 'pid'
  16. -D [backend] enable debug mode (e cfg.debug=true)
  17. -e k=v evaluate config var
  18. -f block size = file size
  19. -F [binplug] force to use that rbin plugin
  20. -h, -hh show help message, -hh for long
  21. -H ([var]) display variable
  22. -i [file] run script file
  23. -I [file] run script file before the file is opened
  24. -k [k=v] perform sdb query into core->sdb
  25. -l [lib] load plugin file
  26. -L list supported IO plugins
  27. -m [addr] map file at given address (loadaddr)
  28. -M do not demangle symbol names
  29. -n, -nn do not load RBin info (-nn only load bin structures)
  30. -N do not load user settings and scripts
  31. -o [OS/kern] set asm.os (linux, macos, w32, netbsd, ...)
  32. -q quiet mode (no prompt) and quit after -i
  33. -p [prj] use project, list if no arg, load if no file
  34. -P [file] apply rapatch file and quit
  35. -R [rarun2] specify rarun2 profile to load (same as -e dbg.profile=X)
  36. -s [addr] initial seek
  37. -S start r2 in sandbox mode
  38. -t load rabin2 info in thread
  39. -u set bin.filter=false to get raw sym/sec/cls names
  40. -v, -V show radare2 version (-V show lib versions)
  41. -w open file in write mode
  42. -X [rr2rule] specify custom rarun2 directive
  43. -z, -zz do not load strings or load them even in raw

参数很多,这里最重要是 file。如果你想 attach 到一个进程上,则使用 pid。常用参数如下:

  • -A:相当于在交互界面输入了 aaa
  • -c:运行 radare 命令。(r2 -A -q -c 'iI~pic' file
  • -d:调试二进制文件或进程。
  • -a,-b,-o:分别指定体系结构、位数和操作系统,通常是自动的,但也可以手动指定。
  • -w:使用可写模式打开。

rabin2

  1. $ rabin2 -h
  2. Usage: rabin2 [-AcdeEghHiIjlLMqrRsSvVxzZ] [-@ at] [-a arch] [-b bits] [-B addr]
  3. [-C F:C:D] [-f str] [-m addr] [-n str] [-N m:M] [-P[-P] pdb]
  4. [-o str] [-O str] [-k query] [-D lang symname] | file
  5. -@ [addr] show section, symbol or import at addr
  6. -A list sub-binaries and their arch-bits pairs
  7. -a [arch] set arch (x86, arm, .. or <arch>_<bits>)
  8. -b [bits] set bits (32, 64 ...)
  9. -B [addr] override base address (pie bins)
  10. -c list classes
  11. -C [fmt:C:D] create [elf,mach0,pe] with Code and Data hexpairs (see -a)
  12. -d show debug/dwarf information
  13. -D lang name demangle symbol name (-D all for bin.demangle=true)
  14. -e entrypoint
  15. -E globally exportable symbols
  16. -f [str] select sub-bin named str
  17. -F [binfmt] force to use that bin plugin (ignore header check)
  18. -g same as -SMZIHVResizcld (show all info)
  19. -G [addr] load address . offset to header
  20. -h this help message
  21. -H header fields
  22. -i imports (symbols imported from libraries)
  23. -I binary info
  24. -j output in json
  25. -k [sdb-query] run sdb query. for example: '*'
  26. -K [algo] calculate checksums (md5, sha1, ..)
  27. -l linked libraries
  28. -L [plugin] list supported bin plugins or plugin details
  29. -m [addr] show source line at addr
  30. -M main (show address of main symbol)
  31. -n [str] show section, symbol or import named str
  32. -N [min:max] force min:max number of chars per string (see -z and -zz)
  33. -o [str] output file/folder for write operations (out by default)
  34. -O [str] write/extract operations (-O help)
  35. -p show physical addresses
  36. -P show debug/pdb information
  37. -PP download pdb file for binary
  38. -q be quiet, just show fewer data
  39. -qq show less info (no offset/size for -z for ex.)
  40. -Q show load address used by dlopen (non-aslr libs)
  41. -r radare output
  42. -R relocations
  43. -s symbols
  44. -S sections
  45. -u unfiltered (no rename duplicated symbols/sections)
  46. -v display version and quit
  47. -V Show binary version information
  48. -x extract bins contained in file
  49. -X [fmt] [f] .. package in fat or zip the given files and bins contained in file
  50. -z strings (from data section)
  51. -zz strings (from raw bins [e bin.rawstr=1])
  52. -zzz dump raw strings to stdout (for huge files)
  53. -Z guess size of binary program

当我们拿到一个二进制文件时,第一步就是获取关于它的基本信息,这时候就可以使用 rabin2。rabin2 可以获取包括 ELF、PE、Mach-O、Java CLASS 文件的区段、头信息、导入导出表、数据段字符串、入口点等信息,并且支持多种格式的输出。

下面介绍一些常见的用法:(我还会列出其他实现类似功能工具的用法,你可以对比一下它们的输出)

  • -I:最常用的参数,它可以打印出二进制文件信息,其中我们需要重点关注其使用的安全防护技术,如 canary、pic、nx 等。(filechekcsec -f
  • -e:得到二进制文件的入口点。(`readelf -h`)
  • -i:获得导入符号表,RLT中的偏移等。(readelf -r
  • -E:获得全局导出符号表。
  • -s:获得符号表。(readelf -s
  • -l:获得二进制文件使用到的动态链接库。(ldd
  • -z:从 ELF 文件的 .rodare 段或 PE 文件的 .text 中获得字符串。(strings -d
  • -S:获得完整的段信息。(readelf -S
  • -c:列出所有类,在分析 Java 程序是很有用。

最后还要提到的一个参数 -r,它可以将我们得到的信息以 radare2 可读的形式输出,在后续的分析中可以将这样格式的信息输入 radare2,这是非常有用的。

rasm2

  1. $ rasm2 -h
  2. Usage: rasm2 [-ACdDehLBvw] [-a arch] [-b bits] [-o addr] [-s syntax]
  3. [-f file] [-F fil:ter] [-i skip] [-l len] 'code'|hex|-
  4. -a [arch] Set architecture to assemble/disassemble (see -L)
  5. -A Show Analysis information from given hexpairs
  6. -b [bits] Set cpu register size (8, 16, 32, 64) (RASM2_BITS)
  7. -c [cpu] Select specific CPU (depends on arch)
  8. -C Output in C format
  9. -d, -D Disassemble from hexpair bytes (-D show hexpairs)
  10. -e Use big endian instead of little endian
  11. -E Display ESIL expression (same input as in -d)
  12. -f [file] Read data from file
  13. -F [in:out] Specify input and/or output filters (att2intel, x86.pseudo, ...)
  14. -h, -hh Show this help, -hh for long
  15. -i [len] ignore/skip N bytes of the input buffer
  16. -k [kernel] Select operating system (linux, windows, darwin, ..)
  17. -l [len] Input/Output length
  18. -L List Asm plugins: (a=asm, d=disasm, A=analyze, e=ESIL)
  19. -o [offset] Set start address for code (default 0)
  20. -O [file] Output file name (rasm2 -Bf a.asm -O a)
  21. -p Run SPP over input for assembly
  22. -s [syntax] Select syntax (intel, att)
  23. -B Binary input/output (-l is mandatory for binary input)
  24. -v Show version information
  25. -w What's this instruction for? describe opcode
  26. -q quiet mode

rasm2 是一个内联汇编、反汇编程序。它的主要功能是获取给定机器指令操作码对应的字节。

下面是一些重要的参数:

  • -L:列出目标体系结构所支持的插件,输出中的第一列说明了插件提供的功能(a=asm, d=disasm, A=analyze, e=ESIL)。
  • -a:知道插件的名字后,就可以使用 -a` 来进行设置。
  • -b:设置CPU寄存器的位数。
  • -d:反汇编十六进制对字符串。
  • -D:反汇编并显示十六进制对和操作码。
  • -C:汇编后以 C 语言风格输出。
  • -f:从文件中读入汇编代码。

例子:

  1. $ rasm2 -a x86 -b 32 'mov eax,30'
  2. b81e000000
  3. $ rasm2 -a x86 -b 32 'mov eax,30' -C
  4. "\xb8\x1e\x00\x00\x00"
  5. $ rasm2 -d b81e000000
  6. mov eax, 0x1e
  7. $ rasm2 -D b81e000000
  8. 0x00000000 5 b81e000000 mov eax, 0x1e
  9. $ rasm2 -a x86 -b 32 -d 'b81e000000'
  10. mov eax, 0x1e
  11. $ cat a.asm
  12. mov eax,30
  13. $ rasm2 -f a.asm
  14. b81e000000

rahash2

  1. $ rahash2 -h
  2. Usage: rahash2 [-rBhLkv] [-b S] [-a A] [-c H] [-E A] [-s S] [-f O] [-t O] [file] ...
  3. -a algo comma separated list of algorithms (default is 'sha256')
  4. -b bsize specify the size of the block (instead of full file)
  5. -B show per-block hash
  6. -c hash compare with this hash
  7. -e swap endian (use little endian)
  8. -E algo encrypt. Use -S to set key and -I to set IV
  9. -D algo decrypt. Use -S to set key and -I to set IV
  10. -f from start hashing at given address
  11. -i num repeat hash N iterations
  12. -I iv use give initialization vector (IV) (hexa or s:string)
  13. -S seed use given seed (hexa or s:string) use ^ to prefix (key for -E)
  14. (- will slurp the key from stdin, the @ prefix points to a file
  15. -k show hash using the openssh's randomkey algorithm
  16. -q run in quiet mode (-qq to show only the hash)
  17. -L list all available algorithms (see -a)
  18. -r output radare commands
  19. -s string hash this string instead of files
  20. -t to stop hashing at given address
  21. -x hexstr hash this hexpair string instead of files
  22. -v show version information

rahash2 用于计算检验和,支持字节流、文件、字符串等形式和多种算法。

重要参数:

  • -a:指定算法。默认为 sha256,如果指定为 all,则使用所有算法。
  • -b:指定块的大小(而不是整个文件)
  • -B:打印处每个块的哈希
  • -s:指定字符串(而不是文件)
  • -a entropy:显示每个块的熵(-B -b 512 -a entropy

radiff2

  1. $ radiff2 -h
  2. Usage: radiff2 [-abcCdjrspOxuUvV] [-A[A]] [-g sym] [-t %] [file] [file]
  3. -a [arch] specify architecture plugin to use (x86, arm, ..)
  4. -A [-A] run aaa or aaaa after loading each binary (see -C)
  5. -b [bits] specify register size for arch (16 (thumb), 32, 64, ..)
  6. -c count of changes
  7. -C graphdiff code (columns: off-A, match-ratio, off-B) (see -A)
  8. -d use delta diffing
  9. -D show disasm instead of hexpairs
  10. -e [k=v] set eval config var value for all RCore instances
  11. -g [sym|off1,off2] graph diff of given symbol, or between two offsets
  12. -G [cmd] run an r2 command on every RCore instance created
  13. -i diff imports of target files (see -u, -U and -z)
  14. -j output in json format
  15. -n print bare addresses only (diff.bare=1)
  16. -O code diffing with opcode bytes only
  17. -p use physical addressing (io.va=0)
  18. -q quiet mode (disable colors, reduce output)
  19. -r output in radare commands
  20. -s compute text distance
  21. -ss compute text distance (using levenstein algorithm)
  22. -S [name] sort code diff (name, namelen, addr, size, type, dist) (only for -C or -g)
  23. -t [0-100] set threshold for code diff (default is 70%)
  24. -x show two column hexdump diffing
  25. -u unified output (---+++)
  26. -U unified output using system 'diff'
  27. -v show version information
  28. -V be verbose (current only for -s)
  29. -z diff on extracted strings

radiff2 是一个基于偏移的比较工具。

重要参数:

  • -s:计算文本距离并得到相似度。
  • -AC:这两个参数通常一起使用,从函数的角度进行比较。
  • -g:得到给定的符号或两个偏移的图像对比。
    • 如:radiff2 -g main a.out b.out | xdot -(需要安装xdot)
  • -c:计算不同点的数量。

rafind2

  1. $ rafind2 -h
  2. Usage: rafind2 [-mXnzZhv] [-a align] [-b sz] [-f/t from/to] [-[m|s|S|e] str] [-x hex] file ..
  3. -a [align] only accept aligned hits
  4. -b [size] set block size
  5. -e [regex] search for regular expression string matches
  6. -f [from] start searching from address 'from'
  7. -h show this help
  8. -m magic search, file-type carver
  9. -M [str] set a binary mask to be applied on keywords
  10. -n do not stop on read errors
  11. -r print using radare commands
  12. -s [str] search for a specific string (can be used multiple times)
  13. -S [str] search for a specific wide string (can be used multiple times)
  14. -t [to] stop search at address 'to'
  15. -v print version and exit
  16. -x [hex] search for hexpair string (909090) (can be used multiple times)
  17. -X show hexdump of search results
  18. -z search for zero-terminated strings
  19. -Z show string found on each search hit

rafind2 用于在二进制文件中查找字符模式。

重要参数:

  • -s:查找特定字符串。
  • -e:使用正则匹配。
  • -z:搜索以\0结束的字符串。
  • -x:查找十六进制字符串。

ragg2

  1. $ ragg2 -h
  2. Usage: ragg2 [-FOLsrxhvz] [-a arch] [-b bits] [-k os] [-o file] [-I path]
  3. [-i sc] [-e enc] [-B hex] [-c k=v] [-C file] [-p pad] [-q off]
  4. [-q off] [-dDw off:hex] file|f.asm|-
  5. -a [arch] select architecture (x86, mips, arm)
  6. -b [bits] register size (32, 64, ..)
  7. -B [hexpairs] append some hexpair bytes
  8. -c [k=v] set configuration options
  9. -C [file] append contents of file
  10. -d [off:dword] patch dword (4 bytes) at given offset
  11. -D [off:qword] patch qword (8 bytes) at given offset
  12. -e [encoder] use specific encoder. see -L
  13. -f [format] output format (raw, pe, elf, mach0)
  14. -F output native format (osx=mach0, linux=elf, ..)
  15. -h show this help
  16. -i [shellcode] include shellcode plugin, uses options. see -L
  17. -I [path] add include path
  18. -k [os] operating system's kernel (linux,bsd,osx,w32)
  19. -L list all plugins (shellcodes and encoders)
  20. -n [dword] append 32bit number (4 bytes)
  21. -N [dword] append 64bit number (8 bytes)
  22. -o [file] output file
  23. -O use default output file (filename without extension or a.out)
  24. -p [padding] add padding after compilation (padding=n10s32)
  25. ntas : begin nop, trap, 'a', sequence
  26. NTAS : same as above, but at the end
  27. -P [size] prepend debruijn pattern
  28. -q [fragment] debruijn pattern offset
  29. -r show raw bytes instead of hexpairs
  30. -s show assembler
  31. -v show version
  32. -w [off:hex] patch hexpairs at given offset
  33. -x execute
  34. -z output in C string syntax

ragg2 可以将高级语言编写的简单程序编译成 x86、x86-64 或 ARM 的二进制文件。

重要参数:

  • -a:设置体系结构。
  • -b:设置体系结构位数(32/64)。
  • -P:生成某种模式的字符串,常用于输入到某程序中并寻找溢出点。
  • -r:使用原始字符而不是十六进制对。
    • ragg2 -P 50 -r`
  • -i:生成指定的 shellcode。查看 -L
    • ragg2 -a x86 -b 32 -i exec
  • -e:使用指定的编码器。查看 -L

rarun2

  1. $ rarun2 -h
  2. Usage: rarun2 -v|-t|script.rr2 [directive ..]
  3. program=/bin/ls
  4. arg1=/bin
  5. # arg2=hello
  6. # arg3="hello\nworld"
  7. # arg4=:048490184058104849
  8. # arg5=:!ragg2 -p n50 -d 10:0x8048123
  9. # arg6=@arg.txt
  10. # arg7=@300@ABCD # 300 chars filled with ABCD pattern
  11. # system=r2 -
  12. # aslr=no
  13. setenv=FOO=BAR
  14. # unsetenv=FOO
  15. # clearenv=true
  16. # envfile=environ.txt
  17. timeout=3
  18. # timeoutsig=SIGTERM # or 15
  19. # connect=localhost:8080
  20. # listen=8080
  21. # pty=false
  22. # fork=true
  23. # bits=32
  24. # pid=0
  25. # pidfile=/tmp/foo.pid
  26. # #sleep=0
  27. # #maxfd=0
  28. # #execve=false
  29. # #maxproc=0
  30. # #maxstack=0
  31. # #core=false
  32. # #stdio=blah.txt
  33. # #stderr=foo.txt
  34. # stdout=foo.txt
  35. # stdin=input.txt # or !program to redirect input to another program
  36. # input=input.txt
  37. # chdir=/
  38. # chroot=/mnt/chroot
  39. # libpath=$PWD:/tmp/lib
  40. # r2preload=yes
  41. # preload=/lib/libfoo.so
  42. # setuid=2000
  43. # seteuid=2000
  44. # setgid=2001
  45. # setegid=2001
  46. # nice=5

rarun2 是一个可以使用不同环境、参数、标准输入、权限和文件描述符的启动器。

常用的参数设置:

  • program
  • arg1, arg2,…
  • setenv
  • stdin, stdout

例子:

  • rarun2 program=a.out arg1=$(ragg2 -P 300 -r)
  • rarun2 program=a.out stdin=$(python a.py)

rax2

  1. $ rax2 -h
  2. Usage: rax2 [options] [expr ...]
  3. =[base] ; rax2 =10 0x46 -> output in base 10
  4. int -> hex ; rax2 10
  5. hex -> int ; rax2 0xa
  6. -int -> hex ; rax2 -77
  7. -hex -> int ; rax2 0xffffffb3
  8. int -> bin ; rax2 b30
  9. int -> ternary ; rax2 t42
  10. bin -> int ; rax2 1010d
  11. float -> hex ; rax2 3.33f
  12. hex -> float ; rax2 Fx40551ed8
  13. oct -> hex ; rax2 35o
  14. hex -> oct ; rax2 Ox12 (O is a letter)
  15. bin -> hex ; rax2 1100011b
  16. hex -> bin ; rax2 Bx63
  17. hex -> ternary ; rax2 Tx23
  18. raw -> hex ; rax2 -S < /binfile
  19. hex -> raw ; rax2 -s 414141
  20. -b bin -> str ; rax2 -b 01000101 01110110
  21. -B str -> bin ; rax2 -B hello
  22. -d force integer ; rax2 -d 3 -> 3 instead of 0x3
  23. -e swap endianness ; rax2 -e 0x33
  24. -D base64 decode ;
  25. -E base64 encode ;
  26. -f floating point ; rax2 -f 6.3+2.1
  27. -F stdin slurp C hex ; rax2 -F < shellcode.c
  28. -h help ; rax2 -h
  29. -k keep base ; rax2 -k 33+3 -> 36
  30. -K randomart ; rax2 -K 0x34 1020304050
  31. -n binary number ; rax2 -n 0x1234 # 34120000
  32. -N binary number ; rax2 -N 0x1234 # \x34\x12\x00\x00
  33. -r r2 style output ; rax2 -r 0x1234
  34. -s hexstr -> raw ; rax2 -s 43 4a 50
  35. -S raw -> hexstr ; rax2 -S < /bin/ls > ls.hex
  36. -t tstamp -> str ; rax2 -t 1234567890
  37. -x hash string ; rax2 -x linux osx
  38. -u units ; rax2 -u 389289238 # 317.0M
  39. -w signed word ; rax2 -w 16 0xffff
  40. -v version ; rax2 -v

rax2 是一个格式转换工具,在二进制、八进制、十六进制数字和字符串之间进行转换。

重要参数:

  • -e:交换字节顺序
  • -s:十六进制->字符
  • -S:字符->十六进制
  • -D, -E:base64 解码和编码

交互式使用方法

当我们进入到 Radare2 的交互式界面后,就可以使用交互式命令进行操作。

输入 ? 可以获得帮助信息,由于命令太多,我们只会重点介绍一些常用命令:

  1. [0x00000000]> ?
  2. Usage: [.][times][cmd][~grep][@[@iter]addr!size][|>pipe] ; ...
  3. Append '?' to any char command to get detailed help
  4. Prefix with number to repeat command N times (f.ex: 3x)
  5. |%var =valueAlias for 'env' command
  6. | *[?] off[=[0x]value] Pointer read/write data/values (see ?v, wx, wv)
  7. | (macro arg0 arg1) Manage scripting macros
  8. | .[?] [-|(m)|f|!sh|cmd] Define macro or load r2, cparse or rlang file
  9. | =[?] [cmd] Send/Listen for Remote Commands (rap://, http://, <fd>)
  10. | /[?] Search for bytes, regexps, patterns, ..
  11. | ![?] [cmd] Run given command as in system(3)
  12. | #[?] !lang [..] Hashbang to run an rlang script
  13. | a[?] Analysis commands
  14. | b[?] Display or change the block size
  15. | c[?] [arg] Compare block with given data
  16. | C[?] Code metadata (comments, format, hints, ..)
  17. | d[?] Debugger commands
  18. | e[?] [a[=b]] List/get/set config evaluable vars
  19. | f[?] [name][sz][at] Add flag at current address
  20. | g[?] [arg] Generate shellcodes with r_egg
  21. | i[?] [file] Get info about opened file from r_bin
  22. | k[?] [sdb-query] Run sdb-query. see k? for help, 'k *', 'k **' ...
  23. | L[?] [-] [plugin] list, unload load r2 plugins
  24. | m[?] Mountpoints commands
  25. | o[?] [file] ([offset]) Open file at optional address
  26. | p[?] [len] Print current block with format and length
  27. | P[?] Project management utilities
  28. | q[?] [ret] Quit program with a return value
  29. | r[?] [len] Resize file
  30. | s[?] [addr] Seek to address (also for '0x', '0x1' == 's 0x1')
  31. | S[?] Io section manipulation information
  32. | t[?] Types, noreturn, signatures, C parser and more
  33. | T[?] [-] [num|msg] Text log utility
  34. | u[?] uname/undo seek/write
  35. | V Enter visual mode (V! = panels, VV = fcngraph, VVV = callgraph)
  36. | w[?] [str] Multiple write operations
  37. | x[?] [len] Alias for 'px' (print hexadecimal)
  38. | y[?] [len] [[[@]addr Yank/paste bytes from/to memory
  39. | z[?] Zignatures management
  40. | ?[??][expr] Help or evaluate math expression
  41. | ?$? Show available '$' variables and aliases
  42. | ?@? Misc help for '@' (seek), '~' (grep) (see ~??)
  43. | ?:? List and manage core plugins

于是我们知道了 Radare2 交互命令的一般格式,如下所示:

  1. [.][times][cmd][~grep][@[@iter]addr!size][|>pipe] ; ...

如果你对 *nix shell, sed, awk 等比较熟悉的话,也可以帮助你很快掌握 radare2 命令。

  • 在任意字符命令后面加上 ? 可以获得关于该命令更多的细节。如 a?p?!?@?
  • 当命令以数字开头时表示重复运行的次数。如 3x
  • ! 单独使用可以显示命令使用历史记录。
  • ; 是命令分隔符,可以在一行上运行多个命令。如 px 10; pd 20
  • .. 重复运行上一条命令,使用回车键也一样。
  • / 用于在文件中进行搜索操作。
  • ! 开头可以运行 shell 命令。用法:!<cmd>
    • !ls
  • | 是管道符。用法:<r2command> | <program|H|>
    • pd | less
  • ~ 用于文本比配(grep)。用法:[command]~[modifier][word,word][endmodifier][[column]][:line]
    • i~:0 显示 i 输出的第一行
    • pd~mov,eax 反汇编并匹配 mov 或 eax 所在行
    • pi~mov&eax 匹配 mov 和 eax 都有的行
    • i~0x400$ 匹配以 0x400 结尾的行
  • ??? 可以获得以 ? 开头的命令的细节
    • ? 可以做各种进制和格式的快速转换。如 ? 1234
    • ?p vaddr 获得虚拟地址 vaddr 的物理地址
    • ?P paddr 获得物理地址 paddr 的虚拟地址
    • ?v 以十六进制的形式显示某数学表达式的结果。如 ?v eip-0x804800
    • ?l str 获得 str 的长度,结果被临时保存,使用 ?v 可输出结果。
  • @@ foreach 迭代器,在列出的偏移处重复执行命令。
    • wx ff @@ 10 20 30 在偏移 10、20、30 处写入 ff
    • p8 4 @@ fcn.* 打印处每个函数的头 4 个字节
  • ?$? 可以显示表达式所使用变量的帮助信息。用法:?v [$.]
    • $$ 是当前所处的虚拟地址
    • $? 是最后一个运算的值
    • $s 文件大小
    • $b 块大小
    • $l 操作码长度
    • $j 跳转地址。当 $$ 处是一个类似 jmp 的指令时,$j 中保存着将要跳转到的地址
    • $f 跳转失败地址。即当前跳转没有生效,$f 中保存下一条指令的地址
    • $m 操作码内存引用。如:mov eax,[0x10] => 0x10
  • e 用于进行配置信息的修改
    • e asm.bytes=false 关闭指令 raw bytes 的显示

默认情况下,执行的每条命令都有一个参考点,通常是内存中的当前位置,由命令前的十六进制数字指示。任何的打印、写入或分析命令都在当前位置执行。例如反汇编当前位置的一条指令:

  1. [0x00005060]> pd 1
  2. ;-- entry0:
  3. ;-- rip:
  4. 0x00005060 31ed xor ebp, ebp

block size 是在我们没有指定行数的时候使用的默认值,输入 b 即可看到,使用 b [num] 修改字节数,这时使用打印命令如 pd 时,将反汇编相应字节的指令。

  1. [0x00005060]> b
  2. 0x100
  3. [0x00005060]> b 10
  4. [0x00005060]> b
  5. 0xa
  6. [0x00005060]> pd
  7. ;-- entry0:
  8. ;-- rip:
  9. 0x00005060 31ed xor ebp, ebp
  10. 0x00005062 4989d1 mov r9, rdx

分析(analyze)

所有与分析有关的命令都以 a 开头:

  1. [0x00000000]> a?
  2. |Usage: a[abdefFghoprxstc] [...]
  3. | ab [hexpairs] analyze bytes
  4. | abb [len] analyze N basic blocks in [len] (section.size by default)
  5. | aa[?] analyze all (fcns + bbs) (aa0 to avoid sub renaming)
  6. | ac [cycles] analyze which op could be executed in [cycles]
  7. | ad[?] analyze data trampoline (wip)
  8. | ad [from] [to] analyze data pointers to (from-to)
  9. | ae[?] [expr] analyze opcode eval expression (see ao)
  10. | af[?] analyze Functions
  11. | aF same as above, but using anal.depth=1
  12. | ag[?] [options] output Graphviz code
  13. | ah[?] analysis hints (force opcode size, ...)
  14. | ai [addr] address information (show perms, stack, heap, ...)
  15. | ao[?] [len] analyze Opcodes (or emulate it)
  16. | aO Analyze N instructions in M bytes
  17. | ar[?] like 'dr' but for the esil vm. (registers)
  18. | ap find prelude for current offset
  19. | ax[?] manage refs/xrefs (see also afx?)
  20. | as[?] [num] analyze syscall using dbg.reg
  21. | at[?] [.] analyze execution traces
  22. | av[?] [.] show vtables
  1. [0x00000000]> aa?
  2. |Usage: aa[0*?] # see also 'af' and 'afna'
  3. | aa alias for 'af@@ sym.*;af@entry0;afva'
  4. | aa* analyze all flags starting with sym. (af @@ sym.*)
  5. | aaa[?] autoname functions after aa (see afna)
  6. | aab aab across io.sections.text
  7. | aac [len] analyze function calls (af @@ `pi len~call[1]`)
  8. | aad [len] analyze data references to code
  9. | aae [len] ([addr]) analyze references with ESIL (optionally to address)
  10. | aai[j] show info of all analysis parameters
  11. | aar[?] [len] analyze len bytes of instructions for references
  12. | aan autoname functions that either start with fcn.* or sym.func.*
  13. | aas [len] analyze symbols (af @@= `isq~[0]`)
  14. | aat [len] analyze all consecutive functions in section
  15. | aaT [len] analyze code after trap-sleds
  16. | aap find and analyze function preludes
  17. | aav [sat] find values referencing a specific section or map
  18. | aau [len] list mem areas (larger than len bytes) not covered by functions
  • afl:列出所有函数。
  • axt [addr]:找到对给定地址的交叉引用。
  • af [addr]:当你发现某个地址处有一个函数,但是没有被分析出来的时候,可以使用该命令重新分析。

Flags

flag 用于将给定的偏移与名称相关联,flag 被分为几个 flag spaces,用于存放不同的 flag。

  1. [0x00000000]> f?
  2. |Usage: f [?] [flagname] # Manage offset-name flags
  3. | f list flags (will only list flags from selected flagspaces)
  4. | f?flagname check if flag exists or not, See ?? and ?!
  5. | f. [*[*]] list local per-function flags (*) as r2 commands
  6. | f.blah=$$+12 set local function label named 'blah'
  7. | f* list flags in r commands
  8. | f name 12 @ 33 set flag 'name' with length 12 at offset 33
  9. | f name = 33 alias for 'f name @ 33' or 'f name 1 33'
  10. | f name 12 33 [cmt] same as above + optional comment
  11. | f-.blah@fcn.foo delete local label from function at current seek (also f.-)
  12. | f-- delete all flags and flagspaces (deinit)
  13. | f+name 12 @ 33 like above but creates new one if doesnt exist
  14. | f-name remove flag 'name'
  15. | f-@addr remove flag at address expression
  16. | f. fname list all local labels for the given function
  17. | f= [glob] list range bars graphics with flag offsets and sizes
  18. | fa [name] [alias] alias a flag to evaluate an expression
  19. | fb [addr] set base address for new flags
  20. | fb [addr] [flag*] move flags matching 'flag' to relative addr
  21. | fc[?][name] [color] set color for given flag
  22. | fC [name] [cmt] set comment for given flag
  23. | fd addr return flag+delta
  24. | fe- resets the enumerator counter
  25. | fe [name] create flag name.#num# enumerated flag. See fe?
  26. | fi [size] | [from] [to] show flags in current block or range
  27. | fg bring visual mode to foreground
  28. | fj list flags in JSON format
  29. | fl (@[flag]) [size] show or set flag length (size)
  30. | fla [glob] automatically compute the size of all flags matching glob
  31. | fm addr move flag at current offset to new address
  32. | fn list flags displaying the real name (demangled)
  33. | fo show fortunes
  34. | fr [old] [[new]] rename flag (if no new flag current seek one is used)
  35. | fR[?] [f] [t] [m] relocate all flags matching f&~m 'f'rom, 't'o, 'm'ask
  36. | fs[?]+-* manage flagspaces
  37. | fS[on] sort flags by offset or name
  38. | fV[*-] [nkey] [offset] dump/restore visual marks (mK/'K)
  39. | fx[d] show hexdump (or disasm) of flag:flagsize
  40. | fz[?][name] add named flag zone -name to delete. see fz?[name]

常见用法:

  • f flag_name @ addr:给地址 addr 创建一个 flag,当不指定地址时则默认指定当前地址。
  • f-flag_name:删除flag。
  • fs:管理命名空间。

    1. [0x00005060]> fs?
    2. |Usage: fs [*] [+-][flagspace|addr] # Manage flagspaces
    3. | fs display flagspaces
    4. | fs* display flagspaces as r2 commands
    5. | fsj display flagspaces in JSON
    6. | fs * select all flagspaces
    7. | fs flagspace select flagspace or create if it doesn't exist
    8. | fs-flagspace remove flagspace
    9. | fs-* remove all flagspaces
    10. | fs+foo push previous flagspace and set
    11. | fs- pop to the previous flagspace
    12. | fs-. remove the current flagspace
    13. | fsm [addr] move flags at given address to the current flagspace
    14. | fss display flagspaces stack
    15. | fss* display flagspaces stack in r2 commands
    16. | fssj display flagspaces stack in JSON
    17. | fsr newname rename selected flagspace

定位(seeking)

使用 s 命令可以改变当前位置:

  1. [0x00000000]> s?
  2. |Usage: s # Seek commands
  3. | s Print current address
  4. | s:pad Print current address with N padded zeros (defaults to 8)
  5. | s addr Seek to address
  6. | s- Undo seek
  7. | s- n Seek n bytes backward
  8. | s-- Seek blocksize bytes backward
  9. | s+ Redo seek
  10. | s+ n Seek n bytes forward
  11. | s++ Seek blocksize bytes forward
  12. | s[j*=!] List undo seek history (JSON, =list, *r2, !=names, s==)
  13. | s/ DATA Search for next occurrence of 'DATA'
  14. | s/x 9091 Search for next occurrence of \x90\x91
  15. | s.hexoff Seek honoring a base from core->offset
  16. | sa [[+-]a] [asz] Seek asz (or bsize) aligned to addr
  17. | sb Seek aligned to bb start
  18. | sC[?] string Seek to comment matching given string
  19. | sf Seek to next function (f->addr+f->size)
  20. | sf function Seek to address of specified function
  21. | sg/sG Seek begin (sg) or end (sG) of section or file
  22. | sl[?] [+-]line Seek to line
  23. | sn/sp Seek to next/prev location, as specified by scr.nkey
  24. | so [N] Seek to N next opcode(s)
  25. | sr pc Seek to register
  26. | ss Seek silently (without adding an entry to the seek history)
  • s+,s-:重复或撤销。
  • s+ n,s- n:定位到当前位置向前或向后 n 字节的位置。
  • s/ DATA:定位到下一个出现 DATA 的位置。

信息(information)

  1. [0x00000000]> i?
  2. |Usage: i Get info from opened file (see rabin2's manpage)
  3. | Output mode:
  4. | '*' Output in radare commands
  5. | 'j' Output in json
  6. | 'q' Simple quiet output
  7. | Actions:
  8. | i|ij Show info of current file (in JSON)
  9. | iA List archs
  10. | ia Show all info (imports, exports, sections..)
  11. | ib Reload the current buffer for setting of the bin (use once only)
  12. | ic List classes, methods and fields
  13. | iC Show signature info (entitlements, ...)
  14. | id[?] Debug information (source lines)
  15. | iD lang sym demangle symbolname for given language
  16. | ie Entrypoint
  17. | iE Exports (global symbols)
  18. | ih Headers (alias for iH)
  19. | iHH Verbose Headers in raw text
  20. | ii Imports
  21. | iI Binary info
  22. | ik [query] Key-value database from RBinObject
  23. | il Libraries
  24. | iL [plugin] List all RBin plugins loaded or plugin details
  25. | im Show info about predefined memory allocation
  26. | iM Show main address
  27. | io [file] Load info from file (or last opened) use bin.baddr
  28. | ir Relocs
  29. | iR Resources
  30. | is Symbols
  31. | iS [entropy,sha1] Sections (choose which hash algorithm to use)
  32. | iV Display file version info
  33. | iz|izj Strings in data sections (in JSON/Base64)
  34. | izz Search for Strings in the whole binary
  35. | iZ Guess size of binary program

i 系列命令用于获取文件的各种信息,这时配合上 ~ 命令来获得精确的输出,下面是一个类似 checksec 的输出:

  1. [0x00005060]> iI ~relro,canary,nx,pic,rpath
  2. canary true
  3. nx true
  4. pic true
  5. relro full
  6. rpath NONE

~ 命令还有一些其他的用法,如获取某一行某一列等,另外使用 ~{} 可以使 json 的输出更好看:

  1. [0x00005060]> ~?
  2. |Usage: [command]~[modifier][word,word][endmodifier][[column]][:line]
  3. modifier:
  4. | & all words must match to grep the line
  5. | $[n] sort numerically / alphabetically the Nth column
  6. | + case insensitive grep (grep -i)
  7. | ^ words must be placed at the beginning of line
  8. | ! negate grep
  9. | ? count number of matching lines
  10. | ?. count number chars
  11. | ?? show this help message
  12. | :[s]-[e] show lines s-e
  13. | .. internal 'less'
  14. | ... internal 'hud' (like V_)
  15. | {} json indentation
  16. | {path} json grep
  17. | {}.. less json indentation
  18. | endmodifier:
  19. | $ words must be placed at the end of line
  20. | column:
  21. | [n] show only column n
  22. | [n-m] show column n to m
  23. | [n-] show all columns starting from column n
  24. | [i,j,k] show the columns i, j and k
  25. | Examples:
  26. | i~:0 show first line of 'i' output
  27. | i~:-2 show first three lines of 'i' output
  28. | pd~mov disasm and grep for mov
  29. | pi~[0] show only opcode
  30. | i~0x400$ show lines ending with 0x400

打印(print) & 反汇编(disassembling)

  1. [0x00000000]> p?
  2. |Usage: p[=68abcdDfiImrstuxz] [arg|len] [@addr]
  3. | p=[?][bep] [blks] [len] [blk] show entropy/printable chars/chars bars
  4. | p2 [len] 8x8 2bpp-tiles
  5. | p3 [file] print stereogram (3D)
  6. | p6[de] [len] base64 decode/encode
  7. | p8[?][j] [len] 8bit hexpair list of bytes
  8. | pa[edD] [arg] pa:assemble pa[dD]:disasm or pae: esil from hexpairs
  9. | pA[n_ops] show n_ops address and type
  10. | p[b|B|xb] [len] ([skip]) bindump N bits skipping M
  11. | pb[?] [n] bitstream of N bits
  12. | pB[?] [n] bitstream of N bytes
  13. | pc[?][p] [len] output C (or python) format
  14. | pC[d] [rows] print disassembly in columns (see hex.cols and pdi)
  15. | pd[?] [sz] [a] [b] disassemble N opcodes (pd) or N bytes (pD)
  16. | pf[?][.nam] [fmt] print formatted data (pf.name, pf.name $<expr>)
  17. | ph[?][=|hash] ([len]) calculate hash for a block
  18. | p[iI][df] [len] print N ops/bytes (f=func) (see pi? and pdi)
  19. | pm[?] [magic] print libmagic data (see pm? and /m?)
  20. | pr[?][glx] [len] print N raw bytes (in lines or hexblocks, 'g'unzip)
  21. | p[kK] [len] print key in randomart (K is for mosaic)
  22. | ps[?][pwz] [len] print pascal/wide/zero-terminated strings
  23. | pt[?][dn] [len] print different timestamps
  24. | pu[?][w] [len] print N url encoded bytes (w=wide)
  25. | pv[?][jh] [mode] show variable/pointer/value in memory
  26. | p-[?][jh] [mode] bar|json|histogram blocks (mode: e?search.in)
  27. | px[?][owq] [len] hexdump of N bytes (o=octal, w=32bit, q=64bit)
  28. | pz[?] [len] print zoom view (see pz? for help)
  29. | pwd display current working directory

常用参数如下:

  • px:输出十六进制数、偏移和原始数据。后跟 o,w,q 时分别表示8位、32位和64位。
  • p8:输出8位的字节流。
  • ps:输出字符串。

radare2 中反汇编操作是隐藏在打印操作中的,即使用 pd

  1. [0x00000000]> pd?
  2. |Usage: p[dD][ajbrfils] [sz] [arch] [bits] # Print Disassembly
  3. | NOTE: len parameter can be negative
  4. | NOTE: Pressing ENTER on empty command will repeat last pd command and also seek to end of disassembled range.
  5. | pd N disassemble N instructions
  6. | pd -N disassemble N instructions backward
  7. | pD N disassemble N bytes
  8. | pda disassemble all possible opcodes (byte per byte)
  9. | pdb disassemble basic block
  10. | pdc pseudo disassembler output in C-like syntax
  11. | pdC show comments found in N instructions
  12. | pdk disassemble all methods of a class
  13. | pdj disassemble to json
  14. | pdr recursive disassemble across the function graph
  15. | pdf disassemble function
  16. | pdi like 'pi', with offset and bytes
  17. | pdl show instruction sizes
  18. | pds[?] disassemble summary (strings, calls, jumps, refs) (see pdsf and pdfs)
  19. | pdt disassemble the debugger traces (see atd)

@addr 表示一个相对寻址,这里的 addr 可以是地址、符号名等,这个操作和 s 命令不同,它不会改变当前位置,当然即使使用类似 s @addr 的命令也不会改变当前位置。

  1. [0x00005060]> pd 5 @ main
  2. ;-- main:
  3. ;-- section..text:
  4. 0x00003620 4157 push r15 ; section 13 va=0x00003620 pa=0x00003620 sz=75529 vsz=75529 rwx=--r-x .text
  5. 0x00003622 4156 push r14
  6. 0x00003624 4155 push r13
  7. 0x00003626 4154 push r12
  8. 0x00003628 55 push rbp
  9. [0x00005060]> s @ main
  10. 0x3620
  11. [0x00005060]> s 0x3620
  12. [0x00003620]>

写入(write)

当你在打开 r2 时使用了参数 -w 时,才可以使用该命令,w 命令用于写入字节,它允许多种输入格式:

  1. [0x00000000]> w?
  2. |Usage: w[x] [str] [<file] [<<EOF] [@addr]
  3. | w[1248][+-][n] increment/decrement byte,word..
  4. | w foobar write string 'foobar'
  5. | w0 [len] write 'len' bytes with value 0x00
  6. | w6[de] base64/hex write base64 [d]ecoded or [e]ncoded string
  7. | wa[?] push ebp write opcode, separated by ';' (use '"' around the command)
  8. | waf file assemble file and write bytes
  9. | wao[?] op modify opcode (change conditional of jump. nop, etc)
  10. | wA[?] r 0 alter/modify opcode at current seek (see wA?)
  11. | wb 010203 fill current block with cyclic hexpairs
  12. | wB[-]0xVALUE set or unset bits with given value
  13. | wc list all write changes
  14. | wc[?][ir*?] write cache undo/commit/reset/list (io.cache)
  15. | wd [off] [n] duplicate N bytes from offset at current seek (memcpy) (see y?)
  16. | we[?] [nNsxX] [arg] extend write operations (insert instead of replace)
  17. | wf -|file write contents of file at current offset
  18. | wh r2 whereis/which shell command
  19. | wm f0ff set binary mask hexpair to be used as cyclic write mask
  20. | wo[?] hex write in block with operation. 'wo?' fmi
  21. | wp[?] -|file apply radare patch file. See wp? fmi
  22. | wr 10 write 10 random bytes
  23. | ws pstring write 1 byte for length and then the string
  24. | wt[f][?] file [sz] write to file (from current seek, blocksize or sz bytes)
  25. | wts host:port [sz] send data to remote host:port via tcp://
  26. | ww foobar write wide string 'f\x00o\x00o\x00b\x00a\x00r\x00'
  27. | wx[?][fs] 9090 write two intel nops (from wxfile or wxseek)
  28. | wv[?] eip+34 write 32-64 bit value
  29. | wz string write zero terminated string (like w + \x00)

常见用法:

  • wa:写入操作码,如 wa jmp 0x8048320
  • wx:写入十六进制数。
  • wv:写入32或64位的值。
  • wo:有很多子命令,用于将当前位置的值做运算后覆盖原值。

    1. [0x00005060]> wo?
    2. |Usage: wo[asmdxoArl24] [hexpairs] @ addr[!bsize]
    3. | wo[24aAdlmorwx] without hexpair values, clipboard is used
    4. | wo2 [val] 2= 2 byte endian swap
    5. | wo4 [val] 4= 4 byte endian swap
    6. | woa [val] += addition (f.ex: woa 0102)
    7. | woA [val] &= and
    8. | wod [val] /= divide
    9. | woD[algo] [key] [IV] decrypt current block with given algo and key
    10. | woe [from to] [step] [wsz=1] .. create sequence
    11. | woE [algo] [key] [IV] encrypt current block with given algo and key
    12. | wol [val] <<= shift left
    13. | wom [val] *= multiply
    14. | woo [val] |= or
    15. | wop[DO] [arg] De Bruijn Patterns
    16. | wor [val] >>= shift right
    17. | woR random bytes (alias for 'wr $b')
    18. | wos [val] -= substraction
    19. | wow [val] == write looped value (alias for 'wb')
    20. | wox [val] ^= xor (f.ex: wox 0x90)

调试(debugging)

在开启 r2 时使用参数 -d 即可开启调试模式,当然如果你已经加载了程序,可以使用命令 ood 重新开启调试。

  1. [0x7f8363c75f30]> d?
  2. |Usage: d # Debug commands
  3. | db[?] Breakpoints commands
  4. | dbt[?] Display backtrace based on dbg.btdepth and dbg.btalgo
  5. | dc[?] Continue execution
  6. | dd[?] File descriptors (!fd in r1)
  7. | de[-sc] [rwx] [rm] [e] Debug with ESIL (see de?)
  8. | dg <file> Generate a core-file (WIP)
  9. | dH [handler] Transplant process to a new handler
  10. | di[?] Show debugger backend information (See dh)
  11. | dk[?] List, send, get, set, signal handlers of child
  12. | dL [handler] List or set debugger handler
  13. | dm[?] Show memory maps
  14. | do[?] Open process (reload, alias for 'oo')
  15. | doo[args] Reopen in debugger mode with args (alias for 'ood')
  16. | dp[?] List, attach to process or thread id
  17. | dr[?] Cpu registers
  18. | ds[?] Step, over, source line
  19. | dt[?] Display instruction traces (dtr=reset)
  20. | dw <pid> Block prompt until pid dies
  21. | dx[?] Inject and run code on target process (See gs)

视图模式

在调试时使用视图模式是十分有用的,因为你既可以查看程序当前的位置,也可以查看任何你想看的位置。输入 V 即可进入视图模式,按下 p/P 可在不同模式之间进行切换,按下 ? 即可查看帮助,想退出时按下 q

  1. Visual mode help:
  2. ? show this help
  3. ?? show the user-friendly hud
  4. $ toggle asm.pseudo
  5. % in cursor mode finds matching pair, otherwise toggle autoblocksz
  6. @ redraw screen every 1s (multi-user view), in cursor set position
  7. ! enter into the visual panels mode
  8. _ enter the flag/comment/functions/.. hud (same as VF_)
  9. = set cmd.vprompt (top row)
  10. | set cmd.cprompt (right column)
  11. . seek to program counter
  12. " toggle the column mode (uses pC..)
  13. / in cursor mode search in current block
  14. :cmd run radare command
  15. ;[-]cmt add/remove comment
  16. 0 seek to beginning of current function
  17. [1-9] follow jmp/call identified by shortcut (like ;[1])
  18. ,file add a link to the text file
  19. /*+-[] change block size, [] = resize hex.cols
  20. </> seek aligned to block size (seek cursor in cursor mode)
  21. a/A (a)ssemble code, visual (A)ssembler
  22. b toggle breakpoint
  23. B enumerate and inspect classes
  24. c/C toggle (c)ursor and (C)olors
  25. d[f?] define function, data, code, ..
  26. D enter visual diff mode (set diff.from/to)
  27. e edit eval configuration variables
  28. f/F set/unset or browse flags. f- to unset, F to browse, ..
  29. gG go seek to begin and end of file (0-$s)
  30. hjkl move around (or HJKL) (left-down-up-right)
  31. i insert hex or string (in hexdump) use tab to toggle
  32. mK/'K mark/go to Key (any key)
  33. M walk the mounted filesystems
  34. n/N seek next/prev function/flag/hit (scr.nkey)
  35. o go/seek to given offset
  36. O toggle asm.esil
  37. p/P rotate print modes (hex, disasm, debug, words, buf)
  38. q back to radare shell
  39. r refresh screen / in cursor mode browse comments
  40. R randomize color palette (ecr)
  41. sS step / step over
  42. t browse types
  43. T enter textlog chat console (TT)
  44. uU undo/redo seek
  45. v visual function/vars code analysis menu
  46. V (V)iew graph using cmd.graph (agv?)
  47. wW seek cursor to next/prev word
  48. xX show xrefs/refs of current function from/to data/code
  49. yY copy and paste selection
  50. z fold/unfold comments in disassembly
  51. Z toggle zoom mode
  52. Enter follow address of jump/call
  53. Function Keys: (See 'e key.'), defaults to:
  54. F2 toggle breakpoint
  55. F4 run to cursor
  56. F7 single step
  57. F8 step over
  58. F9 continue

视图模式下的命令和命令行模式下的命令有很大不同,下面列出几个,更多的命令请查看帮助:

  • o:定位到给定的偏移。
  • ;:添加注释。
  • V:查看图形。
  • ::运行 radare2 命令

Web 界面使用

Radare2 的 GUI 尚在开发中,但有一个 Web 界面可以使用,如果刚开始你不习惯命令行操作,可以输入下面的命令:

  1. $ r2 -c=H [filename]

默认地址为 http://localhost:9090/,这样你就可以在 Web 中进行操作了,但是我强烈建议你强迫自己使用命令行的操作方式。

cutter GUI

cutter 是 r2 官方的 GUI,已经在快速开发中,基本功能已经有了,喜欢界面操作的读者可以试一下(请确保 r2 已经正确安装):

  1. $ yaourt -S qt
  1. $ git clone https://github.com/radareorg/cutter
  2. $ cd cutter
  3. $ mkdir build
  4. $ cd build
  5. $ qmake ../src
  6. $ make

然后就可以运行了:

  1. $ ./cutter

在 CTF 中的运用

更多资源