Learn linux command by playing Bandit wargame. The Bandit wargame is aimed at absolute beginners. It will teach the basics needed to be able to play other wargames. Below is the solution of Level 12 → Level 13.
In this post we will learn about various compression techniques and
how to decompress file. We will learn how to convert binary to hex file
and vice-versa.
how to decompress file. We will learn how to convert binary to hex file
and vice-versa.
Previous Post
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 using mkdir. For example: mkdir /tmp/myname123. Then copy the datafile using cp, and rename it using mv (read the manpages!)
Commands you may need to solve this level
grep, sort, uniq, strings, base64, tr, tar, gzip, bzip2, xxd, mkdir, cp, mv, file
Solution :
Command to connect remote host :
ssh [email protected] -p 2220 password is 5Te8Y4drgCRfCx8ugdwuEX8KFC6k2EUuAs mentioned in question make a new directory in /tmp and rename the file.
xxd program is used to make a hexdump or to do the reverse. Option -r convert hexdump into the binary. File myfile.txt is a hexdump and convert it into a binary file myfile1.bin using commandxxd -r myfile.txt > myfile1.binUsing command
file myfile1.bin , we found that myfile1.bin is a gzip compressed data.zcat is a program supplied with gzip and is used to decompress gzip compressed files.zcat myfile1.bin > myfile2Again using
file command on myfile2, we found that it is bzip2 compressed data.bzcat program is supplied with bzip2 and is used to decompress bzip2 compressed files.bzcat myfile2 > myfile3myfile3 is gzip compressed file so use zcat program to decompress it in myfile4. myfile4 is a POSIX tar archive.tar program is used for archiving file and options x is used to extract an archive, f is used to specify name of the tar archive and v is used for more detailed listing.tar -xvf myfile4This command outputs file
data5.bin which is again a tar archive. Again use tar program on data5.bin which outputs data6.bin. data6.bin is a bzip2 compressed file and use bzcat program to decompress it to myfile7.myfile7 is a tar archive and use tar program which outputs data8.bin. data8.bin is a gzip compressed file and use zcat to decompress it to file myfile9.myfile9 contains ASCII text and cat myfile9 tells the password for the next level.The password for the next level is
8ZjyCRiBWFYkneahHwxCv3wb2a1ORpYL .
Next Post
Bandit Level 13 to Level 15
Bandit Level 16 to Level 18
Bandit Level 19 to Level 20
Bandit Level 21 to Level 22
Bandit Level 23 → Level 24
Bandit Level 24 → Level 25
Bandit Level 25 to Level 26
Bandit Level 27 to Level 31
Bandit Level 32 → Level 33
Bandit Level 16 to Level 18
Bandit Level 19 to Level 20
Bandit Level 21 to Level 22
Bandit Level 23 → Level 24
Bandit Level 24 → Level 25
Bandit Level 25 to Level 26
Bandit Level 27 to Level 31
Bandit Level 32 → Level 33
Originally posted at Programmercave
.