Don't like this style? Click here to change it! blue.css

LOGIN:
Welcome .... Click here to logout

Daily Reminder: Mom's Spaghetti

Our compass through all of this is the desire for the following comfort food:

Today we're just going to get this thing done.

LAB DAY: Leak a glibc, compute FREE_HOOK and system, tcache-poisoning for WWW

(Given a USE-AFTER-FREE)

OK what's the samba?

Something like this:

Practical Stages:

Stage 1: Binary runs with pwntools AND pwndbg

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

Stage 2: Make sure you are linked to glibc 2.31

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

Stage 3: Generate and process a leak

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.

Stage 4: Finish the Samba get your flag

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.

Heap Reference Guides: