본문 바로가기

Bandit

Bandit: Level 7

PS C:\Users\USER> ssh bandit7@bandit.labs.overthewire.org -p2220

...

bandit7@bandit.labs.overthewire.org's password:

...

bandit7@bandit:~$

 

The password for the next level is stored in the file data.txt next to the word millionth

 

 

먼저, data.txt 파일을 찾아 보자.

bandit7@bandit:~$ ls -al
total 4108
drwxr-xr-x   2 root    root       4096 Jul 28 19:04 .
drwxr-xr-x 150 root    root       4096 Jul 28 19:06 ..
-rw-r--r--   1 root    root        220 Mar 31  2024 .bash_logout
-rw-r--r--   1 root    root       3851 Jul 28 18:47 .bashrc
-rw-r-----   1 bandit8 bandit7 4184396 Jul 28 19:04 data.txt
-rw-r--r--   1 root    root        807 Mar 31  2024 .profile

bandit7@bandit:~$ cat data.txt

. . .
sniped  vFiKhVWsFsRiW22574umWbBz3m9xSSIO
adjoin  5aKqzGfPb1YD182oRVpKcg63P5HuMUsu
sights  ijotAUdrD8ZBr2rpyvgmUMCJeaB1s2w9
secondary       Urvz0OxNpjdWRKTah4T4p3rbDYYsB8fM
Dickerson       Sxab2WdYYGJZKMlet7PpBDApGtXcz0Lk
passively       ir7EDSKS318L8LLXjA07CUDGQM1Qw5jn
rubbles l8zNRjdVJOJ5rd11FZMSUoQFqmpOEeJy
stigmatizing    7OjvuMpyEcAx9QchZgRpSMsQo9sEotjf
ancient r8IIMPHYs076iGiRpBzJ3stU0gJDayJM
woodiness       J7RMQt5qL5Oa9H1XonEZfEDrzpJyuHBj
energy  LPr5juqYdflDHp4bEDRry2oL2Iv1bfww
sodomites       MaljPfKIOURf1x9KS3AT5PJtt622xsEI
gherkin BMElvwJSIUtLGEQwCyOtGAsnlG9tPG4r
simulcasted     KrgLNi35CP3HHeW3lZmXzmWkEuc0RSn4
. . .

 

현재 위치에 존재하는 파일들을 살펴 보았더니 data.txt가 존재한다.

바로 cat 명령어를 이용해 내용을 읽어보려 했으나 엄청난 양의 정보가 순식간에 들어 있어 끊이지 않고 10초 이상 파일을 읽어내려 갔다.

cat 명령어를 통해서는 millionth 옆의 문자열을 찾기 어려워 보여 다른 방법을 시도해야겠지만, 내용의 형식을 알았으므로 millionth라는 단어가 위치한 한 줄 전체를 출력하면 되겠다는 생각이 든다.

 

 

이럴 때 유용한 명령어가 바로 파일 내의 특정한 문자열을 찾을 때 사용되는 grep 명령어 이다.

옵션이 굉장히 다양한데, 그 중 위에 사용된 -w 옵션은 단어가 포함된 행을 출력한다.

 

예를 들어, grep -w "millionth" data.txt 라는 명령을 실행하면, 

data.txt 파일 안에서 millionth 라는 단어가 포함된 줄만 그 내용이 출력될 것이다.

bandit7@bandit:~$ grep -w "millionth" data.txt
millionth       dfwvzFQi4mU0wfNbFOe9RoWskMLg7eEc

 

 

 

'Bandit' 카테고리의 다른 글

Bandit: Level 9  (0) 2025.08.22
Bandit: Level 8  (2) 2025.08.09
Bandit: Level 6  (0) 2025.07.31
Bandit: Level 5  (3) 2025.07.28
Bandit: Level 4  (2) 2025.07.28