회선을 통해: bandit 9 -> 10, 10 -> 11(문자열, grep 및 base64)

문제의 원문(레벨 9 -> 10)

The password for the next level is stored in the file data.
txt in one of the few human-readable strings, preceded by several ‘=’ characters.
  • Passwd는 암호에서 “==” 앞에 오는 사람이 읽을 수 있는 여러 문자 중 하나입니다.
bandit9@bandit:~$ cat data.txt | grep "=="
grep: (standard input): binary file matches

위와 같이 입력했는데 File Discript를 사용하여 바이너리로 읽을 수 없다고 합니다(입력 오류 ‘1’).

  • grep은 일반적으로 바이너리를 읽을 수 없지만 다음 명령으로 읽을 수 있습니다.
  • grep -a : 바이너리 읽기. (바이너리 파일을 읽을 때 자주 사용합니다.)

문자열 => 파일에서 ASCII 문자열을 출력합니다. 즉, 이 명령은 이진 파일도 읽을 수 있습니다.

strings data.txt

▼ ▼▼▼▼▼▼

bandit9@bandit:~$ strings data.txt
..
q99B
fs4l
f========== theM
s,<)
GgYA
..
A|9wE
========== password
)j;S2{
..
>0{MKqzdk
========== is
"6V-(
l(8A
..
========== G7w8LIi6J3kTb8A7j9LgrywtEUlyyp6s

Strings는 간단한 명령어로 아스키값만 뽑아내는데 보기가 어렵습니다. 아래와 같이 하시면 깔끔합니다

bandit9@bandit:~$ strings data.txt | grep "=="
f========== theM
========== password
========== is
========== G7w8LIi6J3kTb8A7j9LgrywtEUlyyp6s


문제의 원문(레벨 10 -> 11)

The password for the next level is stored in the file data.txt, which contains base64 encoded data
  • data.txt는 base64로 인코딩된 데이터입니다.

인코딩 -> 디코딩은 base64 명령을 사용하여 수행됩니다. 그 내용은 다음과 같습니다.

bandit10@bandit:~$ cat data.txt
VGhlIHBhc3N3b3JkIGlzIDZ6UGV6aUxkUjJSS05kTllGTmI2blZDS3pwaGxYSEJNCg==

bandit10@bandit:~$ base64 --decode
VGhlIHBhc3N3b3JkIGlzIDZ6UGV6aUxkUjJSS05kTllGTmI2blZDS3pwaGxYSEJNCg==
The password is 6zPeziLdR2RKNdNYFNb6nVCKzphlXHBM

base64 입력 후 –decode “인코딩된 문자” 입력 -> Ctrl-D를 눌러 종료하고 디코딩된 문자열 출력

bandit10@bandit:~$ echo "VGhlIHBhc3N3b3JkIGlzIDZ6UGV6aUxkUjJSS05kTllGTmI2blZDS3pwaGxYSEJNCg==" | base64 --decode
The password is 6zPeziLdR2RKNdNYFNb6nVCKzphlXHBM
========== G7w8LIi6J3kTb8A7j9LgrywtEUlyyp6s

위와 같이 Echo와 함께 사용하는 방법도 있습니다.