Bandit Level 12-13@overthewire.org
Description
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 using mkdir. For example: mkdir /tmp/myname123. Then copy the datafile using cp, and rename it using mv (read the manpages!).
Current level credentials
Key | Value |
---|---|
Server-name: | bandit.labs.overthewire.org |
Port: | 2220 |
User: | bandit12 |
Password: | JVNBBFSmZwKKOP0XbFXOoW8chDz5yVRv |
Current level login
Log in
1 |
|
sshpass
before using it. The ssh
command can also be used on its own. If so, copy-paste the password when requested.
Hints And Solution
Hint(s)
Research how to unzip gzip
and bzip2
compressed files.
To unzip gzip
compressed files, the file must have an extension that allows gzip
to recognize that it is compressed.
Research how to eXtract tar
archives.
Solution
This challenge resembles a Matryoshka (Russian doll). The file has been numerous times compressed and tar'ed, and we must figure out how to unzip
and untar
the file in order to obtain the password for the subsequent level (peel off the layers). Every time we create a new file, we must use the file
command to check what type of file it is in order to "peel off another layer of the puzzle".
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
We'll create new files by modifying the existing one. To achieve that, we must be in a location where we have write permission. The /tmp
directory must have a folder created in it, and we must utilize that directory as our working directory. We copy the initial file to the working directory.
Because the initial file is described as a hexdump
, we use xxd
to convert it back to a binary file.
1 2 3 4 5 6 7 8 9 10 11 |
|
The file
command is used to determine the file type of the new binary file, and the output indicates that it is a gzip
compressed file. We try to unzip the file with 'gunzip
, but it requires a file extension. To unzip the file, we could also use gzip-d
. So we rename the data.bin
file to data.gz
, and now we can unzip it. Also, for future reference, keep in mind that unzip
requires an extension to function.
1 2 3 4 5 6 7 8 9 10 |
|
To determine the file type, we use the file
command. It's compressed with bzip2
. We look up how to decompress gzip2
compressed data and use that information to unzip the file. Unlike with gunzip
, we do not need to rename the file to make it work with bunzip
.
1 2 3 4 5 6 7 8 9 |
|
The steps are the same. Determine the file format. If it's gzip
, rename the file; if it's bzip2
, you can leave it alone. ls
will show you the new file.
1 2 3 4 5 6 7 8 |
|
We have a tar
archive this time. The command changes, but the process stays the same. To untar
the file, we use tar -xf
. Unlike the zip-commands, a new file is created, but the original file is kept.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
Since it's a tar
archive again, we simply repeat the steps from before. Since there are now files that we don't use anymore, let's do some housekeeping and delete those unneeded files. Because this is another tar archive, we simply repeat the previous steps. Since there are now files that we no longer use, let's do some housekeeping and delete those files.
1 2 3 4 5 6 7 |
|
It's a compressed bzip2
file. We don't need to change the extension, so we just use the command gunzip
to unzip it.
1 2 3 4 5 6 7 |
|
It's a tar
archive. Repeat the steps to untar a tar
archive.
1 2 3 4 5 6 7 8 9 |
|
It's a gzip
compressed file. Repeat the steps to unzip a gzip
.
1 2 3 4 |
|
This time, we received a file with ASCII text
content, allowing us to output the file's contents.The output (with cat
) reveals the next level's password.
Resources
Resources
Bandit-level13@overthewire
xxd manpage @linux.die.net
bzip2 manpage @linux.die.net
gzip manpage @linux.die.net
tar manpage @linux.die.net
Hex dump on Wikipedia
Comments
Any feedback and suggestions are welcome. This website was created using mkdocs and the material plugin. If you want, you can make a pull request. The repository is https://github.com/dabonzo/itsec_hp