Bandit9->10
Level Goal
The password for the next level is stored in the file data.txt in one of the few human-readable strings, preceded by several ‘=’ characters.
Commands useful to solve the level
Helpful Reading Material
Where to start?
As with the two previous levels, we are going to start by running file on our data.txt file.
Here is the output from this command :
bandit9@bandit:~$ file data.txt
data.txt: data
bandit9@bandit:~$
Part 1 : Printing human-readable strings
To safely print human-readable strings in non text files, we can use the strings command. We need to
figure out how to use this command to print the few human-readle strings in data.txt
Hint
Try to look in the strings(1) man page and
find out how to use the strings utility to achieve this goal
Solution
We can use the --all option to ensure that all the file is scanned
(this should be the default behavior but under certain implementations, the default behavior could
be different so this will prevent the exploitation of any
BFD library vulnerabilities).
Thus, the command we're looking for is strings --all data.txt, which will dump the human-readable
strings to stdout.
Now, we just need to grep the character '=' in this output and look for the password string.
Full Solution
Here is the full command :
strings --all data.txt | grep =
Bonus : Using the size of the password string
We know that the password string is a 33 characters long string, so we know that the line we're looking for is at least 33 characters long. We are going to find a way to display only the (at least) 33 characters long strings in data.txt.
Hint
Reading the strings(1) man page,
can you figure out an option to achieve this goal?
Solution
The option we're looking for is the -n option, we'll call it with -33 which means
that we're looking for at least 33 characters long strings.
Here is the full command :
strings --all -33 data.txt
You can now jump to the next level