Bandit

Bandit 워게임으로 리눅스 공부하기 - Bandit Level 2 → Level 3

waterclean101 2023. 8. 23. 13:01

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

→ 홈 디렉토리에 있는 "spaces in this filename"라는 이름의 파일에 저장된 비밀번호를 찾는 문제

풀이

1. find로 파일 위치 알아내기

bandit2@bandit:~$ find / -name "*spaces*" 2>/dev/null

/opt/radare2/test/db/cmd/spaces
/opt/radare2/test/unit/test_spaces.c
/opt/radare2/libr/util/spaces.d
/opt/radare2/libr/util/spaces.o
/opt/radare2/libr/util/spaces.c
/opt/radare2/libr/include/r_util/r_spaces.h
/home/bandit2/spaces in this filename # 여기 찾음
/proc/sys/user/max_cgroup_namespaces
/proc/sys/user/max_ipc_namespaces
/proc/sys/user/max_mnt_namespaces
/proc/sys/user/max_net_namespaces
/proc/sys/user/max_pid_namespaces
/proc/sys/user/max_time_namespaces
/proc/sys/user/max_user_namespaces
/proc/sys/user/max_uts_namespaces
  • "*spaces*": 이 부분은 검색할 파일 이름을 지정하는데 사용된다. 여기서 *****는 와일드카드로서 모든 문자열을 나타낸다. 따라서 **"*spaces*"**는 파일 이름 중간이나 어디에든 "spaces" 문자열이 포함된 파일을 찾는다는 의미다.

2. cat으로 바로 읽기

bandit2@bandit:~$ cat /home/bandit2/"spaces in this filename"
  • 파일 이름에 스페이스가 들어간 경우 “” 로 묶어서 찾을 수 있다.

3. bandit3 계정에 로그인

다른 username으로 접속하기 위해 먼저 기존 원격접속을 해제하고 재접속한다.

bandit2@bandit:~$ exit
logout
Connection to bandit.labs.overthewire.org closed.
                                                                                                                                                                                                                                           
┌──(root㉿kali)-[/home/kali]
└─# ssh bandit3@bandit.labs.overthewire.org -p 2220

                         _                     _ _ _   
                        | |__   __ _ _ __   __| (_) |_ 
                        | '_ \\ / _` | '_ \\ / _` | | __|
                        | |_) | (_| | | | | (_| | | |_ 
                        |_.__/ \\__,_|_| |_|\\__,_|_|\\__|
                                                       

                      This is an OverTheWire game server. 
            More information on <http://www.overthewire.org/wargames>

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

      ,----..            ,----,          .---.
     /   /   \\         ,/   .`|         /. ./|
    /   .     :      ,`   .'  :     .--'.  ' ;
   .   /   ;.  \\   ;    ;     /    /__./ \\ : |
  .   ;   /  ` ; .'___,/    ,' .--'.  '   \\' .
  ;   |  ; \\ ; | |    :     | /___/ \\ |    ' '
  |   :  | ; | ' ;    |.';  ; ;   \\  \\;      :
  .   |  ' ' ' : `----'  |  |  \\   ;  `      |
  '   ;  \\; /  |     '   :  ;   .   \\    .\\  ;
   \\   \\  ',  /      |   |  '    \\   \\   ' \\ |
    ;   :    /       '   :  |     :   '  |--"
     \\   \\ .'        ;   |.'       \\   \\ ;
  www. `---` ver     '---' he       '---" ire.org

Welcome to OverTheWire!

패스워드까지 입력하면 접속 성공