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:
Today we're just going to get this thing done.
OK what's the samba?
Something like this:
First run tmux
then run ipython3 -i exp.py
where exp.py is the following script.
Confirm you have a two screen setup to interact AND debug
Either use that old pwndocker image (https://prof.ninja/pwndocker last three lines) OR
Use patchelf: patchelf --set-interpreter ./ld-linux-x86-64.so.2 --set-rpath . moms
confirm
the linking worked with ldd ./moms
Do the first few parts of the samba and VIEW AFTER FREE the big chunk. Save the view response into a variable
and do some Python to process the leak something like this: u64(uglybytes.ljust(8,b"\x00"))
Use vmmap
to find the base of glibc and subtract it from your leak to get the forever offset, save the offset into your script.
Now in all future versions you can do leak - forever_offset
to get the glibc base address (even though it's random every time). Confirm this by
print(hex(glibcbase))
and look for 000 at the end.
Now find the other two offsets you need: the offset from the base of glibc to the
location of system
and __free_hook
. Use info address __free_hook
and info address system
and
subtract the glibcbase to get your two forever offsets.
In your script the edits aren't separate lines but rather part of your malloc, and you'll need to add "indexes" which are
just references for you the hacker to use later. I'll encourage you to visualize the tcache bin after steps to make a really accurate mental model.
Once you think your samba is working then you can switch from the gdb line to the old p=process line at the top of your script. Then when you're done do p.interactive()
and cat flag.txt
.