Bandit Level 8 → Level 9

장일영·2024년 5월 10일

Bandit

목록 보기
9/33

Level

Goal

The password for the next level is stored in the file data.txt and is the only line of text that occurs only once

다음 레벨의 패스워드는 data.txt 파일에 저장되어 있으며 단 한 번만 나타난다.

Commands you may need to solve this level

grep, sort, uniq, strings, base64, tr, tar, gzip, bzip2, xxd

Helpful Reading Material

Piping and Redirection

Exploit

bandit8@bandit:~$ ls -al
total 56
drwxr-xr-x  2 root    root     4096 Oct  5  2023 .
drwxr-xr-x 70 root    root     4096 Oct  5  2023 ..
-rw-r--r--  1 root    root      220 Jan  6  2022 .bash_logout
-rw-r--r--  1 root    root     3771 Jan  6  2022 .bashrc
-rw-r-----  1 bandit9 bandit8 33033 Oct  5  2023 data.txt
-rw-r--r--  1 root    root      807 Jan  6  2022 .profile

bandit8@bandit:~$ file data.txt
data.txt: ASCII text

bandit8@bandit:~$ head data.txt
kjIuqjobFBhKw9Mmfj2wAnWbXB2VxSfv
5Y76FifuxKStZi4CVovF2uPhgLrZnLzG
AiYd84lOOVTA4gqJPX7f6DH8eG3zwq1W
A16BW831T94qcsYcGDSkgzYhxnX2xUdK
vlsSKqk3yVx2PZxIkBuZPR3KKIf8hGi1
cEqNrEqHVIIi9fQKdcvAxaip1brmsSxT
FQIgwPiuPKftkFhIy9Nzm94sWdNGTlHd
P8jd7Kr8GXVKTLhe1Y7cVYAARwh4lN4A

data.txt는 ASCII text 파일이므로 sort 커맨드와 uniq 커맨드 이용해 정렬하고 중복을 제거할 수 있다. sort--unique 옵션은 연속적으로 중복된 값만 제거할 수 있으므로 정렬의 결과를 uniq 커맨드로 넘겨 출력한다.

bandit8@bandit:~$ cat data.txt | sort | uniq -c

-c 옵션으로 중복 횟수를 카운트해서 출력할 수 있다. 파일 사이즈가 크면 grep 커맨드를 추가로 호출해 필요한 라인만 출력할 수 있다.

bandit8@bandit:~$ cat data.txt | sort | uniq -c | grep "1\ "

0개의 댓글