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

OverTheWire Bandit Level 20 → 21 tutorial!!

Login

Log in as bandit20 using the password you obtained from Level 19 → 20.

ssh bandit20@bandit.labs.overthewire.org -p 2220
# password: 0qXahG8ZjOVMN9Ghs7iOWsCfZyXOUbYO

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

Task

Task placeholder

There is a setuid helper called suconnect in your home. suconnect will connect to a TCP port on localhost and expects you to send the current password (for bandit20). If the password is correct, it returns the password for bandit21 over the same connection.

A little bit of Theory

  • setuid binaries run with the effective UID of the file owner. Here, suconnect is owned by bandit21, so the connection it makes and the check it performs happen as bandit21.
  • Plan:

    1. Start a Netcat listener on localhost:<PORT>.
    2. Run ./suconnect <PORT> so it dials your listener.
    3. Type the bandit20 password into the listener → it replies with the bandit21 password.
  • Netcat flavors:

    • OpenBSD: nc -l 12345
    • Traditional: nc -l -p 12345

Further reading:

Solution

  1. Inspect the helper

    ls -l
    file suconnect
    strings suconnect | head
    

    Why? Confirms setuid (-rwsr-x---) and usage suconnect <port>.

    inspect placeholder

  2. Start a listener on a random high port (Terminal A)

    PORT=$(shuf -i 20000-65000 -n 1); echo "Using port: $PORT"
    nc -l $PORT       # or: nc -l -p $PORT
    

    Why? Avoid port collisions on the shared host.

  3. Run the connector (Terminal B)

    ./suconnect $PORT
    

    Why? suconnect (running as bandit21) connects to your listener and waits for a line.

    suconnect placeholder

  4. Send the current password (Terminal A)

    Paste the bandit20 password and press Enter:

    0qXahG8ZjOVMN9Ghs7iOWsCfZyXOUbYO
    

    You should receive the bandit21 password back.

    receive placeholder

  5. Copy the printed password (no trailing spaces/newlines).

  6. Log into the next level (bandit21)

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

Password

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

EeoULMCra2q0dSkYj561DX7s1CpBuOBt

Troubleshooting

  • nc: Address already in use → Pick another port, e.g. PORT=$(shuf -i 30000-65000 -n 1).
  • No response after typing → Press Enter to send a newline.
  • Connection refused → Start the listener first, then run ./suconnect.
  • Only one terminal? → Use tmux (tmux; Ctrl+B ") or a second SSH session.
  • Garbage/extra spaces → Type the password carefully; only the exact line plus newline.

Copy-paste quick run (two terminals)

# Terminal A (listener)
PORT=$(shuf -i 20000-65000 -n 1); echo "Using port: $PORT"
nc -l $PORT          # or: nc -l -p $PORT

# Terminal B (connector)
./suconnect $PORT

# Back to Terminal A: paste bandit20 password, press Enter → it prints bandit21 password.

Congrats 🎉 You used a setuid connector and a local listener to exfiltrate the next password — welcome to bandit21!


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