Previous Level: Level 4
Login
SSH: ssh bandit4@bandit.labs.overthewire.org -p 2220
Password: pIwrPrtPN36QITSp3EQaw936yaFoFgAB
Task
The password for the next level is stored in the only human-readable file in the inhere directory.
A little bit of Theory
The file
command gives us the type of data of the file. Some examples would be: ‘ELF’, ‘Perl script’, ‘ASCII text’, ‘data’ and more.
For this task, we are looking specifically for human-readable files. It means that the data is presented so that we can read the information. An ELF file, for example, is not human-readable. If you would try to print its content (head <elf_file_name>
), the result would look something like this: �������$��$,0�%��0�'��0<u���8�w���9�t�
.
The most common data encodings that are human-readable are ASCII and Unicode.
If we want to apply/use a command on all the files in the current directory, repeating the command or writing all filenames is tedious.
To use the command on all the files in the directory without a lot of writing, we can use ‘*’, which is called a ‘wildcard symbol’. ‘*’ can stand for any number of any literal characters. An example could be file*
, which would match to everything that starts with ‘file’, like ‘file00’, ‘file’, ‘fileAA’ and so on.
It replaces the filename/path option in the command.
Solution
We again go into the ‘inhere’ directory and print out the files in the system:
|
|
We can see that there are ten files.
We can use different methods to find the human-readable file and therefore, the password.
- We could just print the contents of every file (
cat
). This is, however, not very efficient when we deal with more files. - Instead, we could use the method I mentioned in the theory part. The command structure is
file <filename>
. Instead of using a filename, we use a wildcard to get the type for all the files. Additionally, looking at the file names, specifically at the fact, the names start with ‘-’, gives us problems. Therefore we use the same method as in Level 2.
|
|
We can see that only ‘-file07’ is of type ‘ASCII text’, which is one of the encodings, that humans can read. (It is also the same file type as the files from previous levels.) Now we only need to print the file:
|
|
And get the next password.
https://overthewire.org/wargames/bandit/bandit5.html
Next Level: Level 6