PicoCTFHardReverse500 pts

Spelunky

cyberhub2024-03Original source

Overview

Reverse engineering a stripped binary to reconstruct the flag generation algorithm, involving anti-debugging techniques and obfuscated control flow.

Reverse EngineeringAnti-DebuggingBinary AnalysisGhidraControl Flow Obfuscation

01Reconnaissance

Every engagement starts with mapping what is reachable. A full service scan of Spelunky highlighted the exposed surface and pointed at reverse engineering as the most promising entry point.

Enumeration is deliberately exhaustive here — the goal is to leave no service unexamined before committing to an attack path.

nmap — service discovery
$ nmap -sC -sV -oN nmap/initial 10.10.11.42
PORT     STATE SERVICE  VERSION
22/tcp   open  ssh      OpenSSH 8.9p1 Ubuntu
80/tcp   open  http     nginx 1.18.0
$ echo "10.10.11.42 spelunky.htb" | sudo tee -a /etc/hosts
$ gobuster dir -u http://spelunky.htb -w /usr/share/wordlists/dirb/common.txt -q
/login                (Status: 200)
/api                  (Status: 401)

02Exploitation

Decompilation exposed a check that compared the input against a value computed at runtime.

In this reverse challenge that translated into a repeatable foothold. Reverse engineering a stripped binary to reconstruct the flag generation algorithm, involving anti-debugging techniques and obfuscated control flow.

analysis — recovering the logic
$ file ./bin
$ r2 -A ./bin
[0x00001060]> pdf @ main
$ ./bin $(python3 keygen.py)

03Flags

The flag is recovered directly from the solved challenge.

flags
$ cat flag.txt
picoCTF{redacted_for_this_writeup}

Commands are illustrative of the technique and platform, not a live exploit against a specific target. Follow the original source link for the authoritative walkthrough.