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!)
grep, sort, uniq, strings, base64, tr, tar, gzip, bzip2, xxd, mkdir, cp, mv, file
오늘 써볼 명령어
(mktemp, cp, file, xxd, mv, gzip, bzip2, tar)
mktemp : /tmp 하위에 디렉토리 생성 (이름도 완전 랜덤)
- -d: 임시 디렉토리 생성
cp : 원본 파일을 원하는 위치에 복사 붙여넣기 할 수 있는 명령어
- -i : 복사 파일이 이름이 이미 존재할 경우, 사용자에게 덮어 쓰기 여부 확인
- -b : 복사될 파일이 이름이 이미 존재할 경우, 백업파일을 생성
- -f : 복사 될 파일이 이름이 이미 존재 할 경우, 강제로 덮어쓰기
- -r : 하위 디렉토리 까지 모두 복사
- -a : 원본 파일의 속성, 링크 정보까지 모두 복사
- -p : 원본 파일의 소유자, 그룹, 권한 등의 정보까지 모두 복사
- -v : 복사 진행 상태를 출력
- 제일 많이 사용하는건 붙여넣기할 경로정도?
file : 지정 파일이 무슨 속성을 가진 파일인지 확인 (ex: ASCII, gzip, bzip2 ...)
- file [폴더 이름]
xxd : binary file을 16진수로 hexdump 하거나, dump된 내용을 binary file로 되돌릴 때 사용
- -r : 16진수 덤프를 원본 바이너리 데이터로 되돌리기
- -l len : 출력할 바이트 수를 len으로 제한
- -s offset : 파일의 특정 오프셋(offset)부터 덤프 시작
- -p : "plain" 덤프를 생성합니다. 16진수만 출력하고, 주소나 ASCII 표현은 포함하지 않습니다
- -g bytes : 바이트 그룹의 너비를 설정 (기본값은 8비트)
- -h : 파일의 끝에 "hex dump"라고 출력
gzip : 압축 또는 해제
- -d : (decompress) : 압축 해제 옵션
bzip2 : 압축 또는 해제 (원본파일의 내용 손상이 극소화되는 이점을 가지고 있다)
- -d: 압축 해제 옵션
tar : 압축 또는 해제
- -f : 대상 tar 아카이브 지정. (기본 옵션)
- -c : tar 아카이브 생성. 기존 아카이브 덮어 쓰기. (파일 묶을 때 사용)
- -x : tar 아카이브에서 파일 추출. (파일 풀 때 사용)
- -v : 처리되는 과정(파일 정보)을 자세하게 나열
- -z : gzip 압축 적용 옵션
- -j : bzip2 압축 적용 옵션
- -t : tar 아카이브에 포함된 내용 확인
- C : 대상 디렉토리 경로 지정
- -A : 지정된 파일을 tar 아카이브에 추가
- -d : tar 아카이브와 파일 시스템 간 차이점 검색
- -r : tar 아카이브의 마지막에 파일들 추가
- -u : tar 아카이브의 마지막에 파일들 추가
- -k : tar 아카이브 추출 시, 기존 파일 유지
- -U : tar 아카이브 추출 전, 기존 파일 삭제
- -w : 모든 진행 과정에 대해 확인 요청. (interactive)
- -e : 첫 번째 에러 발생 시 중지
다량의 압축이 된 파일을 순조롭게 풀기 위해서 임시 디렉토리를 생성하고,해당 경로에서 반복적인 압축 해제를 진행한다
bandit12@bandit:~$ ls
data.txt
bandit12@bandit:~$ mktemp -d
/tmp/tmp.EDqSpA2oJB
bandit12@bandit:~$ cp data.txt /tmp/tmp.EDqSpA2oJB
bandit12@bandit:~$ cd /tmp/tmp.EDqSpA2oJB
bandit12@bandit:/tmp/tmp.EDqSpA2oJB$ ls
data.txt
bandit12@bandit:/tmp/tmp.EDqSpA2oJB$ file data.txt
data.txt: ASCII text
<div class="cssterm">
bandit12@bandit:~$ ls
data.txt
bandit12@bandit:~$ mktemp -d
/tmp/tmp.EDqSpA2oJB
bandit12@bandit:~$ cp data.txt /tmp/tmp.EDqSpA2oJB
bandit12@bandit:~$ cd /tmp/tmp.EDqSpA2oJB
bandit12@bandit:/tmp/tmp.EDqSpA2oJB$ ls
data.txt
bandit12@bandit:/tmp/tmp.EDqSpA2oJB$ file data.txt
data.txt: ASCII text
</div>
hexdump 파일 해제/ data2라는 파일은 gzip으로 압축된 데이터 파일이라고 설명해주네요
bandit12@bandit:/tmp/tmp.EDqSpA2oJB$ xxd -r data.txt > test
bandit12@bandit:/tmp/tmp.EDqSpA2oJB$ ls
test data.txt
bandit12@bandit:/tmp/tmp.EDqSpA2oJB$ file test
test: gzip compressed data, was "data2.bin", last modified: Tue Oct 14 09:26:00 2025, max compression, from Unix, original size modulo 2^32 572
파일을 gzip 속성에 맞춰 변경해주고 gzip 압축 해제를 진행하니 bzip2로 압축되어있는 파일임을 확인할 수 있습니다
bandit12@bandit:/tmp/tmp.EDqSpA2oJB$ mv test test.gz
bandit12@bandit:/tmp/tmp.EDqSpA2oJB$ ls
data.txt test.gz
bandit12@bandit:/tmp/tmp.EDqSpA2oJB$ gzip -d test.gz
bandit12@bandit:/tmp/tmp.EDqSpA2oJB$ ls
data.txt test
bandit12@bandit:/tmp/tmp.EDqSpA2oJB$ file test
test: bzip2 compressed data, block size = 900k
그렇다면 bzip2 압축을 풀어봐야겠죠.
bandit12@bandit:/tmp/tmp.EDqSpA2oJB$ mv test test.bz2
bandit12@bandit:/tmp/tmp.EDqSpA2oJB$ ls
data.txt test.bz2
bandit12@bandit:/tmp/tmp.EDqSpA2oJB$ bzip2 -d test.bz2
bandit12@bandit:/tmp/tmp.EDqSpA2oJB$ ls
data.txt test
bandit12@bandit:/tmp/tmp.EDqSpA2oJB$ file test
test: gzip compressed data, was "data4.bin", last modified: Tue Oct 14 09:26:00 2025, max compression, from Unix, original size modulo 2^32 20480
gzip 압축을 풀어보니 이번에는 새롭게 tar로 압축되어있습니다
bandit12@bandit:/tmp/tmp.EDqSpA2oJB$ mv test test.gz
bandit12@bandit:/tmp/tmp.EDqSpA2oJB$ ls
data.txt test.gz
bandit12@bandit:/tmp/tmp.EDqSpA2oJB$ gzip -d test.gz
bandit12@bandit:/tmp/tmp.EDqSpA2oJB$ ls
data.txt test
bandit12@bandit:/tmp/tmp.EDqSpA2oJB$ file test
test: POSIX tar archive (GNU)
궁금해서 파일을 한번 읽어봤더니 .. 한참 더 압축을 풀어야할 것 같습니다 이번에도 tar로 압축되어 있습니다
bandit12@bandit:/tmp/tmp.EDqSpA2oJB$ cat test
I22L�SL�d␦<��Pi~��2hɓ000��␦��r�y?�002400015073413450011242 0ustar rootrootdata6.bin0000644000000000000000000000033315073413450011246 0ustar rootrootBZh91AY&SY�I����j��}�� [#�ta�@f �
�P��TŴ��4H�*C�'jb�7)�z4���t��p�&5��Z�4�V#´e^�y
ڼ�+>�K-��J�՞lBI��L*�
6;>�d.(J"N��d9�d��(�2@@?��"�(HD$���
bandit12@bandit:/tmp/tmp.EDqSpA2oJB$ mv test test.tar
bandit12@bandit:/tmp/tmp.EDqSpA2oJB$ tar -xvf test.tar
data5.bin
bandit12@bandit:/tmp/tmp.EDqSpA2oJB$ file data5.bin
data5.bin: POSIX tar archive (GNU)
이번에도 tar 압축 -> 풀고
bandit12@bandit:/tmp/tmp.EDqSpA2oJB$ mv data5.bin data5.bin.tar
bandit12@bandit:/tmp/tmp.EDqSpA2oJB$ ls
data5.bin.tar data.txt test.tar
bandit12@bandit:/tmp/tmp.EDqSpA2oJB$ tar -xvf data5.bin.tar
data6.bin
bandit12@bandit:/tmp/tmp.EDqSpA2oJB$ file data6.bin
data6.bin: POSIX tar archive (GNU)
bandit12@bandit:/tmp/tmp.EDqSpA2oJB$ mv data6.bin data6.bin.tar
bandit12@bandit:/tmp/tmp.EDqSpA2oJB$ tar -xvf data6.bin.tar
data8.bin
gzip으로 된 data8파일을 압축해제했더니 드디어 보이는 ASCII text 파일 !!
bandit12@bandit:/tmp/tmp.EDqSpA2oJB$ file data8.bin
data8.bin: gzip compressed data, was "data9.bin", last modified: Tue Oct 14 09:26:00 2025, max compression, from Unix, original size modulo 2^32 49
bandit12@bandit:/tmp/tmp.EDqSpA2oJB$ mv data8.bin data8.bin.gz
bandit12@bandit:/tmp/tmp.EDqSpA2oJB$ ls
data5.bin.tar data6.bin.tar data8.bin.gz data.txt test.tar
bandit12@bandit:/tmp/tmp.EDqSpA2oJB$ gzip -d data8.bin.gz
bandit12@bandit:/tmp/tmp.EDqSpA2oJB$ ls
data5.bin.tar data6.bin.tar data8.bin data.txt test.tar
bandit12@bandit:/tmp/tmp.EDqSpA2oJB$ file data8.bin
data8.bin: ASCII text
짜잔 최종 결과물이 나왔습니다
bandit12@bandit:/tmp/tmp.EDqSpA2oJB$ cat data8.bin
The password is FO5dwFsc0cbaIiH0h8J2eUks2vdTDwAn
bandit13번 문제는 반복이 많은 문제였습니다 야호~
'bandit' 카테고리의 다른 글
| [OverTheWire] bandit 13 -> 14 (0) | 2025.11.23 |
|---|---|
| [OverTheWire] bandit 19 -> 20 (0) | 2025.11.22 |
| [OverTheWire] bandit 11 -> 12 (0) | 2025.11.22 |
| [OverTheWire] bandit 10 -> 11 (0) | 2025.11.22 |
| [OverTheWire] bandit 9 -> 10 (0) | 2025.11.22 |