1. Bandit0 목표
The goal of this level is for you to log into the game using SSH.
The host to which you need to connect is bandit.labs.overthewire.org, on port 2220.
The username is bandit0 and the password is bandit0.
Once logged in, go to the Level 1 page to find out how to beat Level 1.
The password for the next level is stored in a file called readme located
in the home directory. Use this password to log into bandit1 using SSH.
Whenever you find a password for a level, use SSH (on port 2220) to log
into that level and continue the game.
Commands you may need to solve this level
ssh, ls , cd , cat , file , du , find
2. Bandit0 구현
# 비밀번호 root 입력 접속
ssh -oStrictHostKeyChecking=no root@localhost -p 2220
useradd bandit0
echo -e "bandit0\nbandit0" | passwd bandit0
# 현재 폴더에 대한 소유자 및 그룹이 bandit0 일 경우
# bandit0로 접속한 유저가 홈 폴더에 파일을 생성할 수 있다.
# 그렇기 때문에 홈 폴더 내부 모든 파일의 소유자 및 그룹을 root로 변경하여 준다.
chown -R root:root /home/bandit0/.[!.]*
# 다음 패스워드가 담긴 readme file을 생성한다.
echo 'boJ9jbbUNNfktd78OOpsqOltutMc3MY1' > /home/bandit0/readme
# bandit1 유저를 생성하여 준다.
useradd bandit1 && echo -e "boJ9jbbUNNfktd78OOpsqOltutMc3MY1\nboJ9jbbUNNfktd78OOpsqOltutMc3MY1" | passwd bandit1
# readme 파일을 소유자는 읽고 쓰기 그룹은 읽기만 가능하도록 설정한다.
chmod 640 /home/bandit0/readme
# readme 파일의 소유자를 bandit1 로 그룹은 bandit0로 변경하여 준다.
# bandit1 소유자는 쓰기 권한이 있어 파일을 변경할 수 있다고 생각할 수 있으나
# bandit1 소유자는 bandit0 폴더의 쓰기 권한이 없어 수정할 수 없다.
# 모든 권한에 쓰기 권한이 없을경우 root 사용자도 수정할 수 없어 사용한 방법이다.
chown bandit1:bandit0 /home/bandit0/readme
# root 사용자 이외에도 bandit0와 bandit1 폴더는 읽기, 실행(접근) 권한은 있어야 하므로
# bandit0, bandit1 에게 실행 및 접근 권한을 준다.
chmod 755 /home/bandit0 /home/bandit1
exit
3. Bandit0 문제풀의
# 비밀번호 : bandit0
ssh bandit0@localhost -p 2220
# 다음 문제 비밀번호를 확인
# boJ9jbbUNNfktd78OOpsqOltutMc3MY1
cat readme
'Wargame > Bandit' 카테고리의 다른 글
[ Docker ] Bandit Wargame 만들기 - 4번 문제 ( 6 / 33 ) (0) | 2024.06.04 |
---|---|
[ Docker ] Bandit Wargame 만들기 - 3번 문제 ( 5 / 33 ) (0) | 2024.06.04 |
[ Docker ] Bandit Wargame 만들기 - 2번 문제 ( 4 / 33 ) (1) | 2024.06.04 |
[ Docker ] Bandit Wargame 만들기 - 1번 문제 ( 3 / 33 ) (0) | 2024.06.04 |
[ Docker ] Bandit Wargame 만들기 ( 1 / 33 ) (0) | 2021.11.26 |