OverTheWire Bandit Guide

here's how to solve the bandit level 5 → 6

Back to the Bandit Guides

Previous Level Guide: Bandit Level 4 → 5


Access

SSH: ssh bandit5@bandit.labs.overthewire.org -p 2220

Password: S5OaPLeSSUs49foWliHtl0xbrqITe1gh

Info

Description: The password for the next level is stored in a file somewhere under the inhere directory and has all of the following properties: human-readable, 1033 bytes in size, not executable
Commands: ls, cd, cat, file, du, find

Theory

To get the password, the instructions say that the file is human readable, 1033 bytes, and it's not a data file, aka not executable. To do this we will use the find command followed by a point (.), which will make the command scan through all files and folders for the next instructions, which is the type, which will be f so that it only shows files, not folders, then the size, for that we will use 1033c, the c meaning bytes, there are others like b for blocks and k,M,G for kibibytes,mebibytes,gibibytes respectively. Then use ! -executable where the exclamation point means that all the instructions from that point are going to be inverse, for example -executable will find executable files, but if you put ! or also called "not", like ! -executable, it will be like telling the server not executable. And that should be enough, if there's more than one file found, we'll just check it for human readability later. Following all of this, we get a command like this:

find . -type f -size 1033c ! -executable

Solution

Now you just have to get into the level and go to the inhere folder:

~$ ls
inhere

~$ cd inhere

~/inhere$ ls

~/inhere$ ls -a
.            maybehere01  maybehere04  maybehere07  maybehere10  maybehere13  maybehere16  maybehere19
..           maybehere02  maybehere05  maybehere08  maybehere11  maybehere14  maybehere17
maybehere00  maybehere03  maybehere06  maybehere09  maybehere12  maybehere15  maybehere18

Now that we are in this folder we can see that there are 20 different folders that, after further exploration, you can see that each folder has 9 files each. That info really doesn't matter, so let's just get to the chase, le's input the command we did earlier:

~/inhere$ find . -type f -size 1033c ! -executable
./maybehere07/.file2

And it works! But here's a little fun fact if you are still reading this, a little after doing this, I found out you don't even need the not executable thing, because it's the only 1033 byte file in the entire server, also folders don't take up space virtually (it does take up space in the disk, but it usually doesn't show that to the client), so you can also remove the type f thing. So if you want to do this level more efficiently, you can shrink the command to this:

~/inhere$ find . -size 1033c
./maybehere07/.file2

Now we just use cat to open print the contents of the file at ./maybehere07/.file2, and we should be good to go to the next level:

~/inhere$ cat ./maybehere07/.file2
HYZcza5TcvBLoUE7kbfBQWgnzlqbOKrh
https://overthewire.org/wargames/bandit/bandit6.html
Next Level Guide: Bandit Level 6 → Level 7