These commands are used to control GEF's interface.
contextThe context is the heart of GEF. It provides the state of the registers, stack, instruction pointer, threads, and stack trace. The context loads and updates automatically as you run the program.
This is what the context pane looks like:
context[ Legend: Modified register | Code | Heap | Stack | String ]───────────────────────────────────────────────────────────────────────────────────── registers ────$eax : 0x0804908d → <_start+002d> jmp 0x8049196 <main>$ebx : 0xf7fa8e14 → 0x00231d0c$ecx : 0xffffd6b0 → 0x00000001$edx : 0xffffd6d0 → 0xf7fa8e14 → 0x00231d0c$esp : 0xffffd694 → 0xffffd6b0 → 0x00000001$ebp : 0xffffd698 → 0x00000000$esi : 0x0804bf04 → 0x08049140 → <__do_global_dtors_aux+0000> endbr32$edi : 0xf7ffcb60 → 0x00000000$eip : 0x080491a4 → <main+000e> sub esp, 0x4$eflags: [zero carry PARITY adjust SIGN trap INTERRUPT direction overflow resume virtualx86 identification]$cs: 0x23 $ss: 0x2b $ds: 0x2b $es: 0x2b $fs: 0x00 $gs: 0x63───────────────────────────────────────────────────────────────────────────────────────── stack ────0xffffd694│+0x0000: 0xffffd6b0 → 0x00000001 ← $esp0xffffd698│+0x0004: 0x00000000 ← $ebp0xffffd69c│+0x0008: 0xf7d9bcc3 → add esp, 0x100xffffd6a0│+0x000c: 0x000000000xffffd6a4│+0x0010: 0x000000000xffffd6a8│+0x0014: 0xf7db4fc9 → add ebx, 0x1f3e4b0xffffd6ac│+0x0018: 0xf7d9bcc3 → add esp, 0x100xffffd6b0│+0x001c: 0x00000001─────────────────────────────────────────────────────────────────────────────────── code:x86:32 ──── 0x80491a0 <main+000a> push ebp 0x80491a1 <main+000b> mov ebp, esp 0x80491a3 <main+000d> push ecx●→ 0x80491a4 <main+000e> sub esp, 0x4 0x80491a7 <main+0011> sub esp, 0xc 0x80491aa <main+0014> push 0x804a008 0x80491af <main+0019> call 0x8049050 <puts@plt>─────────────────────────────────────────────────────────────────────────────────────── threads ────[#0] Id 1, Name: "args", stopped 0x80491a4 in main (), reason: BREAKPOINT───────────────────────────────────────────────────────────────────────────────────────── trace ────[#0] 0x80491a4 → main()Use context to refresh the context. This prints the current context. This is useful if you have printed other data and want to re-see the context.
You can use gef config context.layout to change the layout of the context. By default, all sections are shown.
gef config context.layout─────────────────────────────────── GEF configuration setting: context.layout ───────────────────────────────────context.layout (str) = "legend regs stack code args source memory threads trace extra libc_function_args syscall_args libc_function_args syscall_args libc_function_args syscall_args"Description: Change the order/presence of the context sectionsTo hide a section, prepend the section name with a - (or omit it).
gef config context.layout "-legend regs stack code args -source -threads -trace extra memory"legend, source, threads, and trace sections.The following are also customizable:
nb_lines_stack: The number of lines of the stack to show.nb_lines_backtrace: The number of lines of the backtrace to show.nb_lines_code and nb_lines_code_prev: The number of lines of code to show before and after the current instruction.context.nb_lines_threads: The number of lines of the threads to show.Finally, you can change the direction that the stack grows using:
gef config context.grow_stack_down Truetmux-setupTo make GEF's output more readable, you can use the tmux-setup command to format the GEF window inside tmux. This will split the plane vertically and place the context in the right-hand pane.
As you enter commands on the left side, the context will update on the right.