These commands are useful for finding vulnerabilities and speeding up the exploit development process.
format-string-helper
The format string helper is a tool to help with format string vulnerabilities. It adds breakpoints at the start of printf and similar functions. If a potentially vulnerable format string is found, it will trigger the breakpoint.
If we continue the program, we see there is a potential format string bug:
────────────────────────────────────────────────────────────────────────────────────────────────────── trace ────
[#0] 0xf7c57a90 → printf()
[#1] 0x80491fb → main()
────────────────────────────────────────────────────────────────────────────────────────────────────── extra ────
[*] Format string helper
Possible insecure format string: printf('[sp + 0x4]' → 0xffffd57c: 'AAAA\n')
Reason: Call to 'printf()' with format string argument in position #0 is in page 0xfffdd000 ([stack]) that has write permission
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────
The best course is to use finish to reach the end of the printf command since the helper puts the breakpoint inside the function. We can then check the disassembly to see if there is truly a format string bug.
search-pattern alters the original find command by making it more user-friendly. search-pattern looks across all memory segments in all loaded files for the pattern.
gef➤ search-pattern "/bin/cat flag.txt"
[+] Searching '/bin/cat flag.txt' in memory
[+] In '/home/joybuzzer/split'(0x601000-0x602000), permission=rw-
0x601060 - 0x601071 → "/bin/cat flag.txt"
gef➤ search-pattern "/bin/sh"
[+] Searching '/bin/sh' in memory
[+] In '/usr/lib/x86_64-linux-gnu/libc.so.6'(0x7ffff7dbd000-0x7ffff7e15000), permission=r--
0x7ffff7dd8698 - 0x7ffff7dd869f → "/bin/sh"
You can still specify a memory range to search in:
gef➤ search-pattern "/bin/cat flag.txt" little 0x600000-0x602000
[+] Searching '/bin/cat flag.txt' in 0x600000-0x602000
[+] In '/home/joybuzzer/Documents/vunrotc/.public/binex/05-rop/split/src/split'(0x600000-0x601000), permission=r--
0x601060 - 0x601071 → "/bin/cat flag.txt"
gef➤ search-pattern "/bin/sh" little libc
[+] Searching '/bin/sh' in libc
[+] In '/usr/lib/x86_64-linux-gnu/libc.so.6'(0x7ffff7dbd000-0x7ffff7e15000), permission=r--
0x7ffff7dd8698 - 0x7ffff7dd869f → "/bin/sh"
GEF wants to search loaded libraries for the pattern. Therefore, search-pattern can only be used during runtime.
shellcode
This command provides a command-line interface for the Shellstorm Database. It allows you to search for shellcode and download it directly into the debugged process. There are two subcommands: search and get.