OverTheWire : Bandit Level 2 → Level 3

heuniy·2023년 9월 24일

bandit_write up

목록 보기
4/10

문제

https://overthewire.org/wargames/bandit/bandit3.html

Bandit Level 2 → Level 3
Level Goal
The password for the next level is stored in a file called spaces in this filename located in the home directory

home 디렉토리 안에 있는 spaces in this filename 파일을 읽으면 password 를 얻을 수 있다.


풀이

현재 어디 있는지 확인하기 위해 pwd 명령어를 사용한다.

bandit2@bandit:~$ pwd
/home/bandit2

home 디렉토리에 있음을 확인할 수 있다.



디렉토리 목록을 확인하기 위해 ls 명령어를 사용한다.

bandit2@bandit:~$ ls
spaces in this filename

spaces in this filename 파일이 있음을 확인할 수 있다.



파일 내용 출력을 위해 cat 명령어를 사용한다.

bandit2@bandit:~$ cat spaces in this filename
cat: spaces: No such file or directory
cat: in: No such file or directory
cat: this: No such file or directory
cat: filename: No such file or directory

하지만 파일 내용이 출력되지 않는다.


띄어쓰기 공간을 기준으로 하나의 파일로 인식하기 때문에
파일 이름에 띄어쓰기가 있는 경우 어떻게 입력해야 할 지 찾아보았다.

How do you deal with spaces in filename, then? There are two ways:

1. Wrap the entire filename between quotes
2. Escape every space using backslash key

두 가지 방법이 있음을 확인할 수 있다.


bandit2@bandit:~$ cat 'spaces in this filename'
aBZ0W5EmUfAf7kHTQeOwd8bauFJ2lAiG

bandit2@bandit:~$ cat spaces\ in\ this\ filename
aBZ0W5EmUfAf7kHTQeOwd8bauFJ2lAiG

passwordaBZ0W5EmUfAf7kHTQeOwd8bauFJ2lAiG 이다.


기타

리눅스 명령어 정리 (누적)

pwd : 현재 작업중인 디렉토리 정보(경로) 출력

ls : 디렉토리 목록 확인

cat [파일명] : [파일명] 내용 출력

  • cat ./[파일명] : 현재 디렉토리에 있는 [파일명] 내용을 출력
  • cat '[파 일 명]' : space가 있는 [파일명] 내용 출력
  • cat [파\ 일\ 명] : space가 있는 [파일명] 내용 출력
profile
고양이 귀여워

0개의 댓글