Wargame: Bandit
Level: 18
Category: Linux Fundamentals
Description
.bashrc has been modified to run exit immediately, so interactive SSH sessions terminate right away. The password is in readme in the home directory.
Overview
- SSH allows passing a command directly:
ssh user@host commandruns the command without starting an interactive shell. - This bypasses
.bashrcbecause the login shell is not interactive. - Alternatively,
ssh -tforces a pseudo-TTY, orssh -Tsuppresses the PTY entirely.
Solution
connect = pwn.ssh(host=hostname, user="bandit18", password=password, port=2220)
channel = connect.system("cat readme")
result = channel.recv().decode().strip()
Password
awhqfNnAbc1naukrpqDYcF95h7HoMTrC