본문 바로가기
Security/CTF

Bandit Level 8 → Level 9 [8/34]

by LimSeongHyeon 2025. 5. 28.
 

OverTheWire: Level Goal

We're hackers, and we are good-looking. We are the 1%. <!-- Please read and accept the Rules! --> 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 Commands you may need to solve th

overthewire.org

 

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

 

 

이번에도 디렉터리부터 확인해보자

bandit8@bandit:~$ ls -al
total 56
drwxr-xr-x  2 root    root     4096 Apr 10 14:23 .
drwxr-xr-x 70 root    root     4096 Apr 10 14:24 ..
-rw-r--r--  1 root    root      220 Mar 31  2024 .bash_logout
-rw-r--r--  1 root    root     3771 Mar 31  2024 .bashrc
-rw-r-----  1 bandit9 bandit8 33033 Apr 10 14:23 data.txt
-rw-r--r--  1 root    root      807 Mar 31  2024 .profile

 

 

플래그는 data.txt에 적혀있는 것 같고, "the only line of text that occurs only once"라고 하는것을 보아하니 uniq 명령어를 써야될 것 같은 느낌이 든다.

uniq [OPTION]... [INPUT [OUTPUT]]

-u, --unique
	only print unique lines

 

 

-u 옵션을 지정하면 unique line만 print 한단다. 사용 방법도 친히 나와있으니 사용해보도록 하자.

bandit8@bandit:~$ uniq -u data.txt 
L3ZCH71RRxt8Kmy3X3R0NqQTmebcmkQ4
NknAyxnPgpoEcWHizP4TA8ALeIyco1VT
Fmt5ODm3V6Qf1oTF3qEJNWlVcHFdpbuz
nOu0uI9qll3ws9FtaQt7mE4ngAmMAsfE
ksiDcx6JXM6yZSfpf1TlIIlABpb97SAy
NknAyxnPgpoEcWHizP4TA8ALeIyco1VT
...

엄.. 생각보다 uniq 라인이 매우 많다... 이름 우째야 할까 

 

 

uniq --help를 쳐서 man에 없는 팁이 있나 확인하는 도중 두둥탁..

Note: 'uniq' does not detect repeated lines unless they are adjacent.
You may want to sort the input first, or use 'sort -u' without 'uniq'.

인접한 줄 아니면 감지를 못한댄다... 그럼 sort를 사용하는 쪽으로 바꿔보자

 

 

sort로 data.txt를 먼저 정렬하고 uniq -u에 넘겨줘보자.

bandit8@bandit:~$ sort data.txt | uniq -u
[PASSWORD]

특정에 성공하였다. 궁금하니까 다른 값들에 중복을 확인해보자

 

bandit8@bandit:~$ sort data.txt | uniq -c
     10 0lLAU8Hx0a5E8URNEITfTIe9sy6tcpeE
     10 0oTVZsmZ2OmngEgPis8LloSSnuBmm7t9
     10 11RbnkUhGZG3V5XHw9YBKPWcdZTQrYSQ
     10 3M5U6xE6bEuGjktQvDD4eyHnW3bwvCkj
     10 3WrYuQdo7JuGsvyB8hRss8A1uKcda2q4
      1 [PASSWORD]
     10 4rrSr6IONT8TbtjY0fBa6G5SxLu76X4U
     ...

다른건 모두 10번씩 적혀있었나보다.

 

성공!

'Security > CTF' 카테고리의 다른 글

Bandit Level 7 → Level 8 [7/34]  (0) 2025.05.28
Bandit Level 6 → Level 7 [6/34]  (0) 2025.05.28
Bandit Level 5 → Level 6 [5/34]  (0) 2025.05.28
Bandit Level 4 → Level 5 [4/34]  (0) 2025.05.27
Bandit Level 3 → Level 4 [3/34]  (0) 2025.05.27