r2
General Information
rabin2 -I filenameOutput
$ rabin2 -I megabeets_0x1
arch x86
baddr 0x8048000
binsz 6220
bintype elf
bits 32
canary false
class ELF32
compiler GCC: (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
crypto false
endian little
havecode true
intrp /lib/ld-linux.so.2
laddr 0x0
lang c
linenum true
lsyms true
machine Intel 80386
maxopsz 16
minopsz 1
nx false
os linux
pcalign 0
pic false
relocs true
relro partial
rpath NONE
sanitiz false
static false
stripped false
subsys linux
va trueRun Program with R2
Find Entrypoints
iestands for info entrypoints
Help
If you know the general flag you want to use i.e.
ifor info you can append a?
This will show you all the help available to append to the
iflag.
Analysis
r2 does not analyze the file by default, you need to specify the
aflagTo have r2 analyze the file issue
aaor 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
flagsChoose a flag space using
fs flagspaceand 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 sectionsizzSearch for strings in the whole binary
axt Analyse X-refs to
axtstands 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
mainfunction.Can find it by executing
s mainFirst 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
~/.radare2rcto make changes permanent
Visual Mode and Graph Mode
Much more user-friendly
Press
Vwill bring us to the Visual Mode ScreenUse
p/Pto change between the modesNav to the disassembly view using
pTo go back to a specific screen press
q
Cross-Reference
Use
x/Xto list the references to and from (respectively) the current offset. Use the numbers to jump to a reference
radare2 Commands
Use
:commandto execute r2 commands from inside Visual Mode
Comment
You can add a comment using
;<comment>followed byEnterRemove 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
qto return to r2 shell
Visual Graphs
radare2 has a Graph view
You can access VG move from your shell by running
VVMove up, down, R, L with
h,j,k,land jump to a func usinggand the key shown next to thejump call
All Credit:
https://www.megabeets.net/a-journey-into-radare-2-part-1/
Last updated