OverTheWire Bandit Level 20->Level 21 - Walkthrough

Cybersecurity OverTheWire Bandit Solutions
OverTheWire Bandit Solutions


Introduction

In this post, I will be giving you a walkthrough to the Bandit wargame Level 20->Level 21. We will be using the command "nc" introduced in Level 15 walkthrough to create a listening server on localhost and then pass the password to it.

Goal

There is a setuid binary in the home directory that does the following: it makes a connection to localhost on the port you specify as a command line argument. It then reads a line of text from the connection and compares it to the password in the previous level (bandit20). If the password is correct, it will transmit the password for the next level (bandit21).

Login Details

Server - bandit.labs.overthewire.org
Port - 2220
Username - bandit20
Password - VxCazJaVykI6W36BkBU0mJTCM8rR95XT

Theory

We will use the netcat "nc" command to create a server on localhost and use the option "-l" to tell netcat to listen on the specified port. We can login to the user bandit20 on two separate terminals, make one as a listener and then pass the password from the other terminal to the netcat listener. "-p" option is used to specify the port number on which netcat will listen to the message.

The netcat server created in this level is a one time server and it automatically disconnects after that.

Solution

Open two terminals and SSH into the user bandit20 using the command "ssh bandit20@bandit.labs.overthewire.org -p 2220" and the above password on both the terminals. Type the command "nc -l -p 1258" on one of the terminals(right terminal in this case, use any port number that is not in use). On the other terminal(left terminal), type "./suconnect" to know the usage of the binary file.

Now type the command "./suconnect 1258" on the left terminal and paste the password for bandit20 on the right terminal. The password will be verified and the next level password will be visible on the right terminal.

This completes the Level 21 walkthrough as we got the password. Please explore more on different ways to clear this level for better understanding of various commands.

Please post your doubts and questions in the comment section.

Comments

Popular Posts