To enter in visual mode use the v or V command, and then you'll only have to press keys to get the actions happen instead of commands.
Command | Description |
---|---|
V | Enter visual mode |
p/P | Rotate modes (hex, disasm, debug, words, buf) |
c | Toggle (c)ursor |
q | Back to Radare shell |
hjkl | Move around (or HJKL) (left-down-up-right) |
Enter | Follow address of jump/call |
sS | Step/step over |
o | Toggle asm.pseudo and asm.esil |
. | Seek to program counter |
/ | In cursor mode, search in current block |
:cmd | Run radare command |
;[-]cmt | Add/remove comment |
/*+-[] | Change block size, [] = resize hex.cols |
<,> | Seek aligned to block size |
i/a/A | (i)nsert hex, (a)ssemble code, visual (A)ssembler |
b | Toggle breakpoint |
B | Browse evals, symbols, flags, classes, ... |
d[f?] | Define function, data, code, .. |
D | Enter visual diff mode (set diff.from/to) |
e | Edit eval configuration variables |
f/F | Set/unset flag |
gG | Go seek to begin and end of file (0-$s) |
mK/’K | Mark/go to Key (any key) |
M | Walk the mounted filesystems |
n/N | Seek next/prev function/flag/hit (scr.nkey) |
C | Toggle (C)olors |
R | Randomize color palette (ecr) |
tT | Tab related. see also tab |
v | Visual code analysis menu |
V | (V)iew graph (agv?) |
wW | Seek cursor to next/prev word |
uU | Undo/redo seek |
x | Show xrefs of current func from/to data/code |
yY | Copy and paste selection |
z | fold/unfold comments in diassembly |
Searching
There are many situations where we need to find a value inside a binary or in some specific regions. Use the e search.in=? command to choose where the / command may search for the given value.
Command | Description |
---|---|
/ foo\00 | Search for string ’foo\0’ |
/b | Search backwards |
// | Repeat last search |
/w foo | Search for wide string ’f\0o\0o\0’ |
/wi foo | Search for wide string ignoring case |
/! ff | Search for first occurrence not matching |
/i foo | Search for string ’foo’ ignoring case |
/e /E.F/i | Match regular expression |
/x a1b2c3 | Search for bytes; spaces and uppercase nibbles are allowed, same as /x A1 B2 C3 |
/x a1..c3 | Search for bytes ignoring some nibbles (auto-generates mask, in this example: ff00ff) |
/x a1b2:fff3 | Search for bytes with mask (specify individual bits) |
/d 101112 | Search for a deltified sequence of bytes |
/!x 00 | Inverse hexa search (find first byte != 0x00) |
/c jmp [esp] | Search for asm code (see search.asmstr) |
/a jmp eax | Assemble opcode and search its bytes |
/A | Search for AES expanded keys |
/r sym.printf | Analyze opcode reference an offset |
/R | Search for ROP gadgets |
/P | Show offset of previous instruction |
/m magicfile | Search for matching magic file |
/p patternsize | Search for pattern of given size |
/z min max | Search for strings of given size |
/v[?248] num | Look for a asm.bigendian 32bit value |
Saving (Broken)
This feature has broken and not been resolved at the time of writing these words (Nov.16th 2020). check #Issue 6945: META - Project files and #Issue 17034 for more details.
To save your analysis for now, write your own script which records the function name, variable name, etc. for example:
vim sample_A.r2
e scr.utf8 = false
s 0x000403ce0
aaa
s fcn.00403130
afn return_delta_to_heapaddr
afvn iter var_04h
...
Usable variables in expression
The ?$? command will display the variables that can be used in any math operation inside the r2 shell. For example, using the ? $$ command to evaluate a number or ?v to just the value in one format.
All commands in r2 that accept a number supports the use of those variables.
Command | Description |
---|---|
$$ | here (current virtual seek) |
$$$ | current non-temporary virtual seek |
$? | last comparison value |
$alias=value | alias commands (simple macros) |
$b | block size |
$B | base address (aligned lowest map address) |
$f | jump fail address (e.g. jz 0x10 => next instruction) |
$fl | flag length (size) at current address (fla; pD $l @ entry0) |
$F | current function size |
$FB | begin of function |
$Fb | address of the current basic block |
$Fs | size of the current basic block |
$FE | end of function |
$FS | function size |
$Fj | function jump destination |
$Ff | function false destination |
$FI | function instructions |
$c,$r | get width and height of terminal |
$Cn | get nth call of function |
$Dn | get nth data reference in function |
$D | current debug map base address ?v $D @ rsp |
$DD | current debug map size |
$e | 1 if end of block, else 0 |
$j | jump address (e.g. jmp 0x10, jz 0x10 => 0x10) |
$Ja | get nth jump of function |
$Xn | get nth xref of function |
$l | opcode length |
$m | opcode memory reference (e.g. mov eax,[0x10] => 0x10) |
$M | map address (lowest map address) |
$o | here (current disk io offset) |
$p | getpid() |
$P | pid of children (only in debug) |
$s | file size |
$S | section offset |
$SS | section size |
$v | opcode immediate value (e.g. lui a0,0x8010 => 0x8010) |
$w | get word size, 4 if asm.bits=32, 8 if 64, ... |
${ev} | get value of eval config variable |
$r{reg} | get value of named register |
$k{kv} | get value of an sdb query value |
$s{flag} | get size of flag |
RNum | $variables usable in math expressions |
Authors & Contributors
This book wouldn't be possible without the help of a large list of contributors who have been reviewing, writing and reporting bugs and stuff in the radare2 project as well as in this book.
The radare2 book
This book was started by maijin as a new version of the original radare book written by pancake.
• Old radare1 book http://www.radare.org/get/radare.pdf
Many thanks to everyone who has been involved with the gitbook:
Adrian Studer, Ahmed Mohamed Abd El-MAwgood, Akshay Krishnan R, Andrew Hoog, Anton Kochkov, Antonio Sánchez, Austin Hartzheim, Aswin C (officialcjunior), Bob131, DZ_ruyk, David Tomaschik, Eric, Fangrui Song, Francesco Tamagni, FreeArtMan, Gerardo García Peña, Giuseppe, Grigory Rechistov, Hui Peng, ITAYC0HEN, Itay Cohen, Jeffrey Crowell, John, Judge Dredd (key 6E23685A), Jupiter, Kevin Grandemange, Kevin Laeufer, Luca Di Bartolomeo, Lukas Dresel, Maijin, Michael Scherer, Mike, Nikita Abdullin, Paul, Paweł Łukasik, Peter C, RandomLive, Ren Kimura, Reto Schneider, SchumBlubBlub, SkUaTeR, Solomon, Srimanta Barua, Sushant Dinesh, TDKPS, Thanat0s, Vanellope, Vex Woo, Vorlent, XYlearn, Yuri Slobodyanyuk, ali, aoighost, condret, hdznrrd, izhuer, jvoisin, kij, madblobfish, muzlightbeer, pancake, polym (Tim), puddl3glum, radare, sghctoma, shakreiner, sivaramaaa, taiyu, vane11ope, xarkes.
Оглавление
- Introduction
- History
- The Framework
- radare2
- rabin2
- rasm2
- Examples
- rahash2
- Examples
- radiff2
- rafind2
- ragg2
- Examples
- rarun2
- Sample rarun2 script
- Connecting a Program with a Socket
- Debugging a Program Redirecting the stdio into Another Terminal
- rax2
- Examples
- Downloading radare2
- Building with meson + ninja
- Helper Scripts
- Cleaning Up
- Compilation and Portability
- Static Build
- Meson build
- Docker
- Cleaning Up Old Radare2 Installations
- Windows
- Prerequisites
- Step-by-Step
- Install Visual Studio 2015 (or higher)
- Install Python 3 and Meson via Conda
- Set Up Conda:
- Create a Python Environment for Radare2
- Install Meson
- Install Git for Windows
- Get Radare2 Code
- Compile Radare2 Code
- Check That Radare2 Runs From All Locations
- Android
- Prerequisites
- Step-by-step
- Download and extract the Android NDK
- Make
- Specify NDK base path
- Compile + create tar.gz + push it to connected android device
- Meson
- Create a cross-file for meson
- Compile with meson + ninja
- Move files to your android device and enjoy
- User Interfaces
- Basic Radare2 Usage
- Command-line Options
- Common usage patterns
- Command Format
- Expressions
- Basic Debugger Session
- Contributing
- Radare2 Book
- Configuration
- Colors
- Themes
- Configuration Variables
- asm.arch
- asm.bits
- asm.syntax
- asm.pseudo
- asm.os
- asm.flags
- asm.lines.call
- asm.lines.out
- asm.linestyle
- asm.offset
- asm.trace
- asm.bytes
- asm.sub.reg
- asm.sub.jmp
- asm.sub.rel
- asm.sub.section
- asm.sub.varonly
- cfg.bigendian
- cfg.newtab
- scr.color
- scr.seek
- scr.scrollbar
- scr.utf8
- cfg.fortunes
- cfg.fortunes.type
- stack.size
- Files
- RC Files
- System
- Your Home
- Target file
- Basic Commands
- Seeking
- Open file
- Seeking at any position
- Block Size
- Sections
- Mapping Files
- Print Modes
- Hexadecimal View
- Show Hexadecimal Words Dump (32 bits)
- 8 bits Hexpair List of Bytes
- Show Hexadecimal Quad-words Dump (64 bits)
- Date/Time Formats
- Basic Types
- High-level Languages Views
- Strings
- Print Memory Contents
- Disassembly
- Selecting Target Architecture
- Configuring the Disassembler
- Disassembly Syntax
- Flags
- Local flags
- Flag Zones
- Introduction
- History
- The Framework
- radare2
- rabin2
- rasm2
- Examples
- rahash2
- Examples
- radiff2
- rafind2
- ragg2
- Examples
- rarun2
- Sample rarun2 script
- Connecting a Program with a Socket
- Debugging a Program Redirecting the stdio into Another Terminal
- rax2
- Examples
- Downloading radare2
- Building with meson + ninja
- Helper Scripts
- Cleaning Up
- Compilation and Portability
- Static Build
- Meson build
- Docker
- Cleaning Up Old Radare2 Installations
- Windows
- Prerequisites
- Step-by-Step
- Install Visual Studio 2015 (or higher)
- Install Python 3 and Meson via Conda
- Set Up Conda:
- Create a Python Environment for Radare2
- Install Meson
- Install Git for Windows
- Get Radare2 Code
- Compile Radare2 Code
- Check That Radare2 Runs From All Locations
- Android
- Prerequisites
- Step-by-step
- Download and extract the Android NDK
- Make
- Specify NDK base path
- Compile + create tar.gz + push it to connected android device
- Meson
- Create a cross-file for meson
- Compile with meson + ninja
- Move files to your android device and enjoy
- User Interfaces
- Basic Radare2 Usage
- Command-line Options
- Common usage patterns
- Command Format
- Expressions
- Basic Debugger Session
- Contributing
- Radare2 Book
- Configuration
- Colors
- Themes
- Configuration Variables
- asm.arch
- asm.bits
- asm.syntax
- asm.pseudo
- asm.os
- asm.flags
- asm.lines.call
- asm.lines.out
- asm.linestyle
- asm.offset
- asm.trace
- asm.bytes
- asm.sub.reg
- asm.sub.jmp
- asm.sub.rel
- asm.sub.section
- asm.sub.varonly
- cfg.bigendian
- cfg.newtab
- scr.color
- scr.seek
- scr.scrollbar
- scr.utf8
- cfg.fortunes
- cfg.fortunes.type
- stack.size
- Files
- RC Files
- System
- Your Home
- Target file
- Basic Commands
- Seeking
- Open file
- Seeking at any position
- Block Size
- Sections
- Mapping Files
- Print Modes
- Hexadecimal View
- Show Hexadecimal Words Dump (32 bits)
- 8 bits Hexpair List of Bytes
- Show Hexadecimal Quad-words Dump (64 bits)
- Date/Time Formats
- Basic Types
- High-level Languages Views
- Strings
- Print Memory Contents
- Disassembly
- Selecting Target Architecture
- Configuring the Disassembler
- Disassembly Syntax
- Flags
- Local flags
- Flag Zones
- Writing Data
- Write Over
- Zoom
- Yank/Paste
- Comparing Bytes
- SDB
- Usage example
- So what ?
- More Examples
- Dietline
- Autocompletion
- Emacs (default) mode
- Moving
- Deleting
- Killing and Yanking
- History
- Vi mode
- Entering command modes
- Moving
- Deleting and Yanking
- Visual Mode
- Navigation
- print modes aka panels
- Getting Help
- Visual Disassembly
- Navigation
- d as define
- Usage of the Cursor for Inserting/Patching...
- XREF
- Function Argument display
- Add a comment
- Type other commands
- Search
- The HUDS
- The "UserFriendly HUD"
- The "flag/comment/functions/.. HUD"
- Tweaking the Disassembly
- Visual Configuration Editor
- Examples
- asm.arch: Change Architecture & & asm.bits: Word size in bits at assembler
- asm.pseudo: Enable pseudo syntax
- asm.syntax: Select assembly syntax (intel, att, masm...)
- asm.describe: Show opcode description
- Visual Assembler
- Visual Configuration Editor
- Visual Panels
- Concept
- Overview
- Commands
- Basic Usage
- Split Screen
- Window Mode Commands
- Edit Values
- Tabs
- Saving layouts
- Searching for Bytes
- Basic Search
- Configuring Search Options
- Pattern Matching Search
- Search Automation
- Searching Backwards
- Assembler Search
- Searching for AES Keys
- Disassembling
- Adding Metadata to Disassembly
- ESIL
- Using ESIL
- ESIL Commands
- ESIL Instruction Set
- ESIL Flags
- Syntax and Commands
- Arguments Order for Non-associative Operations
- Special Instructions
- Quick Analysis
- CPU Flags
- Variables
- Bit Arrays
- Arithmetics
- Bit Arithmetics
- Floating Point Unit Support
- Handling x86 REP Prefix in ESIL
- Usage Example:
- Unimplemented/Unhandled Instructions
- ESIL Disassembly Example:
- Introspection
- API HOOKS
- Data and Code Analysis
- Code Analysis
- Analyze functions
- Hand craft function
- Recursive analysis
- Configuration
- Control flow configuration
- Reference control
- Analysis ranges
- Jump tables
- Platform specific controls
- Visuals
- Analysis hints
- Managing variables
- Type inference
- Types
- Loading types
- Printing types
- Linking Types
- Structure Immediates
- Managing enums
- Internal representation
- Structures
- Unions
- Function prototypes
- Calling Conventions
- Virtual Tables
- Syscalls
- Emulation
- Emulation in analysis loop
- Symbols
- Signatures
- Finding Best Matches zb
- Graph commands
- Ascii Art ** (e.g. agf )
- Interactive Ascii Art (e.g. agfv )
- Tiny Ascii Art (e.g. agft )
- Graphviz dot (e.g. agfd )
- JSON (e.g. agfj )
- Graph Modelling Language (e.g. agfg )
- SDB key-value (e.g. agfk )
- R2 custom graph commands (e.g. agf* )
- Web / image (e.g. agfw )
- Scripting
- Loops
- Macros
- Aliases
- R2pipe
- Examples
- Python
- NodeJS
- Go
- Rust
- Ruby
- Perl
- Erlang
- Haskell
- Dotnet
- Java
- Swift
- NewLisp
- Dlang
- Debugger
- Getting Started
- Small session in radare2 debugger
- Migration from ida, GDB or WinDBG
- How to run the program using the debugger
- How do I attach/detach to running process ? (gdb -p)
- How to set args/environment variable/load a specific libraries for the debugging session of radare
- How to script radare2 ?
- How to list Source code as in gdb list ?
- shortcuts
- Equivalent of "set-follow-fork-mode" gdb command
- Common features
- Registers
- Memory Maps
- Heap
- Files
- Reverse Debugging
- Windows Messages
- Remote Access Capabilities
- Debugging with gdbserver
- WinDBG Kernel-mode Debugging (KD)
- Setting Up KD on Windows
- Serial Port
- Network
- Connecting to KD interface on r2
- Serial Port
- Network
- Using KD
- WinDBG Backend for Windows (DbgEng)
- Using the plugin
- Tools
- Rax2
- rafind2
- Rarun2
- Rabin2 — Show Properties of a Binary
- File Properties Identification
- Code Entrypoints
- Imports
- Exports
- Symbols (Exports)
- List Libraries
- Strings
- Program Sections
- Radiff2
- Binary Diffing
- Rasm2
- Assembler
- Visual mode
- Disassembler
- pd N
- pD N
- pda
- pi, pI
- Disassembler Configuration
- ragg2
- Compiling ragg2 example
- Tiny binaries
- Syntax of the language
- Preprocessor
- Aliases
- Includes
- Hashbang
- Main
- Function definition
- Function signatures
- Function types
- Syscalls
- Libraries
- Core library
- Variables
- Arrays
- Tracing
- Poin ters
- Virtual registers
- Math operations
- Return values
- Traps
- Inline assembly
- Labels
- Control flow
- Comments
- rahash2
- Hashing by blocks
- Hashing with rabin2
- Obtaining hashes within radare2 session
- Examples
- Plugins
- Types of plugins
- Listing plugins
- Notes
- IO plugins
- Implementing a new disassembly plugin
- Moving plugin into the tree
- Implementing a new analysis plugin
- Implementing a new format
- To enable virtual addressing
- Create a folder with file format name in libr/bin/format
- Some Examples
- Write a debugger plugin
- More to come..
- Implementing a new pseudo architecture
- Python plugins
- Implementing new format plugin in Python
- Debugging
- Testing the plugin
- Creating an r2pm package of the plugin
- Crackmes
- IOLI CrackMes
- IOLI 0x00
- IOLI 0x01
- IOLI 0x02
- IOLI 0x03
- IOLI 0x04 0x04
- IOLI 0x05
- IOLI 0x06
- IOLI 0x07
- IOLI 0x08
- IOLI 0x09
- Avatao R3v3rs3 4
- .radare2
- .first_steps
- .main
- .vmloop
- ***
- .instructionset
- .bytecode
- .outro
- Radare2 Reference Card
- Survival Guide
- Flags
- Flagspaces
- Information
- Print string
- Visual mode
- Searching
- Saving (Broken)
- Usable variables in expression
- Authors & Contributors
- The radare2 book