Before Pwn
alarm
If a binary uses alarm as a timeout and you are sure the vulnerability is not inside alarm, you can patch its function name to isnan.
- Open the binary in Vim.
- Replace the function name
alarmwithisnan, then save the file. - Done.
Link libc with debugging information
When debugging with GDB, stepping into a libc function normally provides no symbols or similar debugging information. This makes debugging harder, so it is useful to link the binary against a libc build that includes debugging information.
- Follow Build libc with debug info to build a libc with debugging information.
- Run
ldd <binary>to identify the linked loader. - Patch the loader path so it points to the loader you built.
- Done.
A shortcut for patching the loader path
Suppose the original loader path is /lib64/ld-linux-x86-64.so.2. First create a symbolic link at /lib64/ld_linux-x86-64.so.2 that points to your custom loader. You then only need to replace ld- with ld_ in the binary’s loader path.
Note
After replacing the loader, it will prefer the libc in the same directory, allowing the binary to link against the libc build with debugging information.