본문 바로가기

Wargame/Bandit

[ Docker ] Bandit Wargame 만들기 - 27번 문제 ( 28 / 33 )

1. Bandit27 목표

There is a git repository at ssh://bandit27-git@localhost/home/bandit27-git/repo via the port 2220.
The password for the user bandit27-git is the same as for the user bandit27.
Clone the repository and find the password for the next level.

Commands you may need to solve this level
git

 

2. Bandit27 구현

# 비밀번호 root 입력 접속
ssh -oStrictHostKeyChecking=no root@localhost -p 2220

useradd bandit28 && echo -e "Yz9IpL0sBcCeuG7m9uQFt8ZNpS4HZRcN\nYz9IpL0sBcCeuG7m9uQFt8ZNpS4HZRcN" | passwd bandit28

chmod 755 /home/bandit28

chown root:root /home/bandit28

chown -R root:root /home/bandit28/.[!.]*

echo Yz9IpL0sBcCeuG7m9uQFt8ZNpS4HZRcN > /etc/bandit_pass/bandit28

chown bandit28:bandit28 /etc/bandit_pass/bandit28

chmod 400 /etc/bandit_pass/bandit28

useradd bandit27-git && echo -e "upsNCc7vzaRDx6oZC6GiR6ERwe1MowGB\nupsNCc7vzaRDx6oZC6GiR6ERwe1MowGB" | passwd bandit27-git

chmod 750 /home/bandit27-git

mkdir -p /home/bandit27-git/repo

chmod 775 /home/bandit27-git/repo

chown -R bandit27-git:bandit27-git /home/bandit27-git/repo

git init --bare /home/bandit27-git/repo

chsh -s /usr/bin/git-shell bandit27-git

TMP_DIR=$(mktemp -d)

cd $TMP_DIR

# upsNCc7vzaRDx6oZC6GiR6ERwe1MowGB
# 패스워드 입력
GIT_SSH_COMMAND='ssh -o StrictHostKeyChecking=no' git clone ssh://bandit27-git@localhost:2220/home/bandit27-git/repo

cd $TMP_DIR/repo

echo The password to the next level is: $(cat /etc/bandit_pass/bandit28) > $TMP_DIR/repo/README

chmod 664 $TMP_DIR/repo/README

chown bandit27:bandit27 $TMP_DIR/repo/README

git add README

git config user.email "noone@overthewire.org"

git config user.name "Ben Dover"

git commit -m "initial commit of README"

# upsNCc7vzaRDx6oZC6GiR6ERwe1MowGB
# 패스워드 입력
git push

chown -R bandit27:bandit27 /home/bandit27-git/repo

 

3. Bandit27 문제풀의

# bandit27 로 설정한 패스워드를 입력하여 접속한다.
# upsNCc7vzaRDx6oZC6GiR6ERwe1MowGB
ssh -oStrictHostKeyChecking=no bandit27@localhost -p 2220

TMP_DIR=$(mktemp -d)

cd $TMP_DIR

# upsNCc7vzaRDx6oZC6GiR6ERwe1MowGB
# 패스워드 입력
GIT_SSH_COMMAND='ssh -o StrictHostKeyChecking=no' git clone ssh://bandit27-git@localhost:2220/home/bandit27-git/repo

# 패스워드 확인
cat $TMP_DIR/repo/README | awk '{ print $8 }'