[overthewire] Bandit Level 12 → Level 13

moon_security·2025년 3월 3일

[OverTheWire] Bandit

목록 보기
14/32

문제 목표!

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!)

으아아 문제가 엄청 기네요 ㅠㅠ
다음 비밀번호는 data.txt에 저장되어 있으며 hexdump로 이루어진 파일인가 봅니다. 그리고 반복적으로 압축되어 있다고 하네요! 뒤에 내용은 음.. 문제를 풀 때의 팁 같으니 일단 부딪혀 보겠습니다.
cat 명령어를 사용하여 읽어 보았지만 알수 없는 문자들만 보이는군요...

bandit12@bandit:~$ cat data.txt 
00000000: 1f8b 0808 dfcd eb66 0203 6461 7461 322e  .......f..data2.
00000010: 6269 6e00 013e 02c1 fd42 5a68 3931 4159  bin..>...BZh91AY
00000020: 2653 59ca 83b2 c100 0017 7fff dff3 f4a7  &SY.............
00000030: fc9f fefe f2f3 cffe f5ff ffdd bf7e 5bfe  .............~[.
00000040: faff dfbe 97aa 6fff f0de edf7 b001 3b56  ......o.......;V
00000050: 0400 0034 d000 0000 0069 a1a1 a000 0343  ...4.....i.....C
00000060: 4686 4341 a680 068d 1a69 a0d0 0068 d1a0  F.CA.....i...h..
00000070: 1906 1193 0433 5193 d4c6 5103 4646 9a34  .....3Q...Q.FF.4
00000080: 0000 d320 0680 0003 264d 0346 8683 d21a  ... ....&M.F....
00000090: 0686 8064 3400 0189 a683 4fd5 0190 001e  ...d4.....O.....
000000a0: 9034 d188 0343 0e9a 0c40 69a0 0626 4686  .4...C...@i..&F.
000000b0: 8340 0310 d340 3469 a680 6800 0006 8d0d  .@...@4i..h.....
000000c0: 0068 0608 0d1a 64d3 469a 1a68 c9a6 8030  .h....d.F..h...0
000000d0: 9a68 6801 8101 3204 012a ca60 51e8 1cac  .hh...2..*.`Q...
000000e0: 532f 0b84 d4d0 5db8 4e88 e127 2921 4c8e  S/....].N..')!L.
000000f0: b8e6 084c e5db 0835 ff85 4ffc 115a 0d0c  ...L...5..O..Z..
00000100: c33d 6714 0121 5762 5e0c dbf1 aef9 b6a7  .=g..!Wb^.......
00000110: 23a6 1d7b 0e06 4214 01dd d539 af76 f0b4  #..{..B....9.v..
00000120: a22f 744a b61f a393 3c06 4e98 376f dc23  ./tJ....<.N.7o.#
00000130: 45b1 5f23 0d8f 640b 3534 de29 4195 a7c6  E._#..d.54.)A...
00000140: de0c 744f d408 4a51 dad3 e208 189b 0823  ..tO..JQ.......#
00000150: 9fcc 9c81 e58c 9461 9dae ce4a 4284 1706  .......a...JB...
00000160: 61a3 7f7d 1336 8322 cd59 e2b5 9f51 8d99  a..}.6.".Y...Q..
00000170: c300 2a9d dd30 68f4 f9f6 7db6 93ea ed9a  ..*..0h...}.....
00000180: dd7c 891a 1221 0926 97ea 6e05 9522 91f1  .|...!.&..n.."..
00000190: 7bd3 0ba4 4719 6f37 0c36 0f61 02ae dea9  {...G.o7.6.a....
000001a0: b52f fc46 9792 3898 b953 36c4 c247 ceb1  ./.F..8..S6..G..
000001b0: 8a53 379f 4831 52a3 41e9 fa26 9d6c 28f4  .S7.H1R.A..&.l(.
000001c0: 24ea e394 651d cb5c a96c d505 d986 da22  $...e..\.l....."
000001d0: 47f4 d58b 589d 567a 920b 858e a95c 63c1  G...X.Vz.....\c.
000001e0: 2509 612c 5364 8e7d 2402 808e 9b60 02b4  %.a,Sd.}$....`..
000001f0: 13c7 be0a 1ae3 1400 4796 4370 efc0 9b43  ........G.Cp...C
00000200: a4cb 882a 4aae 4b81 abf7 1c14 67f7 8a34  ...*J.K.....g..4
00000210: 0867 e5b6 1df6 b0e8 8023 6d1c 416a 28d0  .g.......#m.Aj(.
00000220: c460 1604 bba3 2e52 297d 8788 4e30 e1f9  .`.....R)}..N0..
00000230: 2646 8f5d 3062 2628 c94e 904b 6754 3891  &F.]0b&(.N.KgT8.
00000240: 421f 4a9f 9feb 2ec9 83e2 c20f fc5d c914  B.J..........]..
00000250: e142 432a 0ecb 0459 1b15 923e 0200 00    .BC*...Y...>...

문제 풀이!

이 파일이 반복적으로 압축되어 있기 떄문에 /tmp 폴더안에 임시 작업공간을 생성합니다.

mkdir /tmp/practice

홈 디렉토리안에 있는 data.txt을 /tmp/practice로 복사합니다.

bandit12@bandit:/tmp/practice$ cp ~/data.txt . # 홈 디렉토리의 data.txt를 현재 폴더로 복사
bandit12@bandit:/tmp/practice$ ls
data.txt
bandit12@bandit:/tmp/practice$ mv data.txt original.hex # 보기 쉽게 이름 변경
bandit12@bandit:/tmp/practice$ ls
original.hex
bandit12@bandit:/tmp/practice$ xxd -r original.hex > data.bin # hexdump된 파일을 다시 바이너리 파일로 변환함
bandit12@bandit:/tmp/practice$ ls
data.bin  original.hex

이제 파일의 형식을 확인한 후 압축된 형식에 따라 압축 해제를 진행하면 됩니다.

bandit12@bandit:/tmp/practice$ file data.bin
data.bin: gzip compressed data, was "data2.bin", last modified: Thu Sep 19 07:08:15 2024, max compression, from Unix, original size modulo 2^32 574
bandit12@bandit:/tmp/practice$ mv data.bin data.gz # gzip 형식이므로 파일 이름 변경
bandit12@bandit:/tmp/practice$ ls
data.gz  original.hex
bandit12@bandit:/tmp/practice$ gunzip data.gz # gunzip 명령어를 활용하여 압축 해제
bandit12@bandit:/tmp/practice$ ls
data  original.hex
bandit12@bandit:/tmp/practice$ file data # bzip2 형식 확인
data: bzip2 compressed data, block size = 900k
bandit12@bandit:/tmp/practice$ mv data data.bz2 # 이름 변경
bandit12@bandit:/tmp/practice$ bunzip2 data.bz2 #bunzip2 명령어를 활용하여 압축 해제
bandit12@bandit:/tmp/practice$ ls
data  original.hex
bandit12@bandit:/tmp/practice$ file data # 파일 형식 확인
data: gzip compressed data, was "data4.bin", last modified: Thu Sep 19 07:08:15 2024, max compression, from Unix, original size modulo 2^32 20480
bandit12@bandit:/tmp/practice$ mv data data.gz # 이름 변경 및 압축 해제
bandit12@bandit:/tmp/practice$ gunzip data.gz
bandit12@bandit:/tmp/practice$ ls
data  original.hex
... # 중략
bandit12@bandit:/tmp/practice$ file data8
data8: ASCII text
bandit12@bandit:/tmp/practice$ cat data8
The password is FO5dwFsc0cbaIiH0h8J2eUks2vdTDwAn

여러번의 압축해제 후 아스키 파일을 얻을 수 있었습니다.
비밀번호 획득 완료 :)

profile
모의해킹 & 보안 공부 기록 블로그

0개의 댓글