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

OverTheWire Bandit Level 2 → 3 tutorial!!

Login

Log in as bandit2 using the password you just obtained from Level 1 → 2.

ssh bandit2@bandit.labs.overthewire.org -p 2220
# password: 263JGJPfgU6LtdEvgfWU1XP5yac29mFx

Why? Each Bandit level is a separate UNIX user. To solve 2 → 3, you must be the bandit2 user.

Task

Task

The password for the next level is stored in a file named –spaces in this filename– located in the home directory of bandit2.

A little bit of Theory

  • Filenames with spaces must be quoted or escaped so the shell treats them as a single argument.
  • Filenames beginning with - can be interpreted as options. Safe ways to reference them:

    • Prefix with a path:

      cat "./--spaces in this filename--"
      
    • Use the option terminator:

      cat -- "--spaces in this filename--"
      
    • Escape spaces (and still add ./ so the leading dashes aren’t parsed as options):

      cat ./--spaces\ in\ this\ filename--
      
  • Tab completion helps avoid typos: type cat ./--spa<Tab> and let the shell complete the filename.
  • ls -la shows file details to confirm you’re in the right place.

Further reading:

Solution

  1. Confirm your location

    pwd
    

    Why? Should print /home/bandit2; that’s where the target file lives.

  2. List files to see the target

    ls -la
    

    Why? Verifies the file –spaces in this filename– exists and shows its permissions.

  3. Read the file safely

    cat "./--spaces in this filename--"
    # or
    cat -- "--spaces in this filename--"
    # or
    cat ./--spaces\ in\ this\ filename--
    

    Why? Quoting/escaping and/or prefixing with a path prevents the leading dashes from being treated as options.

cat

  1. Copy the password (no extra spaces/newlines).

  2. Log into the next level (bandit3)

    exit
    ssh bandit3@bandit.labs.overthewire.org -p 2220
    # paste the password you just found when prompted
    

Password

This is the password shown in my run; if yours differs, copy the one from your own terminal output.

MNk8KNH3Usiio41PRUEoDFPqfxLPlSmx

Troubleshooting

  • No such file or directory → Include the leading/trailing -- and quote/escape spaces; try Tab completion.
  • cat: invalid option → Use cat -- "--filename" or add ./ before the name.
  • Permission denied → Ensure you are logged in as bandit2.

Congrats 🎉 You handled filenames with spaces and can now play as bandit3.


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