pawned
pawned was a basic heap challenge that consisted on an use-after-free bug.
Files
The binary

The binary has 4 main features, one of them being a secret one that can be found reversing the binary and what those basically do is free, allocate, dump and edit chunks.

When freeing chunks, the pointer isn't removed from the list, creating a use-after-free condition and, potentially, memory leaks as well.
As always, I started by creating a few helper functions.
Leak libc
If we make a unsorted bin size allocation and then free it, the pointer will still exist but now will point to it's metadata, which contains a pointer to libc main arena, so we can easily leak libc.
Then we just need to parse the leak and subtract the offset to get the libc base.
Tcache poisoning
At this point, all we have to do is to set a tcache list to poison, free one of the chunks in the list then edit the fd pointer by abusing the use-after-free bug so we can allocate in arbitrary memory.

Final exploit
At this point my strategy was pretty simple, allocate at __free_hook , then edit with a pointer to system and free a chunk with /bin/sh in it's contents so when a free is called I'll get a shell.
Last updated
Was this helpful?