the cat
S.9

MicroCorruption: Montevideo

On Uruguay to unlock Montevideo...

1 Sep 2020 · write-up · return address overwrite

You find a manual:

The main function just calls login.

A look at the conditional_door_unlock function:

You do a quick run with a test input aaaaaaaaaaaaaaaaaa of 18 characters. This is observed:

You would want to jump to the beginning of the injected shellcode.

From the manual, INT7F actually triggers the unlock. If this is pushed instead of 7E and an interrupt is called, the door should unlock.

Payload final draft #1:

Null byte.. big no no. Want to see it?

Because of the null byte, the copy will be unfinished therefore the payload incomplete thus plan fails.

Why not remove the null byte? Why is it there anyway? Answer: The lock's microprocessor(MPS430) has a mandatory memory alignment of 2-bytes. This means instructions, values etc, have to follow this alignment. Therefore, 0x7f has to be written as #0x007f. Also, because the microprocessor follows little-endian ordering, thus, #0x007f is eventually inputted as #0x7f00.

Read more here.

The null has to be done away with, but hooow? You need to find a way to push 0x007fwithout there being a null byte in the payload? We can calculate it.

Find two numbers whose addition/subtraction results in #0x007f. You decide to use 0x0212 and 0x0193. Substracting the latter from the former results in 0x7f. Sweet!

Now to assemble the payload.

Payload final final draft:

This should work. You input:

and the door opens for you!

Onwards to Novosibirsk..