1. Bandit18 목표
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.
Commands you may need to solve this level
ssh, ls, cat
2. Bandit18 구현
# 비밀번호 root 입력 접속
ssh -oStrictHostKeyChecking=no root@localhost -p 2220
chown -R root:root /home/bandit18/.[!.]*
echo echo 'Byebye !' >> /home/bandit18/.bashrc
echo exit 0 >> /home/bandit18/.bashrc
echo IueksS7Ubh8G3DCwVzrTd8rAVOwq3M5x > /home/bandit18/readme
useradd bandit19 && echo -e "IueksS7Ubh8G3DCwVzrTd8rAVOwq3M5x\nIueksS7Ubh8G3DCwVzrTd8rAVOwq3M5x" | passwd bandit19
chmod 640 /home/bandit18/readme /home/bandit18/.bashrc
chown bandit19:bandit18 /home/bandit18/readme /home/bandit18/.bashrc
chmod 755 /home/bandit19
chown root:root /home/bandit19
3. Bandit18 문제풀의
# bandit18 로 설정한 패스워드를 입력하여 접속한다.
# x2gLTTjFwMOhQ8oWNbMN362QKxfRqGlO
ssh -oStrictHostKeyChecking=no bandit18@localhost -p 2220
# case $- in
# *i*) ;;
# *) return;;
# esac
# 이전 레벨의 문제에 접속해서 .bashrc 를 확인하면 위와 같은 구절이 존재한다
# 인터렉티브 모드일 경우는 .bashrc 코드를 이어서 진행하고
# 비인터렉티브 모드일 경우에는 .bashrc 코드진행을 종료한다는 의미이다.
# 비인터렉티브 모드는 ssh에서 직접 접속이 아닌 옵션을 주었을 경우 비인터렉티브 모드로 실행된다.
# bandit17과 bandit18을 bashrc 파일 비교
ssh -oStrictHostKeyChecking=no -p 2220 bandit18@localhost "diff /home/bandit17/.bashrc /home/bandit18/.bashrc"
# 접속 쉘을 지정하여 sh로 로그인
ssh -oStrictHostKeyChecking=no -p 2220 bandit18@localhost -t /bin/sh
'Wargame > Bandit' 카테고리의 다른 글
[ Docker ] Bandit Wargame 만들기 - 20번 문제 ( 21 / 33 ) (0) | 2024.06.19 |
---|---|
[ Docker ] Bandit Wargame 만들기 - 19번 문제 ( 20 / 33 ) (0) | 2024.06.19 |
[ Docker ] Bandit Wargame 만들기 - 17번 문제 ( 18 / 33 ) (0) | 2024.06.18 |
[ Docker ] Bandit Wargame 만들기 - 16번 문제 ( 17 / 33 ) (0) | 2024.06.13 |
[ Docker ] Bandit Wargame 만들기 - 15번 문제 ( 16 / 33 ) (0) | 2024.06.13 |