Bandit Level 2 → Level 3

Minchae Kim·2023년 4월 30일
0

📌 Level 2 → Level 3


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

🚩 Level Goal

The password for the next level is stored in a file called spaces in this filename located in the home directory

🚩 Problem Solving

이전 단계에서 사용했던 cat 명령어로 문제에서 주어진 파일 spaces in this filename을 불러올 경우, 주어진 단어 하나씩 쪼개서 출력된다. 즉 spaces, in, this, filename으로 받아들여지기에, No such file or directory라는 문구가 나오게 되는 것이다.

🔹 Process

파일 이름에 공백이 있을 경우, ''를 사용해서 파일 이름을 감싸주면 된다.

cat 'spaces in this filename'

혹은 단어마다 공백 이전에 \를 추가해야 한다.

cat spaces\ in\ this\ filename

🔹 Password

Bandit3 Password : aBZ0W5EmUfAf7kHTQeOwd8bauFJ2lAiG

📌 Linux Commands


  • Commands you may need to solve this level : ls , cd , cat , file , du , find
  • Helpful Reading Material : Google Search for “spaces in filename”

🚩 공백과 특수 문자가 있는 파일 이름 조작

리눅스에서 파일 이름에 공백이 들어간 경우는 흔하지 않지만, 현재 level에서 요구하기에 간단하게 정리해보았다.

https://linuxopsys.com/topics/how-to-read-filename-with-spaces-in-linux

🔹 공백이 포함된 파일 이름

가장 단순하면서도 쉬운 방법은, ''를 사용하는 것이다. cat 명령어로 파일을 읽어내는 것 뿐만 아니라, 추후 나오겠지만 touch라는 명령어를 활용하여 파일을 생성할 때도 사용할 수 있다.

touch 'read this file'

앞서 언급했다시피, cat 명령어 사용할 때는 \를 이용해도 된다.

cat read\ this\ file

이외에 mkdir 명령어를 사용하여 directory를 생성할 때도 \을 이용하면 공백 있는 디렉터리 형성이 가능하다. 위와 동일하게 공백은 backslash 다음에 사용하면 된다. cd 명령어도 마찬가지다.

mkdir make\ this\ directory

🔹 특수 문자가 포함된 파일 이름

보통 특수 문자라고 하면, -(대시), ;(세미콜론), #(해시) 등을 의미한다. - 다루는 방법은 앞서 다루었고, 나머지는 추후 나온다면 더 자세하게 다룰 예정이다. 간단하게 정리하고 넘어가자.

  • - : --./를 사용한다.
  • ; : ./'file name' 또는 ''를 사용하면 된다.
  • # : ./ 또는 ''를 사용한다. # 기호는 # 뒤에 오는 모든 것을 주석으로 처리한다. 그렇기 때문에 missing file operand가 뜰 수 있다.
profile
It's time to fire on up !

0개의 댓글