Bandit Wargame 풀이 기록입니다.
1. 문제 목표 및 접속 정보
목표
Git 저장소에 파일을 추가하고 커밋 메시지를 정확히 작성한 뒤,이를 원격 저장소로 push하여 다음 레벨 비밀번호를 획득한다.
이 과정에서 쉘이 특수 문자를 어떻게 해석하는지 이해하고,의도한 문자열이 그대로 전달되도록 처리해야 한다.접속 정보
- Host:
bandit.labs.overthewire.org - Port:
2220 - User:
bandit31 - Password:
fb5S2xb7bRyFmAvQYQGEqsbhVyJqhnDy
- Host:
2. 풀이 과정
Git 저장소 클론
로컬 환경에서 Git 저장소를 클론했다.
git clone ssh://bandit31-git@bandit.labs.overthewire.org:2220/home/bandit31-git/repo
클론 후 저장소로 이동했다.
cd repo
ls
README.mdREADME 확인
❯ cat README.md
This time your task is to push a file to the remote repository.
Details:
File name: key.txt
Content: 'May I come in?'
Branch: masterGit 커밋 이력 확인
❯ nano key.txt
May I come in?key.txt를 바로 만들어보았다
원격 브랜치 확인
git branch -r
origin/HEAD -> origin/master
origin/dev
origin/master
origin/sploits-dev기본 브랜치 외에 dev, sploits-dev 브랜치가 존재했다.
dev 브랜치로 이동
먼저 dev 브랜치로 이동했다.
git checkout dev
branch 'dev' set up to track 'origin/dev'.
Switched to a new branch 'dev'파일 구조를 확인했다.
ls
code README.mddev 브랜치 README 확인
❯ git push origin master
_ _ _ _
| |__ __ _ _ __ __| (_) |_
| '_ \ / _` | '_ \ / _` | | __|
| |_) | (_| | | | | (_| | | |_
|_.__/ \__,_|_| |_|\__,_|_|\__|
This is an OverTheWire game server.
More information on http://www.overthewire.org/wargames
backend: gibson-1
bandit31-git@bandit.labs.overthewire.org's password:
Permission denied, please try again.
bandit31-git@bandit.labs.overthewire.org's password:
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 8 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 321 bytes | 321.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
remote: ### Attempting to validate files... ####
remote:
remote: .oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.
remote:
remote: Well done! Here is the password for the next level:
remote: 3O9RfhqyAlVBEZpVb6LYStshZoqoSx5K
remote:
remote: .oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.
remote:
To ssh://bandit.labs.overthewire.org:2220/home/bandit31-git/repo
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'ssh://bandit.labs.overthewire.org:2220/home/bandit31-git/repo'dev 브랜치의 README 파일에서
다음 레벨 비밀번호를 확인할 수 있었다.
3. Level [32] 비밀번호 (Flag) 획득
기본 브랜치가 아닌 개발용 브랜치(dev) 에 남아 있던
README 파일을 확인하여 플래그를 획득했다.
[3O9RfhqyAlVBEZpVb6LYStshZoqoSx5K]
4. 핵심 명령어 및 개념
git branch -r- 원격 저장소의 브랜치 목록을 확인
- 이번 레벨의 핵심 명령어
git checkout <branch>- 다른 브랜치로 이동
- 브랜치마다 파일 내용이 다를 수 있다
- Git 브랜치와 보안
- 메인 브랜치에서 지웠다고 끝이 아니다
- 개발 브랜치에 민감한 정보가 남아 있을 수 있다
한 줄 정리
Git에서는 브랜치도 보안 관리 대상이다.
사용하지 않는 개발 브랜치 하나가 정보 유출의 원인이 될 수 있다.