Floormat Sale

Writeup for Floormat Mega Sale (Pwn) - 1337UP LIVE CTF (2024) ๐Ÿ’œ

Challenge Description

The Floor Mat Store is running a mega sale, check it out!

If you played last 1337UPLIVE last year, you might remember the floormat store. Players were required to exploit a format string vulnerability in printf() to leak the flag off the stack. This year, the floormat store is having a MEGA SALE!

Solution

First, check the binary protections.

checksec --file floormat_sale
[*] '/home/crystal/Desktop/challs/pwn/FloormatSale/solution/floormat_sale'
    Arch:     amd64-64-little
    RELRO:    Partial RELRO
    Stack:    No canary found
    NX:       NX enabled
    PIE:      No PIE (0x400000)

You might think buffer overflow because there's no stack canaries, but that is not the case.

Let's see what the functionality looks like this time.

nc localhost 1339
Welcome to the Floor Mat Mega Sale!

Please choose from our currently available floor mats:

Please select a floor mat:

1. Cozy Carpet Mat - $10
2. Wooden Plank Mat - $15
3. Fuzzy Shag Mat - $20
4. Rubberized Mat - $12
5. Luxury Velvet Mat - $25
6. Exclusive Employee-only Mat - $9999

Enter your choice:
6

Please enter your shipping address:
cryptocat!

Your floor mat will be shipped to:

cryptocat!

Access Denied: You are not an employee!

Alright, like last time then, let's try and provide a format specifier to see if we can leak values from the stack.

Bingo! We could try leaking values from the stack and converting from hex, or using the %s specifier but the flag isn't there this time (wouldn't be a new challenge then, would it?).

You'll want to disassemble the code to see what's going on. I cba rn so here's the original source.

The function is called when we use the menu option 6. There's nothing in the code that will ever change the employee variable, hopefully this is a hint you need to overwrite that variable.

I've covered format string write attacks on my youtube a few times so I'll not do repeat myself in detail here. We already know the location of the variable we want to overwrite (PIE is disabled, we can get it from assembly or reference directly in pwntools) and what we want to overwrite it with (anything but 0). The only thing we need to know is the offset of where our input will land, and we can find that with a fuzzing script.

fuzz.py

We run that and see our AAAA lands at various offsets, e.g. 8, 10, 12 etc.

Not all of these offsets will work. I tried 8 and it didn't work but 10 did. You should be able to automate this stage as well but I couldn't get it working (I don't do pwn challenges anymore xD).

So here's a pwntools script to solve the challenge for us! It will overwrite the employee variable with a 1.

solve.py

When we enter menu option 6, we'll get the flag.

Flag: INTIGRITI{3v3ry_fl00rm47_mu57_60!!}

Last updated