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
lscommand first, and then I found thedata.txtfile which contained base64 encoded data.
So I decoded it using thebase64command with the-doption, which stands for decode.
After I addeddata.txt, I pressed theEnterkey. 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
lsto check the files in the current directory and I found thedata.txtfile.
I tried to read it usingcat, but the contents were unreadable. To understand it, I needed to decode the letters.
So I used thetrcommand 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.txtfile using thelscommand. After that, I made thesank12directory in thetempdirectory to solve this game more easier.
Then I copied thedata.txtfile using thecpcommand into thesank12directory.
I moved into thesank12directory using thecdcommand, and then I typedlsto find thedata.txtfile.
Next, I entered thexxdcommand with the-roption to decode thedata.txtfile. But it was unreadable.
So I added the>symbol and a new file name -- in this case,bandit12to save the result.
I checked the files in the current directory usingls. Thebandit12file apeared.
I needed to know what thebandit12file type is. So I used thefilecommand 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 thebanditfile to thebandit.gzfile.
Then I decoded thebandit.gzfile using thegunzipcommand. After that, I enteredlsagain and I found thebanditfile.
I used thefilecommand again, so I could catch that thebandit12file was compressed bybzip2.
I changed thebandit12file tobandit12.bz2, and I decoded it using thebzip2command with the-doption.
And then, I entered thelscommand again. I found thebandit12file, so I used thefilecommand again to know what the bandit12file type is.gunzip
It was gzip, so I decoded it using thecommand. And then, thebandit12file apeared.bandit12
I checked the type of thefile using thefilecommand. It was thetar.mv bandit12 bandit12.tar
I entered, and then I typedtar -xf bandit12.tarto decode thebandit12file.ls
After that, I enteredto check the files in the current directory. And I found thedata5.binfile.file
I used thecommand, so I knew the typed of thedata5.bin` file was tar.
I entered
mv data5.bin data5.tar. Then I typedtar -xf data5.tar. After that I used thelscommand.
I found thedata6.binfile. I used thefilecommand 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 thelscommand.
I found thedata8.binfile. When I checked it using thefilecommand, it wasgzip.
So I changed the file name todata8gz, and then I tried to decode it using thegunzipcommand.
As a result, thedata8file apeared. It was theASCII textfile.
So I used thecatcommand 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
idcommand to check my current user ID. It'sbandit13.
So it was clear that I could not read thebandit14file.##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
idcommand to check my current user ID which wasbandit13.
So it was clear that I could not read thebandit14file directly.
I used thelscommand to check the files in the current directory and found thesshkey.privatefile.
Next, I used themancommand withsshto find an option that aloows using a private key.
I found that the-ioption let me specify the identity file for public key authentication.
So I entered thesshcommand with the-i sshkey.privateoption.
Then, I addedbandit14@locahost -p 2220that 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/bandit14to find the current password.
After I found the password, I used thenccommand. Thenccommand stands fornetcat, which is short fornetworkand thecatcommand.
Then I add the localhost IP address(127.0.0.1) and port number(30000), and I pressed theEnterkey.
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/bandit15to find the current level's password.
Next, I ran theopensslcommand with thes_clientsubcommand(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_clientsubcommand helps you connect directly to an SSL/TLS serever.
Then I added the-connectoption with the addresslocalhost:30001 and pressedEnter`.
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/bandit16to find the password for the current level.
Next, I entered thenccommand with the-r -w 1 -zoption.
The-roption 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 1option sets limits the connection attimpt timeout to 1 second. This option helps you speed up scans and avoid hanging on unresponsive ports.
The-zoption 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 31046first 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_eofoption, 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 askey16inside the/tmp/sank16directory.
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
key16file were too open.
I checked the file permissions usingls -l key16and 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
lsto check the files in the current directory, and I found two files:passwords.newandpassword.old.
I used thediffcommand 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."
.bashrcis a user-level script that runs automatically when abash shellis 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 ashshell instead ofbash.
I succefully logged into level 18, then I used thelscommand and found thereadmefile.
Finally I rancat readmeand 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
lsto check the files in the current directory.
I found thebandit20-dofile 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/bandit20and 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)