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

OverTheWire Leviathan Level 4 → 5 tutorial!!


Login

Log in as leviathan4 using the password from Level 3 → 4.

ssh leviathan4@leviathan.labs.overthewire.org -p 2223
# password: WG1egElCvO

Why? Each Leviathan level is a different UNIX user. To solve 4 → 5, you must be leviathan4.


Task

There’s something interesting in your home directory — find it and extract the password for leviathan5.


A little bit of Theory

  • Sometimes binaries don’t hide a password — they output encoded data you must transform.
  • If you see a long string of 0/1, think binary → ASCII. Common quick decoders:

    • perl -0777 -pe 's/\s+//g; $_ = pack("B*", $_)'
    • xxd -r -b (expects groups of 8 bits)

Further reading:


Solution

  1. Explore the directory

    ls -la
    find . -maxdepth 2 -type f -o -type d
    

    Why? Quick recon often reveals hidden folders. You should see .trash/ with an executable bin inside.

    inspect

  2. Identify and run the binary

    file .trash/bin
    ./.trash/bin
    

    Why? file confirms it’s an ELF; running it prints a long line of 0/1 bits.

    run

  3. Decode binary → ASCII (Method A: Perl, recommended)

    ./.trash/bin | perl -0777 -pe 's/\s+//g; $_ = pack("B*", $_)'
    

    Why? -0777 slurps the entire stream, s/\s+//g strips whitespace/newlines, and pack("B*", ...) converts the bitstring directly to bytes → clean ASCII.

  4. Alternative: Decode with xxd (Method B)

    ./.trash/bin | tr -cd '01' | sed 's/.\{8\}/& /g' | xxd -r -b
    

    Why? xxd -r -b needs octets separated by spaces/newlines. tr filters to 0/1, sed inserts a space every 8 bits. This avoids “cannot seek backwards” errors.

  5. Grab the password

    The decoded output is plain text:

    leviathan5: 0dyxT7F4QD
    

    Why? The program emits the next username and password encoded as bits; once decoded, it’s readable ASCII.

    decrypt


Password

0dyxT7F4QD

Troubleshooting

  • No output? Run ./.trash/bin from the leviathan4 home directory.
  • xxd complains? Make sure bits are grouped into 8s (sed 's/.\{8\}/& /g') or use the Perl one-liner.
  • Weird leading characters? Use the Perl command that strips whitespace before pack.

Copy-paste quick run

ssh leviathan4@leviathan.labs.overthewire.org -p 2223
# password: WG1egElCvO

cd ~
file .trash/bin

# Method A (Perl — recommended)
./.trash/bin | perl -0777 -pe 's/\s+//g; $_=pack("B*", $_)'
# → leviathan5: 0dyxT7F4QD

# Method B (xxd)
./.trash/bin | tr -cd '01' | sed 's/.\{8\}/& /g' | xxd -r -b
# → leviathan5: 0dyxT7F4QD

ssh leviathan5@leviathan.labs.overthewire.org -p 2223
# password: 0dyxT7F4QD

Congrats 🎉 You recognized a binary-to-ASCII trick and extracted the next password. Onward to leviathan5!


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