the cat
S.7

MicroCorruption: Addis Ababa

Ab..about last night!

1 Sep 2020 · write-up · format string vulnerability

You get to Addis Ababa and find a lock with a manual:

Usernames are printed back. This must be a clue. You think of format string vulnerabilities. Note to self: Printf!!

This is the main function:

A quick run with test input: aaaaaaaaaaaaaaaaaaa (19 characters) to study program flow.

The test_password_valid function:

The flag gets set at address 0x3a32; the test input is wrong so flag is not set.

The input is printed out as is. The printf function is bulky but basically, it also checks for format specifiers: %s, %x, %nand displays accordingly. This presents an exploitable vulnerability. A look at %n:

Detour:
Read more about format string vulnerability here.
The following, is relevant snippets for this particular task.

This can be exploited to overwrite a value in memory... but where to write to? The address where the flag gets set! The door gets unlocked when the flag is not zero.

Flag not zero: call to unlock_door... Hello!

Jo cannot wait no more! _0/