본문 바로가기

wargame/bandit

Level 25 → Level 26

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.
bandit25에서 bandit26에 로그인하는 것은 꽤나 쉬울 것이다... 사용자 bandit26을 위한 쉘은 /bin/bash가 아니라 다른 것이다. 무엇인지 찾고 어떻게 작동하는지 어떻게 부수는지 발견하여라

Code

bandit25@bandit:~$ ls
bandit26.sshkey
bandit25@bandit:~$ cat bandit26.sshkey
-----BEGIN RSA PRIVATE KEY-----
#개인키 정보
bandit25@bandit:~$ cd /etc/bandit_pass
bandit25@bandit:/etc/bandit_pass$ cat bandit26
cat: bandit26: Permission denied
bandit25@bandit:/etc/bandit_pass$ cd ~
bandit25@bandit:~$ ssh -i ~/bandit26.sshkey bandit26@localhost 'cat /etc/bandit_pass/bandit26' # 이전에 18 > 19에서 쓴 방법을 다시 사용해보았다
Could not create directory '/home/bandit25/.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/bandit25/.ssh/known_hosts).
#이것저것 해봄
bandit25@bandit:~$ cat /etc/passwd
#쉘에 관하여 출력됨
bandit26:x:11026:11026:bandit level 26:/home/bandit26:/usr/bin/showtext
#쉘에 관하여 마저 출력
bandit25@bandit:~$ man showtext # manual에 없었다
No manual entry for showtext
See 'man 7 undocumented' for help when manual pages are not available.
bandit25@bandit:~$ cat /usr/bin/showtext # 위에서 주소를 알 수 있어서 경로를 가지고 찾아보았다
#!/bin/sh

export TERM=linux

more ~/text.txt # more 명령어를 사용하여 text.txt를 읽는다
exit 0

bandit25@bandit:~$ ssh -i ~/bandit26.sshkey bandit26@localhost
Could not create directory '/home/bandit25/.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
# 화면 아래에 more이 뜨는 순간에 v를 눌러 편집기를 사용할 수 있다
# :r 명령어를 이용하여 비밀번호를 출력하자

처음에는 bandit25에 있는 bandit26에 대한 정보를 얻고 나서 전처럼 개인키를 사용하거나 ssh 원격조정하는 방법을 이용하면 될 줄 알았는데 둘 다 실패하였다. 이걸저것 구굴링하다가 /etc/passwd 파일의 존재를 깨닫고 찾아보니 showtext라는 쉘을 씀을 알 수 있었다. manual에 없어서 파일에 대해 알아보려고 cat 명령어를 사용하니 more 명령어를 사용하여 text.txt를 읽는 쉘임을 알 수 있었다. 이 다음 구글링 결과 more 명령어에 있는 -v 옵션을 사용하여 해결할 수 있음을 알았다.
+) showtext   more command

#more


'wargame > bandit' 카테고리의 다른 글

Level 24 → Level 25  (0) 2019.02.28
Level 23 → Level 24  (0) 2019.02.28
Level 22 → Level 23  (0) 2019.02.28
Level 21 → Level 22  (0) 2019.02.28
Level 20 → Level 21  (0) 2019.02.28