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

OverTheWire Natas Level 7 → 8 tutorial!!

Login

URL: http://natas8.natas.labs.overthewire.org Credentials: natas8:xcoXLmzMkoIP9D7hlgPlh9XD7OgLAe5Q

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

homepage

Task

The page asks for a secret. Clicking View sourcecode reveals how the server checks it.

A little bit of Theory

The PHP shows an encoded constant and a function used to transform your input:

<?php
$encodedSecret = "3d3d516343746d4d6d6c315669563362";

function encodeSecret($secret) {
  return bin2hex(strrev(base64_encode($secret)));
}

So the server compares encodeSecret($_POST['secret']) with the hex string above. To find the correct input, we invert the operations in reverse order:

  1. hex → bytes
  2. reverse bytes → original base64 text
  3. base64 decode → the real secret

Further reading:

Solution

  1. Open source and copy the encoded string

    source

    3d3d516343746d4d6d6c315669563362
    
  2. Reverse the transform (quick script)

    Python:

    import base64
    s = bytes.fromhex("3d3d516343746d4d6d6c315669563362")
    s = s[::-1]
    secret = base64.b64decode(s)
    print(secret.decode())
    # -> oubWYf2kBq
    

    Or JS Console:

    const h="3d3d516343746d4d6d6c315669563362";
    const bytes=h.match(/../g).map(x=>parseInt(x,16));
    const b64=String.fromCharCode(...bytes.reverse());
    console.log(atob(b64)); // "oubWYf2kBq"
    
  3. Submit the secret oubWYf2kBq and read the result.

    success

Password

ZE1ck82lmdGIoErlhQgWND6j2Wzz6b6t

Troubleshooting

  • “Wrong secret”? → Order must be hex → reverse → base64 decode.
  • Garbled output? → Treat the hex as raw bytes before reversing.
  • Still stuck? → Copy/paste the Python snippet exactly.

Nice! 🎉 You reversed a custom encoder and pulled the secret for natas9. Onward!


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