Bandit level 12
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!)
This level will take us on a journey trying to come to the last part of a Matryoshka doll. With the file being repeatedly compressed it will be layers upon layers of compression and data obfuscation. Firstly the file have been converted to a hexdump and we need to undo that, Then we need to figure out what type of compression is used and how to extract it.
Useful commands:
- mkdir
- mktemp -d
- cd
- cp
- mv
- xxd
- gzip
- gunzip
- tar
Solution - Spoiler Alert!
First we need to create a new temporary directory because we do not have writing permissions in the directory we are currently in. With the command mktemp -d
we will create a temporary directory with a random name. Then we need to cp
the file over there, and cd
our self over there. In our new working directory we can use the xxd -r
command to revert a hex dump, and we get an compressed archive of some sort.
Using the file
command we can get information about the file. And the file formats we will need to handle in this level is 'gzip', 'bzip2' and 'POSIX tar archive'
Gzip, when we need to handle gzip files we first need to rename the the file so it have the '.gz' extension. Gzip will not decompress files without the extension. So first use the mv
command to rename the file, then use the gzip -d
command on the file.
Bzip2, when handling bzip2 files we simply need to use one of the following commands bunzip2
or bzip2 -d
. If bzip2 can not guess the original file name it will use the compressed files name and add '.out' extension to it
POSIX tar archive, if the file is a tar archive we need to use the tar
command to decompress it. And similar to bzip2 we do not need to rename the file, just run the command. We need 2 options, but will use 3 options to the tar
command. Running tar xfv
on the file will Xtract the File and have a Verbose output.
To solve this level we need to cycle through these commands until we are left with a file with the properties of ASCII text, and then cat
that file.
Comments ()