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

OverTheWire Bandit Level 18 → 19 tutorial!!

Login

Log in as bandit18 using the password you obtained from Level 17 → 18.

ssh bandit18@bandit.labs.overthewire.org -p 2220
# password: x2gLTTjFwMOhQ8oWNbMN362QKxfRqGlO

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

Task

Task placeholder

The password for the next level is stored in a file called readme in the home directory. Problem: Someone modified .bashrc to log you out immediately on SSH login.

A little bit of Theory

  • Interactive shells read ~/.bashrc and can be scripted to exit right away (you’ll see Byebye!).
  • You can bypass interactive login by asking SSH to run a command directly (non-interactive), e.g. cat readme.
  • Alternatives: scp/sftp to pull the file without opening an interactive shell.

Further reading:

Solution

  1. Observe the trap (optional)

    ssh bandit18@bandit.labs.overthewire.org -p 2220
    

    Why? You’ll be kicked out immediately due to .bashrc. That’s the point of the level.

    Byebye placeholder

  2. (Option A) Run a remote command with SSH (recommended)

    ssh -p 2220 bandit18@bandit.labs.overthewire.org 'cat readme'
    

    Why? This executes cat readme without launching an interactive shell, so .bashrc doesn’t log you out. If you prefer absolute paths:

    ssh -p 2220 bandit18@bandit.labs.overthewire.org 'cat /home/bandit18/readme'
    

    ssh-cat placeholder

  3. (Option B) Copy the file out with scp

    To stdout:

    scp -P 2220 bandit18@bandit.labs.overthewire.org:readme -
    

    To a local file:

    scp -P 2220 bandit18@bandit.labs.overthewire.org:readme ./bandit19.pass
    cat ./bandit19.pass
    

    scp placeholder

  4. (Option C) Use sftp

    sftp -P 2220 bandit18@bandit.labs.overthewire.org
    sftp> get readme -
    sftp> bye
    

    sftp placeholder

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

  6. Log into the next level (bandit19)

    ssh bandit19@bandit.labs.overthewire.org -p 2220
    # paste the password you just extracted
    

Password

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

cGWpMaKXVwDUNgPAVJbWYuGHVn9zl3j8

Troubleshooting

  • Still seeing Byebye!? → Ensure you used the remote command form (quotes matter): ssh -p 2220 bandit18@bandit.labs.overthewire.org 'cat readme'
  • Permission denied (publickey)? → You accidentally tried logging with a key instead of a password. Use the password from 17 → 18.
  • Weird characters/newlines → Re-run and copy only the line printed by cat readme.
  • Command not found → Use absolute path: '/bin/cat /home/bandit18/readme'.

Copy-paste quick run (one shot)

# Print the password without opening an interactive shell
ssh -p 2220 bandit18@bandit.labs.overthewire.org 'cat /home/bandit18/readme'

# Then log into the next level:
# ssh bandit19@bandit.labs.overthewire.org -p 2220
# (paste the printed line as the password)

Congrats 🎉 You bypassed the interactive shell trap and extracted the next password — welcome to bandit19!


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