보안/Bandit 워게임

OverTheWire - Bandit : Level 2 → Level 3

Security Engineer 2023. 3. 24. 21:00

OverTheWire - Bandit

강의목차: Level 2 → Level 3(cat과 공백문자)

 

Bandit 웹페이지

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

 

 

 

1. Bandit Level 2 → 3

 

Level Goal

 

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

Commands you may need to solve this level

ls , cd , cat , file , du , find

 

Helpful Reading Material

 

다음 레벨의 패스워드는 홈 디렉토리에 위치한 spaces in this filename 의 파일에 저장되어있다.

 

$ ssh -p 2220 bandit2@bandit.labs.overthewire.org

패스워드: rRGizSaX8Mk1RTb1CNQoXTcYZWU6lgzi 

 

$ ls

파일이름인 spaces in this filename 을 cat 명령어를 사용하면 공백으로 인해 제대로 인식되지 않는다.

spaces, in, this, filename 을 각각의 파일 이름으로 생각하여 출력된것이다.

이렇게 공백이 있는 파일을 cat 명령어를 사용할 때는 어떻게 해야 할까?

 

먼저 파일의 형식을 파악한다.

$ file ./*

text 파일임을 확인할 수 있다.

 

cat 명령어를 사용해서 출력하기 위해서는

매 공백 사이에 \ ( 역슬래시 ) 를 넣거나, " " 사이에 파일이름을 써서 cat 명령어를 사용한다.

 

$ cat spaces\ in\ this\ filename
$ cat "spaces in this filename"

$ cat ./sp* ( sp 로 시작하는 모든 파일 출력 )
$ cat ./s*me ( s 로 시작하고 me 로 끝나는 모든 파일 출력 )
$ cat ./s*\ *me ( s 로 시작하고 중간에 공백이 있고 me 로 끝나는 모든 파일 출력 )

패스워드: aBZ0W5EmUfAf7kHTQeOwd8bauFJ2lAiG

 

지금은 파일이 1개이므로 cat 으로 전체 파일을 출력해도 패스워드를 얻을 수 있다.

 

 

$ cat *

$ cat ./*    ( 현재 디렉터리의 모든 것 출력 )

위와 마찬가지로 패스워드를 획득할 수 있다.

 

$ exit ( ssh 접속 상태에서 홈으로 나가기 )

 

 

 

 

Level 3 에 로그인 시도

 

$ ssh -p 2220 bandit3@bandit.labs.overthewire.org

패스워드: aBZ0W5EmUfAf7kHTQeOwd8bauFJ2lAiG

 

 

$ whoami

$ id

입력하여 현재 로그인한 계정 확인

 

 

 

 

 

 

 


취미로 해킹1 강의 : https://www.inflearn.com/course/linux-3