Skip to content

Latest commit

 

History

History
64 lines (41 loc) · 3.28 KB

211020.md

File metadata and controls

64 lines (41 loc) · 3.28 KB

Day 19

OverTheWire WriteUp

Level25 -> Level26

Level Goal

Logging in to bandit26 from bandit25 should be fairly easy… The shell for user bandit26 is not /bin/bash, but something else. Find out what it is, how it works and how to break out of it.

bandit26은 bash 쉘이 아닌 다른 쉘을 쓰고 있다.

grep bandit26 /etc/passwd를 이용하면 현재 bandit26이 무슨 쉘을 사용하고 있는지 확인할 수 있다. 보면 /usr/bin/showtext를 쉘로 사용하고 있고 출력해보면

#!/bin/sh

export TERM=linux

more ~/text.txt
exit 0

more을 통해 ~/text.txt를 출력하고 exit 0로 연결을 끊는 것을 확인했다.

풀기 위해 필요한 커맨드 목록에 more과 vi가 있어서 찾아봤는데 more에서 v를 누르면 vi 편집기가 동작한다고 한다.

하지만 한 화면 안에 출력이 된다면 v를 누르기도 전에 연결이 끊기므로 창을 좀 작게하고 ssh -i bandit26.sshkey bandit26@localhost로 연결을 하면 한 화면 안에 출력이 되지 않아 멈추게 되고 v를 눌러주면 vi 편집기로 들어올 수 있게 된다.

그 이후에는 vi에서 :e [파일명]을 하면 해당 파일을 열 수가 있다.

이를 이용해서 :e /etc/bandit_pass/bandit26을 입력해 주면 password를 얻을 수 있다.

Level26 -> Level27

Level Goal

Good job getting a shell! Now hurry and grab the password for bandit27!

일단 저번에 이어서 vi에서 :set shell=/bin/bash를 입력하면 쉘을 bash쉘로 설정하고 :sh를 입력하면 쉘로 돌아갈 수 있다.

이 상태에서 ls를 쳐보니까 bandit27-do가 있었는데 이전에 있었던 프로그램과 똑같이 ./bandit27-do cat /etc/bandit_pass/bandit27을 입력해주면 된다.

Level27 -> Level28

Level Goal

There is a git repository at ssh://bandit27-git@localhost/home/bandit27-git/repo. 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.

이번에는 그냥 git clone 명령어로 가져오기만 하는 되는 문제였다.

git clone ssh:~

Level28 -> Level29

Level Goal

There is a git repository at ssh://bandit28-git@localhost/home/bandit28-git/repo. The password for the user bandit28-git is the same as for the user bandit28.

Clone the repository and find the password for the next level.

이번에도 git clone으로 가져와서 readme를 보니까 password부분이 x로 되어 있었다.

그래서 아마 이전 기록을 보는 것이라 판단하고 git log 명령어에 -p옵션을 사용했다. git log는 커밋 히스토리를 보여주고 -p옵션은 각 커밋에서 달라진 점을 보여준다.

Level29 -> Level30

Level Goal

There is a git repository at ssh://bandit29-git@localhost/home/bandit29-git/repo. The password for the user bandit29-git is the same as for the user bandit29.

Clone the repository and find the password for the next level.

git clone으로 가져와서 readme 확인결과 password가 없었고 커밋 히스토리까지 확인했는데 password는 없었다.

그래서 git branch -a로 branch를 확인해보니까 dev, HEAD, master, sploits-dev라는 branch가 있었다. 일단 dev라는 branch로 git checkout dev 명령어로 이동했다. 그 다음 README를 출력해보니 password가 적혀 있었다.