Don't like this style? Click here to change it! blue.css
Our compass through all of this is the desire for the following comfort food:
You're babies today and we're going to learn the warmth and love of the dining room table. So that as you venture into the wilderness you'll do your best to recreate this ritual in ever harsher environments.
So the last stage of a successful attack is to control the instruction pointer.
The FREE_HOOK is a symbol in glibc (< 2.34) that allows people to implement a custom free function for debugging.
The address at FREE_HOOK is typically 0 but it's a RW- segment so you can edit it to put in a custom version of free.
Our job in the Mom's Spaghetti is to replace the address at FREE_HOOK with the address of system
.
THEN we call FREE on a chunk where "/bin/sh" is written.
OK what's the samba?
Something like this:
So our mom's spaghetti runs on glibc 2.31, so you'll want to patch the binary to use glibc 2.31:
SOLUTION patchelf --set-interpreter ./ld-linux-x86-64.so.2 --set-rpath . binaryname
Learn how u64
works in pwntools, it consumes the weird unprintable strings and produces the integer leak.
Needs 8 bytes though. So something like u64(raw.ljust(8, b"\x00"))
maybe.
So we have 3-4 addresses we need to deal with:
info address *
info address main_arena
info address __free_hook
info address system
vmmap
There are other ways to deal with this kind of thing including:
libc=ELF("./libc.so.6")
libc.sym.system
libc.sym.__free_hook