Building ‘apropos’ command for radare2

Long Le
Long Le
Aug 9, 2017 · 2 min read

Radare2 is a great tool for reverse engineering. But if you are a new user, it is a bit frustrated to get familiar with radare2 commands. There are hundred of commands available and they are organized in a sequence of abbreviations. For example, command af will be interpreted as: a[nalyze] f[unction].

Some frequently used commands can be listed:

  • a[nalysis]
  • p[rint]
  • i[nfo]
  • d[ebug]
  • P[roject] (capital P, just to illustrate conflict happens :))

So you have to remember few keywords and its combination to form a command. For example, the command pd is created by p (print) and d (disassemble), but dp is created by d (debug) and p (process). Magic? Unlike gdb/lldb, there is no human-readable command (like disassemble) in radare2 and even no built-in apropos command to lookup for interested keywords. Though you can easily get radare2 manual with ?, walking through all commands will not be easy.

As a normal user, I can only remember a dozen of commands and I rely on apropos to search for less frequently used ones. To make radare2 learning journey more comfortable, I wrote a quick and dirty script as a standalone, custom r2apropos command by:

  • Extracting all help text from libr/core/*.c
  • Putting it in a standalone python script to lookup for keywords

Output of the r2apropos command will look like:

lookup for commands related to `heap`

You can make an alias and put it in ~/.radare2rc for permanent use:

#~/.radare2rc
$help=!/path/to/r2apropos.py
$h=$help # make it short
set $help as alias for r2apropos command

Next step? May be adding appropriate keywords to radare2 manual. Hope this help and enjoy r2ing!

Long Le

Written by

Long Le

@vnsecurity.net

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade