Bandit Level 12
이번 문제는 설명에서 확인할 수 있듯이 압축에 관련된 문제이다. 반복 압축된 파일을 file
명령어로 형식을 확인하며 압축 형식에 맞춰 해제시키면 된다. xxd
, tar
, gzip
, bzip2
를 명령어 사용법을 익히는 것이 이번 문제에 목적이라고 볼 수 있다.
hexdump로 파일 생성
bandit12@bandit:/tmp/bongbongco$ cp ~/data.txt .
bandit12@bandit:/tmp/bongbongco$ cat data.txt
00000000: 1f8b 0808 ffb2 095a 0203 6461 7461 322e .......Z..data2.
00000010: 6269 6e00 0143 02bc fd42 5a68 3931 4159 bin..C...BZh91AY
00000020: 2653 5915 1ab4 ec00 0016 ffff f9ef 39d7 &SY...........9.
00000030: fd9f 55ff bf7d ebf7 7fb9 dfdf bb7b ddef ..U..}.......{..
00000040: 5bff 9efd f5af 7fff defb ffbb b001 3b18 [.............;.
00000050: a403 d41a 00d0 0000 0680 000d 0d06 9a06 ................
00000060: 8d00 f50d 01a0 001a 0003 2341 a683 4320 ..........#A..C
00000070: 69ea 0323 4193 41a0 3653 434f 4880 d0d0 i..#A.A.6SCOH...
00000080: 69a0 6434 00d0 01a3 200d 3400 6868 1a34 i.d4.... .4.hh.4
00000090: d1a6 81a0 f506 4646 20d0 0341 a640 640d ......FF ..A.@d.
000000a0: 3468 d034 000d 000d 191e a0e6 8832 6819 4h.4.........2h.
000000b0: 3234 00d3 4c43 40d0 0068 0d18 834d 00c8 24..LC@..h...M..
000000c0: 00d0 6800 0d32 000d 3406 8c86 4620 c800 ..h..2..4...F ..
000000d0: 1a34 0000 0000 0a30 0049 a75b 6e20 a543 .4.....0.I.[n .C
000000e0: d09d 4d66 fe85 b120 e837 e252 3301 618a ..Mf... .7.R3.a.
000000f0: bd1e d8af 2af0 e6eb 25ef 0a2f 0251 a437 ....*...%../.Q.7
00000100: c452 ed6e 392a aa9a 6e0a 1a39 300d 66a7 .R.n9*..n..90.f.
00000110: 6b38 9455 c1bb 7fd0 011a 4815 02c9 9d2c k8.U......H....,
00000120: 6547 da37 da8f 0c4f 274b 22b8 037d 8bab eG.7...O'K"..}..
00000130: 1d73 5c1f 99dd a462 d3e8 708c 686a a9f4 .s\....b..p.hj..
00000140: ac5c 14b7 0847 f033 f94f 14fe 22cd 121c .\...G.3.O.."...
00000150: d452 ccc5 d046 6f31 747d 28a3 f740 4501 .R...Fo1t}(..@E.
00000160: caea 80c6 19d1 7204 1486 2ab4 8659 4d95 ......r...*..YM.
00000170: 5ce8 c14d e3fc 4559 30a2 3dce 2b1c 4c42 \..M..EY0.=.+.LB
00000180: a145 b65a 32d2 3815 d834 e211 6223 64d0 .E.Z2.8..4..b#d.
00000190: 0a3a 2194 2e04 2747 9414 2448 f317 5637 .:!...'G..$H..V7
000001a0: 613a a9eb 0ae7 293e e081 bce2 3ef0 4042 a:....)>....>.@B
000001b0: eb16 a424 c647 a04b a919 9008 c1a9 0ffd ...$.G.K........
000001c0: fcbe 8786 3ac8 44e6 8804 9cba 8244 c80f ....:.D......D..
000001d0: 2e0e e18e bece 276c 6f4a d308 b8fc 2d3e ......'loJ....->
000001e0: 9351 90fd 68f5 2922 f294 92a5 4afd dc64 .Q..h.)"....J..d
000001f0: 37e3 7f05 fe04 01a6 803c 1d09 16a2 aa0f 7........<......
00000200: 359b a5b8 e110 2bfd 3733 7e21 b207 7aaa 5.....+.73~!..z.
00000210: bc41 4152 641c 15f8 081b 22d9 f891 a093 .AARd.....".....
00000220: 24e6 f18f befe 9651 6a14 e086 1826 9eec $......Qj....&..
00000230: f9ce bc70 47fe 983b df74 1d32 f483 cbfe ...pG..;.t.2....
00000240: 0992 0f50 78e1 65b2 c2c9 1d93 5631 5914 ...Px.e.....V1Y.
00000250: 9fe2 ee48 a70a 1202 a356 9d80 0cbb 8293 ...H.....V......
00000260: 4302 0000 C...
bandit12@bandit:/tmp/bongbongco$ xxd -r ./data.txt ./output.bin
압축 해제
bandit12@bandit:/tmp/bongbongco$ file output.bin
output.bin: gzip compressed data, was "data2.bin", last modified: Mon Nov 13 14:58:07 2017, max compression, from Unix
bandit12@bandit:/tmp/bongbongco$ mv output.bin data1.gz
bandit12@bandit:/tmp/bongbongco$ gzip -d data1.gz
bandit12@bandit:/tmp/bongbongco$ ls
data.txt data1
bandit12@bandit:/tmp/bongbongco$ file data1
data1: bzip2 compressed data, block size = 900k
bandit12@bandit:/tmp/bongbongco$ bzip2 -d data1
bzip2: Cant guess original name for data1 -- using data1.out
bandit12@bandit:/tmp/bongbongco$ file data1.out
data1.out: gzip compressed data, was "data4.bin", last modified: Mon Nov 13 14:58:07 2017, max compression, from Unix
bandit12@bandit:/tmp/bongbongco$ mv data1.out data1.gz
bandit12@bandit:/tmp/bongbongco$ gzip -d data1.gz
bandit12@bandit:/tmp/bongbongco$ ls
data.txt data1
bandit12@bandit:/tmp/bongbongco$ file data1
data1: POSIX tar archive (GNU)
bandit12@bandit:/tmp/bongbongco$ tar xvf ./data1
data5.bin
bandit12@bandit:/tmp/bongbongco$ ls
data.txt data1 data5.bin
bandit12@bandit:/tmp/bongbongco$ file data5.bin
data5.bin: POSIX tar archive (GNU)
bandit12@bandit:/tmp/bongbongco$ tar xvf ./data5.bin
data6.bin
bandit12@bandit:/tmp/bongbongco$ ls
data.txt data1 data5.bin data6.bin
bandit12@bandit:/tmp/bongbongco$ file data6.bin
data6.bin: bzip2 compressed data, block size = 900k
bandit12@bandit:/tmp/bongbongco$ ls
data.txt data1 data5.bin data6.bin
bandit12@bandit:/tmp/bongbongco$ bzip2 -d data6.bin
bzip2: Can't guess original name for data6.bin -- using data6.bin.out
bandit12@bandit:/tmp/bongbongco$ file data6.bin.out
data6.bin.out: POSIX tar archive (GNU)
bandit12@bandit:/tmp/bongbongco$ ls
data.txt data1 data5.bin data6.bin.out
bandit12@bandit:/tmp/bongbongco$ tar -xvf ./data6.bin.out
data8.bin
bandit12@bandit:/tmp/bongbongco$ file data8.bin
data8.bin: gzip compressed data, was "data9.bin", last modified: Mon Nov 13 14:58:07 2017, max compression, from Unix
bandit12@bandit:/tmp/bongbongco$ mv data8.bin data8.gz
bandit12@bandit:/tmp/bongbongco$ gzip -d data8.gz
bandit12@bandit:/tmp/bongbongco$ ls
data.txt data1 data5.bin data6.bin.out data8
bandit12@bandit:/tmp/bongbongco$ file data8
data8: ASCII text
패스워드 확인
bandit12@bandit:/tmp/bongbongco$ cat data8
The password is 8ZjyCRiBWFYkneahHwxCv3wb2a1ORpYL