Visual mode is a user-friendly alternative to the command line that offers a variety of visualization features. This allows the user to view, debug, and run the binary in a format that is easier to read. This is mostly equivalent to gdb's GEF plugin, but you directly interact with the UI rather than the UI responding to command-line arguments.
Visual mode overrides a few command-line functionalities, so it's important to discuss the Visual mode equivalents.
To enter Visual mode, use V. To quit Visual mode, use q.
There are five views in Visual mode. These are:
x: Hexadecimal viewa: Disassembly listingd: Debugger Viewv: Visual colorsc: Cursor viewThe most useful view is the Debugger view. This view shows us the stack, registers, and disassembly. We can move around the binary via seeking and stepping.
Use the p command to cycle through the views. Use P to cycle through the views in reverse.
Vpp from the command line. This opens the debugger view directly.[0x080491ef [xaDvc]0 150 args]> breakpoint at 0x00000000- offset - DCDD DEDF E0E1 E2E3 E4E5 E6E7 E8E9 EAEB CDEF0123456789AB0xff9d91dc c3bc d1f7 0100 0000 9492 9dff 9c92 9dff ................0xff9d91ec 0092 9dff 148e f2f7 ad90 0408 0100 0000 ................0xff9d91fc 9492 9dff 148e f2f7 04bf 0408 60cb f7f7 ............`...0xff9d920c 0000 0000 e40e Using Visual Mode, we can more easily perform static and dynamic analysis on a binary. This section will discuss two modes that are commonly used to analyze functions and then debug the binary.
Visual Debugger Mode is an immensely powerful tool for static and dynamic analysis of a binary. This mode shows us the instructions, stack, and registers at a seek address. We can also use this mode to run the binary and debug it.
Visual Debugger Mode offers a few ways to navigate the binary. Below are the standard navigation commands for Visual Debugger Mode. These commands directly influence the current seek address.
j - Move the seek address forward one instruction.k - Move the seek address back one instruction.h - Decrease the seek address by one byte.l - Increase the seek address by one byte.j and k to move between instructions. Moving one byte at a time isn't very useful.There are a few other useful navigation commands. These are:
$eipc - Show/hide the cursor. This is useful for labeling commands like comments.Enter - Seek into the current function. This is useful for navigating across the binary and resolving functions.u - Undo the last seek maneuver. This is used in conjunction with Enter to return to the calling function.g / G - Seek to the beginning/end of the binary.x - Show cross-references to the current seek address. This is useful for finding functions that call the current function.. command, references will be renamed in terms of eip. Using the s command to move elsewhere resets this.[0x080491ef [xAdvc]0 150 args]> ;-- eip:┌ 95: int main (char **argv);│ `- args(sp[0x4..0x4]) vars(2:sp[0xc..0x30])│ 0x080491ef ● 8d4c2404 lea ecx, [argv]│ 0x080491f3 83e4f0 and esp, 0xfffffff0│ 0x080491f6 ff71fc push dword [ecx - 4]│ 0x080491f9 55 push ebp│ 0x080491fa 89e5 mov ebp, esp│ 0x080491fc 51 push ecx│ 0x080491fd 83ec24 sub esp, 0x24│ 0x08049200 83ec0c esp, When inside Visual Debugger Mode, use the : command to open the command line. Like Vim, this opens a small command line at the bottom of the window to enter commands.
Once you enter a command, another command line appears to allow you to enter another command. To exit this, use Enter again to leave the command-line environment.
s that actively change location, ensure you exit the command line to register the new location.Unfortunately, we don't have a shortcut to set breakpoints in Visual Debugger Mode automatically. However, using the : command, we can set breakpoints using the db command. We also don't have a shortcut to continue to this breakpoint, so we use :dc to continue to the breakpoint.
Once we do this, we will see our instruction pointer at the start of main.
[0x080491ef [xAdvc]0 150 args]> ;-- eip:┌ 95: int main (char **argv);│ `- args(sp[0x4..0x4]) vars(2:sp[0xc..0x30])│ 0x080491ef ● 8d4c2404 lea ecx, [argv]│ 0x080491f3 83e4f0 and esp, 0xfffffff0│ 0x080491f6 ff71fc push dword [ecx - 4]│ 0x080491f9 55 push ebp│ 0x080491fa 89e5 mov ebp, esp│ 0x080491fc 51 push ecx│ 0x080491fd 83ec24 sub esp, 0x24│ 0x08049200 83ec0c esp, We can use the following shortcuts to step through the binary:
s - Step into the current instruction.S - Step over the current instruction.We can use these to quickly step through the binary and watch the registers and stack.
radare2 freezes every time I step over a gets instruction. I'm not sure why this is. The only mitigation I have found is to close Visual Debugger Mode before stepping over this instruction.Visual Code Analysis is a somewhat hidden feature of Visual Mode. This mode mimics using pdf on the command line to show us disassemblies for all functions.
To enter this mode, use Vv from the command line or press v from anywhere inside Visual Mode.
.-- functions ----- pdr ---------------------.| (a)nalyze (-)delete (xX)refs (jk)scroll || (r)ename (c)alls (d)efine (tab)disasm | ; CALL XREF from sym.read_in @ 0x80491cc(x)| (d)efine (v)ars (?)help (:)shell | ┌ 25: sym.win ();| (s)ignature (_)hud (q)quit (;)comment | │ 0x08049196 push ebp'-------------------------------------------' │ 0x08049197 mov ebp, esp 0x08049120 53 sym.register_tm_clones │ 0x08049199 sub esp, 8 0x08049160 34 entry.fini0 │ 0x0804919c sub esp, 0xc 0x08049190 6 entry.init0 │ 0x0804919f push str.You_win_ 0x080490d0 4 sym.__x86.get_pc_thunk.bx │ 0x080491a4 call sym.imp.puts 0x08049250 20 sym._fini │ 0x080491a9 add esp, You can use the up and down arrows (or j and k) to navigate between functions. You can use the Enter key to seek to that function.
This pane has many functionality for modifying functions. However, this guide doesn't cover write mode.