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

OverTheWire Bandit Level 19 → 20 tutorial!!

Login

Log in as bandit19 using the password you obtained from Level 18 → 19.

ssh bandit19@bandit.labs.overthewire.org -p 2220
# password: cGWpMaKXVwDUNgPAVJbWYuGHVn9zl3j8

Why? Each Bandit level is a separate UNIX user. To solve 19 → 20, you must be the bandit19 user.

Task

Task placeholder

There is a setuid helper binary in your home directory: bandit20-do. It runs a command as user bandit20. The password for the next level is stored in /etc/bandit_pass/bandit20. Use the helper to read it.

A little bit of Theory

  • setuid: if an executable has the s bit on user perms (e.g., -rwsr-x---), it runs with the file owner’s EUID. Here, bandit20-do is owned by bandit20, so commands it executes run as bandit20.
  • The helper likely takes a command line such as:

    ./bandit20-do <command> [args...]
    

    so we can have it run /bin/cat /etc/bandit_pass/bandit20.

Further reading:

Solution

  1. Inspect the helper binary

    ls -l
    

    Why? You should see bandit20-do with the s bit set (rws).

    ls placeholder

  2. Read the built-in usage (optional)

    ./bandit20-do
    # or try a harmless command:
    ./bandit20-do id
    

    Why? Confirms it runs as bandit20 (look for uid=11020(bandit20) in output).

    usage/id placeholder

  3. Use the helper to print the password file

    ./bandit20-do /bin/cat /etc/bandit_pass/bandit20
    

    Why? We ask it to execute cat as bandit20, so it can read that file.

    cat placeholder

  4. Copy the password (no trailing spaces/newlines).

  5. Log into the next level (bandit20)

    exit
    ssh bandit20@bandit.labs.overthewire.org -p 2220
    # paste the password you just printed
    

Password

This is the password from my run; if yours differs, use the one your terminal printed.

0qXahG8ZjOVMN9Ghs7iOWsCfZyXOUbYO

Troubleshooting

  • “Permission denied” when reading the file → You forgot to use the helper or used plain cat. Must be:

    ./bandit20-do /bin/cat /etc/bandit_pass/bandit20
    
  • “No such file or directory” → Double-check the exact path /etc/bandit_pass/bandit20 and that you ran ./bandit20-do from ~.
  • Helper says “Run a command as another user” and exits → You didn’t pass a command; try ./bandit20-do id first.
  • Command not found → Use absolute path /bin/cat to avoid PATH issues.

Congrats 🎉 You used a setuid helper to execute a command as another user — welcome to bandit20!


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