Dukbong

[Linux 공부] Bandit wargames 26~27 단계 more & setuid & set 본문

Linux

[Linux 공부] Bandit wargames 26~27 단계 more & setuid & set

dukbong_dev 2025. 5. 20. 14:01
반응형
 

OverTheWire: Level Goal

We're hackers, and we are good-looking. We are the 1%. <!-- Please read and accept the Rules! --> Level Goal Good job getting a shell! Now hurry and grab the password for bandit27! Commands you may need to solve this level ls

overthewire.org

26 ~ 27 단계 문제는 이전 단계에서 공부했던 more 명령어와 setuid 명령어를 이해하고 있다면 풀 수있는 문제입니다.

bandit26은 로그인 쉘이 /bin/bash가 아닌것을 까먹는다면 애먹을 수 있습니다.

1. SSH 접속

26 ~ 27 단계 접속 비밀번호는 s0773xxkk0MXfdqOfPRVr9L3jJBUOgCZ 입니다.

ssh bandit26@bandit.labs.overthewire.org -p 2220

2. more & setuid & set

# more 실행화면

v # vi 로 전환

:set shell=/bin/bash # vim 내부에서 :!, :sh 등의 명령을 실행할 때 사용할 외부 셸을 /bin/bash로 지정

:sh # vi를 일시 중단 후 설정된 쉘에서 임시로 명령을 실행할 수 있는 쉘 세션으로 들어가는 명령
# exit 하게 되면 다시 vi로 돌아옵니다.

ls -al

# 응답
total 44
drwxr-xr-x  3 root     root      4096 Apr 10 14:23 .
drwxr-xr-x 70 root     root      4096 Apr 10 14:24 ..
-rwsr-x---  1 bandit27 bandit26 14884 Apr 10 14:23 bandit27-do
-rw-r--r--  1 root     root       220 Mar 31  2024 .bash_logout
-rw-r--r--  1 root     root      3771 Mar 31  2024 .bashrc
-rw-r--r--  1 root     root       807 Mar 31  2024 .profile
drwxr-xr-x  2 root     root      4096 Apr 10 14:23 .ssh
-rw-r-----  1 bandit26 bandit26   258 Apr 10 14:23 text.txt

file bandit27-do

# 응답
bandit27-do: setuid ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, BuildID[sha1]=35d353cf6d732f515a73f50ed205265fe1e68f90, for GNU/Linux 3.2.0, not stripped

./bandit27-do cat /etc/bandit_pass/bandit27

# 응답
upsNCc7vzaRDx6oZC6GiR6ERwe1MowGB
반응형
Comments