r2
General Information
Output
Run Program with R2
Find Entrypoints
ie
stands for info entrypoints
Help
If you know the general flag you want to use i.e.
i
for info you can append a?
This will show you all the help available to append to the
i
flag.
Analysis
r2 does not analyze the file by default, you need to specify the
a
flagTo have r2 analyze the file issue
aa
or analyse all, oraaa
Can also have r2 analyze the file at start up with
Flag Space
After analysis radare2 associates names to interesting offsets in the file such as
sections, functions, symbols, strings
.All are called
flags
Choose a flag space using
fs flagspace
and print the flags it contains withf
.Can pass multiple commands with semi colon i.e.
cmd1;cmd2;cmd3
Can see the strcmp, strcpy, puts etc.
We can also list the strings flagspace
Strings
Lets look at the strings
iz
- List the strings in data sectionsizz
Search for strings in the whole binary
axt Analyse X-refs to
axt
stands for analyse x-refs toFinds data or code references to this specific address
@@
is like a for each iterator sign used to repeat a command over a list of offsetsstr.*
is a wildcard for all flags that start withstr.
(our strings)This helps to list the function name, where they are used and the reference instruction in addition to the strings
Select the correct strings flagspace (default is
'fs *'
Seeking
Seek command accepts an address or math expression as an arg.
Expression can be math operation, flag, or memory access operations.
We want to seek for the
main
function.Can find it by executing
s main
First we want to see what else radare2 has flagged
afl stands for analyze functions list
Disassembling
Seek to the main function
Now disassemble it with
Print Disassemble Function
Prompt will change to the address of main!
Make the Output Prettier
Can add to
~/.radare2rc
to make changes permanent
Visual Mode and Graph Mode
Much more user-friendly
Press
V
will bring us to the Visual Mode ScreenUse
p/P
to change between the modesNav to the disassembly view using
p
To go back to a specific screen press
q
Cross-Reference
Use
x/X
to list the references to and from (respectively) the current offset. Use the numbers to jump to a reference
radare2 Commands
Use
:command
to execute r2 commands from inside Visual Mode
Comment
You can add a comment using
;<comment>
followed byEnter
Remove it using
;-
Mark Offsets
Use this to mark a specific offset with a key of your choice, press
'<key>
to choose your key.This will allow you to mark important addresses you want to jump to quickly
Quit
Press
q
to return to r2 shell
Visual Graphs
radare2 has a Graph view
You can access VG move from your shell by running
VV
Move up, down, R, L with
h,j,k,l
and jump to a func usingg
and the key shown next to thejump call
All Credit:
https://www.megabeets.net/a-journey-into-radare-2-part-1/
Last updated