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

OverTheWire Leviathan Level 1 → 2 tutorial!!


Login

Log in as leviathan1 using the password from Level 0 → 1.

ssh leviathan1@leviathan.labs.overthewire.org -p 2223
# password: 3QJ3TgzHDq

Why? Each Leviathan level is a different UNIX user. To solve 1 → 2, you must be leviathan1.


Task

OTW says there is a SUID binary in the home directory of leviathan1. Your goal: use it to obtain the password for leviathan2.


A little bit of Theory

  • SUID: when an executable has the setuid bit, it runs with the owner’s privileges (here, leviathan2).
  • strings: prints printable strings inside binaries—sometimes reveals clues.
  • ltrace: traces library calls (like strcmp) and shows the arguments the program uses—often enough to leak the expected password.

Further reading:


Solution

  1. Explore the directory

    ls -la
    

    Why? r-s on the owner means SUID; executing check will run as leviathan2.

    Look for a SUID binary:

    -r-sr-x--- 1 leviathan2 leviathan1 15084 Aug 15 13:17 check
    

    inspect


  1. Run the binary once

    ./check
    password: test
    Wrong password, Good Bye ...
    

    Why? Confirms it asks for a password and exits on failure.

    run


  1. Try strings for quick wins

    strings check
    

    Why? Not all binaries keep secrets as plaintext—so we escalate to tracing.

    You’ll see things like password:, Wrong password, Good Bye ..., strcmp, etc., but no plaintext secret.

    strings


  1. Trace with ltrace to catch strcmp

    ltrace ./check
    

    Type any guess (e.g., 1341232) and watch the trace:

    printf("password: ")                              = 10
    getchar(... )                                     = '1'
    getchar(... )                                     = '3'
    getchar(... )                                     = '4'
    strcmp("134", "sex")                              = -1
    puts("Wrong password, Good Bye ...")              = 29
    +++ exited (status 0) +++
    

    Why? ltrace reveals the exact argument passed to strcmp, which is the expected password.

    → The program compares our input to “sex”.

    ltrace


  1. Use the discovered password

    ./check
    password: sex
    $ whoami
    leviathan2
    

    Why? The SUID binary spawned a subshell running as leviathan2.

    shell


  1. Read the actual level password

    All level passwords live in /etc/leviathan_pass/.

    cat /etc/leviathan_pass/leviathan2
    

    Why? On Leviathan, the definitive credential is in this path; the SUID shell gives you permission to read it.

    Output:

    NsN1HwFoyN
    

    decrypt


Password

NsN1HwFoyN

Troubleshooting

  • ltrace shows nothing? Make sure you’re tracing ./check directly, not via a shell wrapper.
  • Only gibberish from strings? That’s normal; ltrace is the key here.
  • Didn’t get a subshell? You must type the exact string sex when ./check prompts.

Copy-paste quick run

ssh leviathan1@leviathan.labs.overthewire.org -p 2223
# password: 3QJ3TgzHDq

ls -la                 # spot SUID ./check
ltrace ./check         # reveals strcmp(..., "sex")
./check
password: sex          # get subshell as leviathan2
whoami                 # → leviathan2
cat /etc/leviathan_pass/leviathan2
# → NsN1HwFoyN

Congrats 🎉 You used ltrace to leak a hard-coded comparison and escalated via a SUID binary. On to leviathan2!


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