Bandit

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

waterclean101 2023. 8. 23. 13:01

Level Goal

The password for the next level is stored in a file called - located in the home directory

Commands you may need to solve this level

ls , cd , cat , file , du , find

→ 다음 단계의 비밀번호는 홈 디렉터리에 있는 -라는 파일에 저장되어있다는 문제

풀이

1. bandit1 계정에 로그인

┌──(root㉿kali)-[/home/kali]
└─# ssh bandit1@bandit.labs.overthewire.org -p 2220

2. pwd와 ls 명령어 사용

bandit1@bandit:~$ pwd # 현재 위치 확인
/home/bandit1
bandit1@bandit:~$ ls # 현재 디렉토리 내용의 리스트
-
  • **pwd** 로 현재 위치가 /home/bandit1 이라는 것을 확인했고 **ls** 로 ‘-’ 가 현재 위치에 있음을 알아냈다.

3. 파일 정보 확인 - file, stat

bandit1@bandit:~$ file ./-

./-: ASCII text

bandit1@bandit:~$ stat -

  File: -
  Size: 0               Blocks: 0          IO Block: 1024   character special file
Device: 19h/25d Inode: 51          Links: 1     Device type: 88,30
Access: (0620/crw--w----)  Uid: (11001/ bandit1)   Gid: (    5/     tty)
Access: 2023-08-22 23:22:48.466270295 +0000
Modify: 2023-08-22 23:22:48.466270295 +0000
Change: 2023-08-22 23:18:43.466270295 +0000
  • **file <파일위치>/<파일명>**은 지정된 파일의 종류(타입)을 확인하는 명령어이다.
  • **stat <파일명>** 디렉터리나 파일의 상세 정보를 표시하는 명령어로, ls 명령어로는 표시되지 않는 정보를 확인할 때 쓰인다.
  • **stat <파일명>** 으로 알 수 있는 내용
    • File: 파일명
    • Size: 파일크기(바이트)
    • Blocks: 하드디스크에 파일 저장하기 위해 할당된 블럭 수
    • IO Block: 할당된 블럭 크기(바이트)
    • File type: 파일 유형 : Regular files, special files, directories, 또는 symbolic links.
    • Device: 디바이스 번호(16진수값)
    • Inode: 파일 Inode 값
    • Links: 파일 링크 수
    • Access: 접근 퍼미션
    • Uid/Gid : 소유자와 그룹 정보
    • Access: 최종 파일 접근 시간
    • Modify: 최종 파일 수정 시간
    • Change: 속성 또는 컨텐트 최종 변경 시간
    • Birth: 파일 생성 시간 (파일 시스템에 따라 -로 나옴)

3. - 읽기

bandit1@bandit:~$ cat ./-

파일 이름이 "-"인 경우에는 명령어가 이를 옵션으로 해석하지 않도록 주의해야 한다.

cat 명령어로 현재 위치의 - 파일을 읽어서 비밀번호를 얻어냈다.

4. bandit2 계정에 로그인

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

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

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

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

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

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

Welcome to OverTheWire!

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