[Bandit-OverTheWire] Level 12 -> Level 13

두비니

·

2020. 9. 21. 10:13

 

Bandit Level 12 → Level 13

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

Helpful Reading Material

 

접속

접속 : ssh bandit12@bandit.labs.overthewire.org -p2220
pw : 5Te8Y4drgCRfCx8ugdwuEX8KFC6k2EUu

 

 

계속해서 압축된 파일의 hexdump라고합니다. 그러면 xxd로 hexdump를 다시 되돌려놓고, 압축했다니깐 압축을 풀어주도록 하겠습니다.

 

+) hexdump란? 쉽게 말해서 파일을 싹다 16진수들로 표현하여 모아놓은 것입니다. 쉽게말해 hxD 에서 파일 집어넣으면 보이는 형식을 hexdump라고 합니다.

++) xxd란? 이런 hexdump를 만들거나 되돌리는 기능을 가진 명령어입니다.

참고 : twpower.github.io/122-xxd-command-usage

 

[Linux] 파일을 16진수로 보여주는 xxd 명령어의 사용법과 예제

Practice makes perfect!

twpower.github.io

 

bandit12@bandit:~$ xxd -r data.txt data
xxd: data: Permission denied

 

bandit12@bandit:~$ mkdir /tmp/dubini0
bandit12@bandit:~$ cp data.txt /tmp/dubini0
bandit12@bandit:~$ cd /tmp/dub
-bash: cd: /tmp/dub: No such file or directory
bandit12@bandit:~$ cd /tmp/dubini0
bandit12@bandit:/tmp/dubini0$ ls
data.txt
bandit12@bandit:/tmp/dubini0$ xxd -r data.txt data
bandit12@bandit:/tmp/dubini0$ ls
data  data.txt

 

data를 확인해봅시다.

bandit12@bandit:/tmp/dubini0$ file data
data: gzip compressed data, was "data2.bin", last modified: Thu May  7 18:14:30 2020, max compression, from Unix

 

gzip 압축 데이터네요.

.gz파일은 gzip명령어로 압축해제합니다. 참고 : ifuwanna.tistory.com/31

 

[Linux 리눅스] 압축, 해제 ( tar / gzip gz / bzip bz2 )

※ Linux 리눅스 압축, 해제 ( tar / gzip gz / bzip2 bz2 ) - 윈도우즈(Windows) 에서의 압축은 zip 등의 방식으로 파일이나 폴더들을 묶음과 동시에 압축(compress) 하는 것을 의미하나 리눅스(Linux)에..

ifuwanna.tistory.com

 

bandit12@bandit:/tmp/dubini0$ mv data data.gz
bandit12@bandit:/tmp/dubini0$ gzip -d data.gz
bandit12@bandit:/tmp/dubini0$ ls
data  data.txt
bandit12@bandit:/tmp/dubini0$ file data
data: bzip2 compressed data, block size = 900k

풀었더니 bzip2 파일이 있네요.

또 풀어줍시다.

 

bandit12@bandit:/tmp/dubini0$ bzip2 -d data.bz2
bandit12@bandit:/tmp/dubini0$ ls
data  data.txt
bandit12@bandit:/tmp/dubini0$ file data
data: gzip compressed data, was "data4.bin", last modified: Thu May  7 18:14:30 2020, max compression, from Unix

 

이런식으로 쭉 반복되서 코드만 올립니다.

 

bandit12@bandit:/tmp/dubini0$ tar -xjvf data.bz2
bandit12@bandit:/tmp/dubini0$ ls
data.bz2  data.txt
bandit12@bandit:/tmp/dubini0$ file data.bz2
data.bz2: bzip2 compressed data, block size = 900k
bandit12@bandit:/tmp/dubini0$ bzip2 -d data.bz2
bandit12@bandit:/tmp/dubini0$ ls
data  data.txt
bandit12@bandit:/tmp/dubini0$ file data
data: gzip compressed data, was "data4.bin", last modified: Thu May  7 18:14:30 2020, max compression, from Unix
bandit12@bandit:/tmp/dubini0$ mv data data.gz
bandit12@bandit:/tmp/dubini0$ gzip -d data.gz
bandit12@bandit:/tmp/dubini0$ file data
data: POSIX tar archive (GNU)
bandit12@bandit:/tmp/dubini0$ tar -xvf data.tar
tar: data.tar: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
bandit12@bandit:/tmp/dubini0$ mv data data.tar
bandit12@bandit:/tmp/dubini0$ tar -xvf data.tar
data5.bin
bandit12@bandit:/tmp/dubini0$ file data5.bin
data5.bin: POSIX tar archive (GNU)
bandit12@bandit:/tmp/dubini0$ mv data5.bin data5.tar
bandit12@bandit:/tmp/dubini0$ tar -xvf data5.tar
data6.bin
bandit12@bandit:/tmp/dubini0$ file data6.bin 
data6.bin: bzip2 compressed data, block size = 900k
bandit12@bandit:/tmp/dubini0$ mv data6.bin data6.bz2
bandit12@bandit:/tmp/dubini0$ bzip2 -d data6.bz2
bandit12@bandit:/tmp/dubini0$ file data
data: cannot open `data' (No such file or directory)
bandit12@bandit:/tmp/dubini0$ ls
data5.tar  data6  data.tar  data.txt
bandit12@bandit:/tmp/dubini0$ file data6
data6: POSIX tar archive (GNU)
bandit12@bandit:/tmp/dubini0$ mv data6 data6.tar
bandit12@bandit:/tmp/dubini0$ tar -xvf data6.tar
data8.bin
bandit12@bandit:/tmp/dubini0$ file data8.bin
data8.bin: gzip compressed data, was "data9.bin", last modified: Thu May  7 18:14:30 2020, max compression, from Unix
bandit12@bandit:/tmp/dubini0$ mv data8.bin data8.gz
bandit12@bandit:/tmp/dubini0$ gzip -d data8.gz
bandit12@bandit:/tmp/dubini0$ ls
data5.tar  data6.tar  data8  data.tar  data.txt
bandit12@bandit:/tmp/dubini0$ file data8
data8: ASCII text
bandit12@bandit:/tmp/dubini0$ cat data8
The password is 8ZjyCRiBWFYkneahHwxCv3wb2a1ORpYL

 

귀찮아....