Bandit Level 19
Bandit Level 19 — read a file even though .bashrc logs you out, by running a command remotely instead of opening a shell.
Source: This content is aggregated from overthewire (MIT). Visit the original repository for the latest version.
Level Goal
The password for the next level is stored in a file readme in the homedirectory. Unfortunately, someone has modified .bashrc to log you out when you log in with SSH.
Commands you may need to solve this level
ssh, ls, cat
Study guide
Level map: logged in as bandit18, find the password for bandit19.
What this level teaches
That an SSH login is not the only way to run something on a server, and what shell startup files do.
Key ideas
.bashrc. A script that bash reads when it starts, used to customise your shell. Whoever controls it controls what happens at login, and attackers abuse that for persistence.- Interactive vs command mode.
ssh user@hostopens an interactive shell, butssh user@host COMMANDruns one command and returns. - Read the argument description in
man sshto see how the command is passed.
How to approach it
- Try logging in normally and observe what the modified
.bashrcdoes. - Use the remote-command form of ssh to run
lsfirst, thencatthe file the Level Goal mentions.
Why it matters
Automation tools such as Ansible, deployment scripts and Git over SSH all run commands remotely this way.