The password for the next level is stored in a file readme in the homedirectory. Unfortunately, someone has modified .bashrc to log you out when you log in with SSH.
비밀번호는 홈 디렉토리에서 readme 파일에 저장되어 있다고 합니다.
근데, 누군가가 .bashrc(bash 쉘의 설정 파일 / 쉘 실행 시 자동으로 스크립트 동작함)을 수정하여 SSH로 연결 시도 할 때마다 로그아웃 된다고 하네요 ㅠㅠ
어떻게 해야 할까요...?
일단, 어떤 현상인지 연결 시도해 보겠습니다.
띠용! 연결 하자마자 바로 'Byebye !'라는 멘트와 함께 로그아웃 되는군요!
이 문제를 해결하기 위해 여러 방법이 있습니다.
SSH 로그인 시 특정 명령어를 입력하면 .bashrc이 실행되지 않고 readme를 읽어볼 수 있습니다.
moonsookang@MoonSooui-noteubug Downloads % ssh bandit18@bandit.labs.overthewire.org -p 2220 cat readme
_ _ _ _
| |__ __ _ _ __ __| (_) |_
| '_ \ / _` | '_ \ / _` | | __|
| |_) | (_| | | | | (_| | | |_
|_.__/ \__,_|_| |_|\__,_|_|\__|
This is an OverTheWire game server.
More information on http://www.overthewire.org/wargames
bandit18@bandit.labs.overthewire.org's password:
cGWpMaKXVwDUNgPAVJbWYuGHVn9zl3j8
위 구문을 통해서 비밀번호를 얻을 수 있습니다!
✅ ssh bandit18@bandit.labs.overthewire.org -p 2220 "cat readme"
SSH에서는 명령어를 위와 같이 직업 실행하면, 원격으로 명령어를 실행하고 자동으로 종료하는 기능이 있음
✅ 리눅스에서 쉘은 사용자와 운영체제 사이의 인터페이스입니다.
즉, 사용자가 명령어를 입력하면 해석하고 실행하지요!
이러한 쉘에도 여러 종류가 있습니다.
- bash
- sh
- zsh
- ksh
...
✅ 여기서 Bash 쉘은 리눅스에서 가장 많이 사용되는 쉘입니다.
기본 sh에서 업그레이드 된 것으로 기능도 많이 추가됐지요!
위를 활용해 SSH 연결 시 Bash가 아닌 기본 sh을 실행하여 문제를 해결해 볼까요?
moonsookang@MoonSooui-noteubug Downloads % ssh bandit18@bandit.labs.overthewire.org -p 2220 sh
_ _ _ _
| |__ __ _ _ __ __| (_) |_
| '_ \ / _` | '_ \ / _` | | __|
| |_) | (_| | | | | (_| | | |_
|_.__/ \__,_|_| |_|\__,_|_|\__|
This is an OverTheWire game server.
More information on http://www.overthewire.org/wargames
bandit18@bandit.labs.overthewire.org's password:
이 명령어를 실행하면 패스워드를 입력해도 화면에서 반응이 없지요??
이미 기본 sh이 실행된 상태라서 그렇습니다!
간단한 명령어 몇개를 입력해 볼까요?
moonsookang@MoonSooui-noteubug Downloads % ssh bandit18@bandit.labs.overthewire.org -p 2220 sh
_ _ _ _
| |__ __ _ _ __ __| (_) |_
| '_ \ / _` | '_ \ / _` | | __|
| |_) | (_| | | | | (_| | | |_
|_.__/ \__,_|_| |_|\__,_|_|\__|
This is an OverTheWire game server.
More information on http://www.overthewire.org/wargames
bandit18@bandit.labs.overthewire.org's password:
ls
readme
pwd
/home/bandit18
id
uid=11018(bandit18) gid=11018(bandit18) groups=11018(bandit18)
위와 같이 잘 실행 됩니다 :)
이를 이용하여 비밀번호 파일을 읽으면 되겠군요!!