
The password for the next level is stored in /etc/bandit_pass/bandit14 and can only be read by user bandit14. For this level, you don’t get the next password, but you get a private SSH key that can be used to log into the next level. Note: localhost is a hostname that refers to the machine you are working on.
다음 레벨의 패스워드는 /etc/bandit_pass/bandit14에 있으며 bandit14 유저만 읽을 수 있다. 이 레벨에서는 다음 패스워드를 얻을 수 없다. 그러나 다음 레벨에 접속할 수 있는 private SSH key를 얻어야 한다. 노트: localhost는 당신이 작업하고 있는 장비의 호스트 이름을 의미한다.
ssh, telnet, nc, openssl, s_client, nmap
bandit13@bandit:~$ ls -al /etc/bandit_pass/ | grep bandit14
-r-------- 1 bandit14 bandit14 33 Oct 5 2023 bandit14
bandit14 파일은 bandit14 계정으로 접속했을 때만 읽을 수 있다.
키 페어(공개 키, 개인 키) 인증 방식을 통해 SSH 연결이 가능하다. 키 페어 인증 방식은 기본적으로 클라이언트에서 공개 키와 개인 키를, 호스트 서버에서 공개 키를 가지고 있어야 한다(서버:.ssh/authorized_keys 파일).
서버에 등록된 클라이언트의 공개 키는 클라이언트의 신원을 확인하는 데 사용된다. 서버가 가지고 있는 비밀 키(클라이언트의 개인 키와 다름)와 클라이언트가 가지고 있는 개인 키로 세션 키를 독립적으로 생성한다(Diffli-Hellman 키 교환 프로토콜 - 각자의 키와 교환한 공유 값을 사용해 동일한 대칭 키를 생성). 이후 세션 키를 통해 암호화, 복호화하여 통신한다.
bandit13@bandit:~$ id
uid=11013(bandit13) gid=11013(bandit13) groups=11013(bandit13)
bandit13@bandit:~$ ls -al
total 24
drwxr-xr-x 2 root root 4096 Oct 5 2023 .
drwxr-xr-x 70 root root 4096 Oct 5 2023 ..
-rw-r--r-- 1 root root 220 Jan 6 2022 .bash_logout
-rw-r--r-- 1 root root 3771 Jan 6 2022 .bashrc
-rw-r--r-- 1 root root 807 Jan 6 2022 .profile
-rw-r----- 1 bandit14 bandit13 1679 Oct 5 2023 sshkey.private
bandit13@bandit:~$ file sshkey.private
sshkey.private: PEM RSA private key
sshkey.private 파일은 REM RSA private key 파일이다. sftp로 키 파일을 로컬 머신에 다운로드 받고 2220번 포트를 통해 bandit14 계정으로 접속해도 무방하나 ssh 기본 포트인 22번 포트가 열려 있다면 바로 접속할 수 있을 것 같다.
bandit13@bandit:~$ nc -zv 127.0.0.1 22
Connection to 127.0.0.1 22 port [tcp/ssh] succeeded!
bandit13@bandit:~$ ssh -i ./sshkey.private bandit14@localhost
The authenticity of host 'localhost (127.0.0.1)' can't be established.
!!! You are trying to log into this SSH server on port 22, which is not intended.
안된다... 출력 메세지를 확인해보니 이런 식의 접근을 막아둔 것으로 보인다.
bandit13@bandit:~$ ssh -i ./sshkey.private bandit14@localhost -p 2220
!!! You are trying to log into this SSH server with a password on port 2220 from localhost.
!!! Connecting from localhost is blocked to conserve resources.
!!! Please log out and log in again.
bandit14@bandit:~$ cat /etc/bandit_pass/bandit14