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

OverTheWire Bandit Level 25 → 26 tutorial!!

Login

Log in as bandit25 using the password you obtained from Level 24 → 25.

ssh bandit25@bandit.labs.overthewire.org -p 2220
# password: iCi86ttT4KSNe1armKiwbQNmB3YJP3q4

Why? Each Bandit level is a separate UNIX user. To solve 25 → 26, you must be the bandit25 user.

Task

Task placeholder

The home directory contains a private SSH key for bandit26. However, the login shell of bandit26 is set to /usr/bin/showtext, which only runs the pager more on a file and then exits. Your job is to figure out how to break out of this restricted environment and obtain the password for bandit26.

A little bit of Theory

  • Shell override: instead of /bin/bash, bandit26’s shell is /usr/bin/showtext.
  • The script /usr/bin/showtext simply executes more ~/text.txt.
  • Pager trick: when more is interactive (--More--), you can press v to launch vim.
  • From vim, you can spawn a real shell with :!bash.

Further reading:

Solution

  1. Inspect the home directory

    ls -la
    

    Why? Confirms the presence of the bandit26.sshkey file needed to connect.

    ls placeholder

  2. Check the shell of bandit26

    grep '^bandit26:' /etc/passwd
    

    Output shows:

    bandit26:x:11026:11026:bandit level 26:/home/bandit26:/usr/bin/showtext
    

    Why? Confirms that bandit26 does not use /bin/bash but /usr/bin/showtext.

    passwd placeholder

  3. Inspect the showtext script

    cat /usr/bin/showtext
    

    It runs:

    #!/bin/sh
    export TERM=linux
    exec more ~/text.txt
    exit 0
    

    Why? Shows that bandit26 will always be dropped into more text.txt.

    showtext placeholder

  4. Login as bandit26 with the SSH key

    ssh -i bandit26.sshkey -p 2220 bandit26@localhost
    

    Why? Connects using the provided private key instead of a password.

    If your terminal is tall, more prints the whole file and exits immediately. → Fix: resize your terminal to ~10 lines tall so more shows --More--.

    ssh placeholder

  5. Escape into vim, then bash

    • Inside more, press v → this opens vim.
    • In vim, type:

       :set shell=/bin/bash
       :shell
      

    Why? This spawns a new shell, giving you full access as bandit26.

    vim escape placeholder

  6. Read the password

    cat /etc/bandit_pass/bandit26
    

    Output:

    s0773xxkk0MXfdqOfPRVr9L3jJBUOgCZ
    

    Why? Prints the password for the next level.

    password placeholder

Password

This is the password I got; copy yours from your own run.

s0773xxkk0MXfdqOfPRVr9L3jJBUOgCZ

Troubleshooting

  • Immediately disconnected? → Shrink your terminal window so more pauses with --More--.
  • Can’t escape? → Be sure you’re inside more. Press v to open vim, then :!bash.
  • Permission errors on ssh key → Ignore; key is already properly restricted.

Congrats 🎉 You successfully escaped a restricted shell using more → vim → bash and obtained the credentials for bandit26!


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