Space pirate: Entrypoint
A standard FSB challenge
Initial Impressions
We are given a 64-bit binary file that upon running gives us two options.
โโโ(kaliใฟkali)-[~/Desktop/CTF/PWN/htb_spacepirate_entrypoint]
โโ$ ./sp_entrypoint
Authentication System
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโ
โโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโ
โโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโ
โโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโ
โโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โโโ โโโ โโโ โโโ โโโโโโโโโ
โโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โโโ โโโ โโโ โโโ โโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโ โโโ โโโ โโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโ โโโ โโโ โโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโ โโโ โโโ โโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโ โโโ โโโ โโโ โโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโ โโโ โโโ โโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโ โโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโ โโโ โโโ โโโ โโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโ โโโ โโโ โโโ โโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโ โโโ โโโ โโโ โโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโ โโโโโ โโโ โโโ โโโ โโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโ โโโโโ โโโ โโโ โโโ โโโโโโโโโโโโโโโโโ
โโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโ โโโโโ โโโ โโโ โโโ โโโ โโโโโโโโโ
โโโโโโโโโโ โโโโโโโโโโโโ โโ โโโ โโโโโ โโโ โโโ โโโ โโโ โโโโโโโโโ
โโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโ
โโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโ
โโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโ
โโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
1. Scan card ๐ณ
2. Insert password โช๏ธ
>
Looking at the decompiled main function in Ghidra, it gives us two functions of interest, open_door and check_pass.
The open_door() function prints out the flag to us while the check_pass() authenticates us if our input is 0nlyTh30r1g1n4lCr3wM3mb3r5C4nP455.
However, that is impossible as the input is only accepting 15 bytes of input (Oxf).
Looking back at the main function, we see a possible FSB vulnerability on line 27 and 29 where our input is being displayed directly with printf.
This can be easily tested with %p which leaks a value of the stack.
We can also see that the variable declared earlier local_48 is on the stack 0xdeadbeef.
Exploit
To successfully get the flag, we need to
Leak the location of the pointer to
local_48on the stackOverwrite the contents of
local_48to be equivalent0xdead1337to pass the check
Using %p.%p.%p.%p.%p.%p.%p, we can see that local_48 is on the 6th position on the stack.
With the use of pwndbg, we can see that the pointer to local_48 is on the 7th position on the stack 0x7fffffffdc68 pointing to 0x7fffffffdc60.
We can then $hn to overwrite the last word (4 bytes) of 0xdeadbeef with %4914c which translates to 1337 in decimal., making local_48 = 0xdead1337.
This makes our final payload %4919c%7$hn, with %7 referring to the pointer to local_48 and $hn referring to the beef portion of 0xdeadbeef which we are trying to overwrite.
Last updated