OverTheWire Bandit Wargame Level 10–20: My Step-by-Step Solutions
This is the second review about Over the wire : Bandit wargames.
While I studying python3, I explored various area of IT and became interested in cybersecurity.
Then I found the Bandit wargames and totally got hooked.
Starting today, I'll write down how I cleared each level of the wargames. This will be a way for me to improve both computer skills and English writing skills.
Please let me know if I use any awkward expressions or provide incorrect information.
If you need more details about Bandit wargames, please check this link : http://www.overthewire.org/wargames
11. Bandit Level 10 → Level 11
Level Goal
The password for the next level is stored in the file data.txt, which contains base64 encoded data
Commands you may need to solve this level
grep, sort, uniq, strings, base64, tr, tar, gzip, bzip2, xxd
Helpful Reading Material
Base64 on Wikipedia
How I soved it
I entered the
ls
command first, and then I found thedata.txt
file which contained base64 encoded data.
So I decoded it using thebase64
command with the-d
option, which stands for decode.
After I addeddata.txt
, I pressed theEnter
key. Then the password popped up, so I logged into level 11.
12. Bandit Level 11 → Level 12
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
Commands you may need to solve this level
grep, sort, uniq, strings, base64, tr, tar, gzip, bzip2, xxd
Helpful Reading Material
Rot13 on Wikipedia
How I soved it
I started by entering
ls
to check the files in the current directory and I found thedata.txt
file.
I tried to read it usingcat
, but the contents were unreadable. To understand it, I needed to decode the letters.
So I used thetr
command which helps translate or delete characters.
I used the arguments'[A-Za-z]'
and'[N-ZA-Mn-za-m]'
to define the ROT13 transformation, conbined with the '|' symbol to pipe the contets formcat
.
As a result, I found the password for the next level.
13. Bandit Level 12 → Level 13
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. For this level it may be useful to create a directory under /tmp in which you can work. Use mkdir with a hard to guess directory name. Or better, use the command “mktemp -d”. Then copy the datafile using cp, and rename it using mv (read the manpages!)
Commands you may need to solve this level
grep, sort, uniq, strings, base64, tr, tar, gzip, bzip2, xxd, mkdir, cp, mv, file
Helpful Reading Material
Hex dump on Wikipedia
How I soved it
I found the
data.txt
file using thels
command. After that, I made thesank12
directory in thetemp
directory to solve this game more easier.
Then I copied thedata.txt
file using thecp
command into thesank12
directory.
I moved into thesank12
directory using thecd
command, and then I typedls
to find thedata.txt
file.
Next, I entered thexxd
command with the-r
option to decode thedata.txt
file. But it was unreadable.
So I added the>
symbol and a new file name -- in this case,bandit12
to save the result.
I checked the files in the current directory usingls
. Thebandit12
file apeared.
I needed to know what thebandit12
file type is. So I used thefile
command to check and then I knew it wasgzip
.
Before I decoded it, I had to change the file extension to
gz
. So I enteredmv bandit12 bandit12.gz
, which means "I want to move thebandit
file to thebandit.gz
file.
Then I decoded thebandit.gz
file using thegunzip
command. After that, I enteredls
again and I found thebandit
file.
I used thefile
command again, so I could catch that thebandit12
file was compressed bybzip2
.
I changed thebandit12
file tobandit12.bz2
, and I decoded it using thebzip2
command with the-d
option.
And then, I entered thels
command again. I found thebandit12
file, so I used thefile
command again to know what the bandit12file type is.
gunzip
It was gzip, so I decoded it using thecommand. And then, the
bandit12file apeared.
bandit12
I checked the type of thefile using the
filecommand. It was the
tar.
mv bandit12 bandit12.tar
I entered, and then I typed
tar -xf bandit12.tarto decode the
bandit12file.
ls
After that, I enteredto check the files in the current directory. And I found the
data5.binfile.
file
I used thecommand, so I knew the typed of the
data5.bin` file was tar.
I entered
mv data5.bin data5.tar
. Then I typedtar -xf data5.tar
. After that I used thels
command.
I found thedata6.bin
file. I used thefile
command to check the type of the file and then I knew it wastar
.
I enteredmv data6.bin data5.tar
. Then I typedtar -xf data6.tar
. After that I used thels
command.
I found thedata8.bin
file. When I checked it using thefile
command, it wasgzip
.
So I changed the file name todata8gz
, and then I tried to decode it using thegunzip
command.
As a result, thedata8
file apeared. It was theASCII text
file.
So I used thecat
command to read the file and finally I found the password for the next level.
14. Bandit Level 13 → Level 14
Level Goal
The password for the next level is stored in /etc/bandit_pass/bandit14 and can only be read by user bandit14. 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
Commands you may need to solve this level
ssh, telnet, nc, openssl, s_client, nmap
Helpful Reading Material
SSH/OpenSSH/Keys
How I solved it
First of all, I entered the
id
command to check my current user ID. It'sbandit13
.
So it was clear that I could not read thebandit14
file.##13. Bandit Level 13 → Level 14
Level Goal
The password for the next level is stored in /etc/bandit_pass/bandit14 and can only be read by user bandit14. 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
Commands you may need to solve this level
ssh, telnet, nc, openssl, s_client, nmap
Helpful Reading Material
SSH/OpenSSH/Keys
How I solved it
First of all, I entered the
id
command to check my current user ID which wasbandit13
.
So it was clear that I could not read thebandit14
file directly.
I used thels
command to check the files in the current directory and found thesshkey.private
file.
Next, I used theman
command withssh
to find an option that aloows using a private key.
I found that the-i
option let me specify the identity file for public key authentication.
So I entered thessh
command with the-i sshkey.private
option.
Then, I addedbandit14@locahost -p 2220
that the address which I wanted to logged in.
The bandit system asked me to continue, and I enteredyes
. Finally I logged intobandit14
.
**15. Bandit Level 14 → Level 15
Level Goal
The password for the next level can be retrieved by submitting the password of the current level to port 30000 on localhost.
Commands you may need to solve this level
ssh, telnet, nc, openssl, s_client, nmap
Helpful Reading Material
How the Internet works in 5 minutes (YouTube) (Not completely accurate, but good enough for beginners)
IP Addresses
IP Address on Wikipedia
Localhost on Wikipedia
Ports
Port (computer networking) on Wikipedia
How I solved it
I started by entering
cat /etc/bandit_pass/bandit14
to find the current password.
After I found the password, I used thenc
command. Thenc
command stands fornetcat
, which is short fornetwork
and thecat
command.
Then I add the localhost IP address(127.0.0.1) and port number(30000), and I pressed theEnter
key.
Then I entered the current level password. As a result, I got the password for the next level.
16. Bandit Level 15 → Level 16
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/TLS encryption.
Helpful note: Getting “DONE”, “RENEGOTIATING” or “KEYUPDATE”? Read the “CONNECTED COMMANDS” section in the manpage.
Commands you may need to solve this level
ssh, telnet, nc, ncat, socat, openssl, s_client, nmap, netstat, ss
Helpful Reading Material
Secure Socket Layer/Transport Layer Security on Wikipedia
OpenSSL Cookbook - Testing with OpenSSL
How I solved it
First of all, I entered
cat /etc/bandit_pass/bandit15
to find the current level's password.
Next, I ran theopenssl
command with thes_client
subcommand(I made many mistakes here at first---I kept using-s_client
, but you should not use the dash. It's a subcommand, not an option.)
Thes_client
subcommand helps you connect directly to an SSL/TLS serever.
Then I added the-connect
option with the addresslocalhost:30001 and pressed
Enter`.
Once connected, I pasted the current level's password. As a result, I got the password for the next level.
17. Bandit Level 16 → Level 17
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/TLS 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.
Helpful note: Getting “DONE”, “RENEGOTIATING” or “KEYUPDATE”? Read the “CONNECTED COMMANDS” section in the manpage.
Commands you may need to solve this level
ssh, telnet, nc, ncat, socat, openssl, s_client, nmap, netstat, ss
Helpful Reading Material
Port scanner on Wikipedia
How I solved it
I started by entering
cat /etc/bandit_pass/bandit16
to find the password for the current level.
Next, I entered thenc
command with the-r -w 1 -z
option.
The-r
option makes to scan ports in a random order instead of sequentially. It helps you avoid detection by intrusion detection systems(IDS) by making scan patterns unpredictable.
The-w 1
option sets limits the connection attimpt timeout to 1 second. This option helps you speed up scans and avoid hanging on unresponsive ports.
The-z
option means to check connection without sending or receicing any data. If you want to check only the ports are opened or not, this option will be help.
As a result, I found five opended ports, so I tried to find out which of those speak SSL/TLS one by one.
I tried
port 31046
first by usingopenssl s_client -connect localhost:31046
, but it didn't support SSL/TLS.
So I moved on to the next one: I entered
openssl s_client -connect localhost:31790
, and it worked!
Once connected, I pasted the current level's password. However, it only reurned a single message---KEYUPDATE
, and nothing else.
That felt suspicious because the wargame description stated: "There is only 1 server that will give the next credentials, the others will simply send back to you whatever you send to it."
So I retried the same command, but dhis time I added the-ign_eof
option, which allows you to keep reading input even after the server disconnects.
I ran the command again and pasted the current level's password. This time, the server responded with an RSA private key.
I saved the key askey16
inside the/tmp/sank16
directory.
Then I tried to log in to the next level using the command:ssh -i key16 bandit17@localhost -p 2220
.
But I was denied., because permissions on the
key16
file were too open.
I checked the file permissions usingls -l key16
and then fixed it withchmod 700 key16
.
After that, I retried the SSH login---and it worked!
18. Bandit Level 17 → Level 18
Level Goal
There are 2 files in the homedirectory: passwords.old and passwords.new. The password for the next level is in passwords.new and is the only line that has been changed between passwords.old and 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
Commands you may need to solve this level
cat, grep, ls, diff
How I solved it
I started by entering
ls
to check the files in the current directory, and I found two files:passwords.new
andpassword.old
.
I used thediff
command to check the difference with those two files. I entereddiff passwords.new passwords.old
.
As a result, I found the password for the next level. So I logged into level 18.
19. Bandit Level 18 → Level 19
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
How I solved it
The wargame discripion stated: "Someone has modified .bashrc to log you out when you log in with SSH."
.bashrc
is a user-level script that runs automatically when abash shell
is started, so I needed to bypass or avoid it.
To do that, I enteredssh bandit18@bandit.labs.overthewire.org -p 2220 /bin/sh
, which starts ash
shell instead ofbash
.
I succefully logged into level 18, then I used thels
command and found thereadme
file.
Finally I rancat readme
and got the password for the next level.
20. Bandit Level 19 → Level 20
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.
Helpful Reading Material
setuid on Wikipedia
How I solved it
I started by entering
ls
to check the files in the current directory.
I found thebandit20-do
file and executed it to see how to use it.
The file allows me to run a command as another user---in this case, bandit20.
So I ran./bandit20-do cat etc/bandit_pass/bandit20
and got the passoword for level 20.
I’m continuing with higher levels, and I’ll post my solutions step by step.
If you find this helpful or want to follow along, feel free to leave a comment!
Top comments (0)