tutorial · bandit

Bandit Level 26

Escape a non-bash shell (more/vi style) to get a real shell.
banditescapemorevi
Optional narration
Marks this level complete in your browser.

Goal

Logging into bandit26 is easy, but the shell isn’t /bin/bash.

Find what it is and break out into a real shell.

Hints

  • Check your login shell: cat /etc/passwd | grep bandit26.
  • Often the “shell” is something like more.
  • If you can open an editor/pager, you can often run shell commands from it.
Solution (click to reveal)
  1. SSH in:
ssh bandit26@bandit.labs.overthewire.org -p 2220
  1. Identify the shell:
grep '^bandit26:' /etc/passwd
  1. If it’s more, you can trigger a shell via v to open vi (works when output is paged). In vi, run:
:set shell=/bin/bash
:shell
  1. Once you have a shell, grab the password for bandit27 from the usual place:
cat /etc/bandit_pass/bandit27

Notes

  • This is a classic “escape the pager/editor” exercise.
  • On some terminals, you may need to resize so more actually activates.