본문 바로가기
Security/OverTheWire

Bandit Level 25 → Level 26 (more)

by curious week 2025. 12. 2.

문제

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.

NOTE: if you’re a Windows user and typically use Powershell to ssh into bandit: Powershell is known to cause issues with the intended solution to this level. You should use command prompt instead.

## 문제 요구사항
bandit26의 로그인 쉘이 bash가 아니다
진짜 쉘(bash/sh)을 따야 한다

## 내가 사용한 명령어
ssh bandit25@bandit.labs.overthewire.org -p 2220

cat /etc/passwd | grep bandit26
cat bandit26.sshkey
키 복사 후
nano bandit.key
chmod 600 bandit.key

터미널 최대로 축소
ssh -i bandit.key bandit25@bandit.labs.overthewire.org -p 2220

v
: 
:set shell=/bin/bash
:shell

cat /etc/bandit_pass/bandit26

## 왜 이 명령어를 골랐는가
// 시스템의 모든 사용자 계정 정보 출력
cat /etc/passwd         
// 그 중 bandit26만 골라서 출력
| grep bandit26         

위 명령어를 이용하면 아래와 같은 쉘 내용을 확인할 수 있다.
#!/bin/sh
more ~/text.txt
exit 0

more나 less는 단순히 텍스트만 보여주는 도구가 아니라, 내부에서 몇 가지 단축키를 지원함.
v로 vim을 열고
:로 명령어 입력

## 어떤 시행착오를 겪었는가
ssh -i bandit26.sshkey bandit26@localhost 같이 
\bandit25에서 로컬로스트로 진입하려고 했지만 계속 실패했다.