OverTheWire - Bandit Walkthrough - Levels 10-19

OverTheWire’s wargames are offered to help learn and practice security concepts in the form of fun-filled games.
The Bandit wargame is aimed at absolute beginners and will teach them the basics needed to be able to play other wargames. All the challenges are focused on the Linux systems and their commands. It aims to get the player familiar with the Linux terminal and introduce some basic security concepts.
It consists of a total of 33 Levels. At each level, you have to find the password for the next level to continue playing. Each Level is a user that you connect as, using SSH in the bandit.labs.overthewire.org
server.
In this post, we will present the solutions for Levels 10-19 of the Bandit wargame.
- See the solutions for the previous Levels 0-9
- See the solutions for the next Levels 20-29
NOTE: These walkthroughs are written and published to help other members of the community that are stuck at some Level. It is strongly advised to first try the challenges yourself until you can progress no more, and only then come back here to see the solution.
Level 10
Level Goal
The password for the next level is stored in the file
data.txt
, which contains base64 encoded data
Solution
Log in to bandit10
, using the password found from Level 9:
We will use base64
in order to decode the file:
Level 11
Level Goal
The password for the next level is stored in the file
data.txt
, where all lowercase (a-z) and uppercase (A-Z) letters have been rotated by 13 positions.
Solution
Log in to bandit11
, using the password found from Level 10:
We will use the tr
utility to map upper case A-Z
to N-ZA-M
and lower case a-z
to n-za-m
, in order to have them rotated by 13 positions and we will feed the file as stdin
:
Level 12
Level Goal
The password for the next level is stored in the file
data.txt
, which is a hexdump of a file that has been repeatedly compressed.
Solution
Log in to bandit12
, using the password found from Level 11:
Working Directory
We first create a directory to work on, in /tmp
, copy data.txt
and change directory there:
Convert Hexdump back to Binary
Because the file is a hexdump we convert it back to the original binary with xxd
:
Check file tpe
We check each time what type of file it is.
gzip
If is a gzip
compressed file, we decompress it with:
bz2
If it is a bzip2
compressed file, we decompress it with:
tar
If it is a tar
archive, we untar it with:
Final ASCII File
After all decompressions cat
the ascii file:
Level 13
Level Goal
The password for the next level is stored in
/etc/bandit_pass/bandit14
and can only be read by userbandit14
. For this level, you don’t get the next password, but you get a private SSH key that can be used to log into the next level. Note: localhost is a hostname that refers to the machine you are working on
Solution
Log in to bandit13
, using the password found from Level 12:
We login to the current server as bandit14
using the SSH key:
Now we can view the password with cat
:
Level 14
Level Goal
The password for the next level can be retrieved by submitting the password of the current level to port
30000
on localhost.
Solution
Log in to bandit14
, using the password found from Level 13:
We connect to port 30000
on localhost using nc
and paste the password from the current level:
Level 15
Level Goal
The password for the next level can be retrieved by submitting the password of the current level to port
30001
on localhost using SSL encryption.
Solution
Log in to bandit15
, using the password found from Level 14:
We cannot use nc
now, because we use SSL encryption. To do that, we use the s_client
from openssl
in order to connect to port 30001
on localhost and paste the password from the current level:
Level 16
Level Goal
The credentials for the next level can be retrieved by submitting the password of the current level to a port on localhost in the range 31000 to 32000. First find out which of these ports have a server listening on them. Then find out which of those speak SSL and which don’t. There is only 1 server that will give the next credentials, the others will simply send back to you whatever you send to it.
Solution
Log in to bandit16
, using the password found from Level 15:
First, we scan all the ports from 31000 to 32000 with nmap
:
And we get the following results:
bandit16@bandit:~$ nmap -sT -p31000-32000 localhost
Starting Nmap 7.40 ( https://nmap.org ) at 2021-04-18 21:57 CEST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00027s latency).
Not shown: 996 closed ports
PORT STATE SERVICE
31046/tcp open unknown
31518/tcp open unknown
31691/tcp open unknown
31790/tcp open unknown
31960/tcp open unknown
Then try to connect to all of these services with openssl s_sclient
in order to check if they speak SSL:
After checking all of them, only these accept SSL connection:
31518
31790
After entering the current level’s password the correct service is the one on port 31790
:
Save the previous private key in a file in /tmp
directory:
Change the permissions so that it is not accessible by others:
We login to the current server as bandit17
using the SSH key:
Now we can view the password with cat
:
Level 17
Level Goal
There are 2 files in the homedirectory:
passwords.old
andpasswords.new
. The password for the next level is in passwords.new and is the only line that has been changed betweenpasswords.old
andpasswords.new
Solution
Log in to bandit17
, using the password found from Level 16:
We just diff
the two files:
- The line with
<
is from the first file (passwords.old
) - The line with
>
is from the second file (passwords.new
)
NOTE: if you have solved this level and see ‘Byebye!’ when trying to log into
bandit18
, this is related to the next level,bandit19
Level 18
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.
Solution
Log in to bandit18
, using the password found from Level 17:
If we try to SSH (either remotely or from localhost), we get:
But we don’t need to login, we can just run the cat
command on the readme
through ssh
:
Level 19
Level Goal
To gain access to the next level, you should use the setuid binary in the homedirectory. Execute it without arguments to find out how to use it. The password for this level can be found in the usual place (
/etc/bandit_pass
), after you have used the setuid binary.
Solution
Log in to bandit19
, using the password found from Level 18:
If we check at the binary permissions:
We can see it has the setuid bit set. This means that anyone who executes this binary, it executes it with bandit20
user’s privileges.
So we use the binary to cat the password on /etc/bandit_pass/bandit20
: