본문 바로가기

Bandit

Bandit: Level 4

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

...

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

...

bandit4@bandit:~$

 

The password for the next level is stored in the only human-readable file in the inhere directory. Tip: if your terminal is messed up, try the “reset” command.

 

bandit4@bandit:~/inhere$ ls -al
total 48
drwxr-xr-x 2 root    root    4096 Apr 10 14:23 .
drwxr-xr-x 3 root    root    4096 Apr 10 14:23 ..
-rw-r----- 1 bandit5 bandit4   33 Apr 10 14:23 -file00
-rw-r----- 1 bandit5 bandit4   33 Apr 10 14:23 -file01
-rw-r----- 1 bandit5 bandit4   33 Apr 10 14:23 -file02
-rw-r----- 1 bandit5 bandit4   33 Apr 10 14:23 -file03
-rw-r----- 1 bandit5 bandit4   33 Apr 10 14:23 -file04
-rw-r----- 1 bandit5 bandit4   33 Apr 10 14:23 -file05
-rw-r----- 1 bandit5 bandit4   33 Apr 10 14:23 -file06
-rw-r----- 1 bandit5 bandit4   33 Apr 10 14:23 -file07
-rw-r----- 1 bandit5 bandit4   33 Apr 10 14:23 -file08
-rw-r----- 1 bandit5 bandit4   33 Apr 10 14:23 -file09

 

여러 개의 파일들이 나온다.

이 중 human-readable 파일을 찾기 위해 file 명령어를 사용한다.

bandit4@bandit:~/inhere$ file *
file: Cannot open `ile00' (No such file or directory)
file: Cannot open `ile01' (No such file or directory)
file: Cannot open `ile02' (No such file or directory)
file: Cannot open `ile03' (No such file or directory)
file: Cannot open `ile04' (No such file or directory)
file: Cannot open `ile05' (No such file or directory)
file: Cannot open `ile06' (No such file or directory)
file: Cannot open `ile07' (No such file or directory)
file: Cannot open `ile08' (No such file or directory)
file: Cannot open `ile09' (No such file or directory)

 

그냥 file * 로 검색했더니 역시나 파일 이름 앞의 -f를 옵션으로 인식해서 제대로 된 검색 결과가 나오지 않는다.

bandit4@bandit:~/inhere$ file ./-file*
./-file00: PGP Secret Sub-key -
./-file01: data
./-file02: data
./-file03: data
./-file04: data
./-file05: data
./-file06: data
./-file07: ASCII text
./-file08: data
./-file09: data

 

./는 현재 디렉토리내의 파일이라는 뜻이므로 ./를 써주고 그뒤에 파일명을 써주면 옵션으로 인식되지 않아 정상적으로 명령어를 작동시킬 수 있다.

 

문제에서 읽어낼 수 있는 파일에 정보가 들어있다고 했으므로 파일이 아스키코드로 작성된 -file07 에 우리가 찾는 정보가 들어있을 것이다.

 

***참고: 여기서 -file00의 [PGP Secret Sub-key -] 라는 파일 형식은, 사람이 읽을 수 있는 텍스트가 아니라 GnuPG 같은 툴에서 비밀 키 데이터로 해석될 수 있는 바이너리 데이터가 들어있다는 뜻이므로 이는 인간이 해석할 수 없는 내용에 해당한다.

 

bandit4@bandit:~/inhere$ cat ./-file07
4oQYVPkxZOOEOO5pTW81FB8j8lxXGUQw

'Bandit' 카테고리의 다른 글

Bandit: Level 6  (0) 2025.07.31
Bandit: Level 5  (3) 2025.07.28
Bandit: Level 3  (1) 2025.07.28
Bandit: Level 2  (0) 2025.07.28
Bandit: Level 1  (0) 2025.07.28