WAR GAME/Bandit

[OverTheWire: Bandit] level31 -> level32

jir4vvit 2020. 3. 10. 17:02

사용 툴: cygwin

 

1) 문제

level31 -> level32 문제

문제가 계속 똑같다.

 

ssh://bandit31-git@localhost/home/bandit31-git/repo에 git 저장소가 있다. 사용자 bandit31-git의 암호는 사용자 bandit31과 동일하다.

저장소를 복제하고 다음 수준의 암호를 찾아라.

 

 

2) 문제풀이

/tmp 밑에 새로운 폴더를 만들고 저장소를 복제하였다.

bandit31@bandit:/tmp/mylevel31$ git clone ssh://bandit31-git@localhost/home/bandit31-git/repo

계속 똑같은거 했으니까 핵심적인 명령어만 표시하겠다..

 

bandit31@bandit:/tmp/mylevel31/repo$ 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: master

bandit31@bandit:/tmp/mylevel31/repo$

repo 디렉터리 밑 README.md 파일을 읽었다.

 

원격 저장소에 파일을 push하라고 한다.

파일 이름은 key.txt이고 May I come in? 이라는 문자가 저장되어있다고 한다.

branch는 master 브랜치이다.

 

지금 현재 내 브랜치가 뭔지 살펴봐야겠다.

bandit31@bandit:/tmp/mylevel31/repo$ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
bandit31@bandit:/tmp/mylevel31/repo$

난 지금 master 브랜치이다. 지금 바로 key.txt를 만들어야겠다.

 

bandit31@bandit:/tmp/mylevel31/repo$ echo "May I come in?" > key.txt
bandit31@bandit:/tmp/mylevel31/repo$ ls -al
total 24
drwxr-sr-x 3 bandit31 root 4096 Mar 10 08:55 .
drwxr-sr-x 3 bandit31 root 4096 Mar 10 08:48 ..
drwxr-sr-x 8 bandit31 root 4096 Mar 10 08:49 .git
-rw-r--r-- 1 bandit31 root    6 Mar 10 08:49 .gitignore
-rw-r--r-- 1 bandit31 root   15 Mar 10 08:55 key.txt
-rw-r--r-- 1 bandit31 root  147 Mar 10 08:49 README.md
bandit31@bandit:/tmp/mylevel31/repo$

바로 만들었다.

vi 에디터로도 만들 수 있지만 난 편하게 저렇게 만들었다.

 

이제 push를 해줘야한다.

 

git 저장소에 자료를 추가 및 업로드 하기 위해서는, 일반적으로 add, commit, push의 순서를 따른다.

stage에 add를 해준뒤 commit으로 일시저장(?)을 하고 push하면 그제서야 저장소에 저장되는 느낌이다.

 

bandit31@bandit:/tmp/mylevel31/repo$ git add -f key.txt
bandit31@bandit:/tmp/mylevel31/repo$ git commit -m "key added"
[master 4a0068d] key added
 1 file changed, 1 insertion(+)
 create mode 100644 key.txt
bandit31@bandit:/tmp/mylevel31/repo$

commit까지 해줬다.

저기 key added는 다른 문구로 바꿔도 된다.

 

bandit31@bandit:/tmp/mylevel31/repo$ git log
commit 4a0068d87318a237a1acda9e6e99efbb026540de
Author: bandit31 <bandit31@overthewire.org>
Date:   Tue Mar 10 08:57:48 2020 +0100

    key added

commit df6c5eb91615c6dc9c99f99ca5fd79addfe62594
Author: Ben Dover <noone@overthewire.org>
Date:   Tue Oct 16 14:00:46 2018 +0200

    initial commit
bandit31@bandit:/tmp/mylevel31/repo$

저 문구는 git log했을 때 보다시피 저기 ... 설명란에 적히는 문구이다.

 

마지막으로 push까지 해주겠다.

bandit31@bandit:/tmp/mylevel31/repo$ git push origin master
Could not create directory '/home/bandit31/.ssh'.
The authenticity of host 'localhost (127.0.0.1)' can't be established.
ECDSA key fingerprint is SHA256:98UL0ZWr85496EtCRkKlo20X3OPnyPSB5tB5RPbhczc.
Are you sure you want to continue connecting (yes/no)? yes
Failed to add the host to the list of known hosts (/home/bandit31/.ssh/known_hosts).
This is a OverTheWire game server. More information on http://www.overthewire.org/wargames

bandit31-git@localhost's password:
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 322 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 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: 56a9bf19c63d650ce78e6ec0354ee45e
remote:
remote: .oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.
remote:
To ssh://localhost/home/bandit31-git/repo
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'ssh://bandit31-git@localhost/home/bandit31-git/repo'
bandit31@bandit:/tmp/mylevel31/repo$

bandit31 패스워드도 제출하니까 저기 Well done! 하면서 다음 레벨의 패스워드를 주고 있다.

 

bandit31@bandit:/tmp/mylevel31/repo$ ssh bandit32@localhost

이런식으로 쉘의 모양이 조금 다르지만..? 다음 레벨에 온 것 같다!