Graph Mode is a powerful tool for analyzing control flow. This mode allows us to visualize the control flow of a binary in a flowchart. This is useful for understanding how the binary works and how to solve challenges.
To enter Graph Mode, use the VV command (or V inside Visual Mode). Use q to leave Graph Mode.
There are 5 views in Graph Mode. These are:
radare2 uses to emulate instructions.The most common view used is Graph View + Opcodes. Use the p shortcut to cycle through views, and P to cycle in reverse.
[0x080491af]> 0x80491af # sym.read_in (char *s1); ┌──────────────────────────────────────────────┐ │ [0x80491af] │ │ ;-- eip: │ │ ;[x] CALL XREF from main @ 0x804923e(x) │ │ 64: sym.read_in (char *s1); │ │ `- args(sp[0x4..0x4]) │ │ push ebp │ │ mov ebp, esp │ │ sub esp, 8 │ │ sub esp, 8 │ │ ; const char *s2 │ │ ; 0x804a011 Graph Mode is very useful for understanding branching. Since it can only show one function at a time, it can be annoying to traverse several function calls. This tool is more useful for static analysis and reverse engineering.
Use the V command while inside Graph Mode to switch the Graph Mode layout. The other layout shows snippets of cross-references from the current function. This is less useful than the default layout, but it's still a useful tool to have.
[0x080491af]> 0x80491af # sym.read_in (char *s1); ┌────────────────────┐ │ [0x80491af] │ └────────────────────┘ v v │ │─────────────────────────────────────────────│ │─────────────────────────────────────────────│ │─────────────────────────────────────────────│ │ ┌────────┘ │ │ │──────────────────────────────────────────┐ │ │────────────────────────────────────────────────── │ └────────────────────────────────────────────────── │ │─────────────────────────┐ ┌──────────────────────────────────────────────────┐ ┌───────────── │ │ 0x8049196 │ │ 0x80491edm.read_in @ 0x80491ca(x) │ │ ;[x] CALL XREF from sym.read_in @ 0x80491cc(x) │ │ ; Graph Mode's commands are a bit different from the other modes. These commands are:
Tab - Move to the next node.Ctrl + / Ctrl - - Zoom in/out.g<identifier> - Seek to the given identifier.u - Undo the last seek maneuver.s/S - Step in/over the current instruction.To view the help command window, use the ? shortcut.