-
[Linux 공부] Bandit wargames 19~20 단계 setuidLinux 2025. 5. 19. 01:39728x90반응형
OverTheWire: Level Goal
We're hackers, and we are good-looking. We are the 1%. <!-- Please read and accept the Rules! --> Level Goal To gain access to the next level, you should use the setuid binary in the homedirectory. Execute it without arguments to find out how to use it. Th
overthewire.org
19 ~ 20 단계는 setuid의 기초적인 이해가 되었는지 문제 입니다.
setuid는 실행 파일에 부여할 수 있는 특별한 종류의 권한이며 이 권한이 설정된 파일을 일반 사용자가 실행하면 그 파일을 실행하는 사용자의 실제 권한이 아닌 파일의 소유자의 권한으로 일시적으로 실행됩니다.
1. SSH 접속
19 ~ 20 단계 접속 비밀번호는 cGWpMaKXVwDUNgPAVJbWYuGHVn9zl3j8 입니다.
ssh bandit19@bandit.labs.overthewire.org -p 2220
2. setuid 파일로 읽기
setuid 파일을 실행하여 특정 경로에 있는 파일을 읽을 수 있습니다.
ls 결과 bandit20-do file bandit20-do 결과 bandit20-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 ./bandit20-do id 결과 uid=11019(bandit19) gid=11019(bandit19) euid=11020(bandit20) groups=11019(bandit19) 해석 : 이 실행파일을 실행하면 bandit20 의 권한을 사용한다. ./bandit20-do ls /etc/bandit_pass 결과 bandit0 bandit10 bandit12 bandit14 bandit16 bandit18 bandit20 bandit21 ... ./bandit20-do cat /etc/bandit_pass/bandit20 결과 0qXahG8ZjOVMN9Ghs7iOWsCfZyXOUbYO
다른 파일은 못읽는건가 궁금해서 찾아보니 아래와 같습니다.
./bandit20-do cat /etc/bandit_pass/bandit21 결과 cat: /etc/bandit_pass/bandit21: Permission denied ./bandit20-do ls -l /etc/bandit_pass/bandit21 결과 -r-------- 1 bandit21 bandit21 33 Apr 10 14:22 /etc/bandit_pass/bandit21
728x90반응형'Linux' 카테고리의 다른 글
[Linux 공부] Bandit wargames 22~23 단계 crontab (0) 2025.05.19 [Linux 공부] Bandit wargames 20~21 단계 setuid & nc (1) 2025.05.19 [Linux 공부] Bandit wargames 18~19 단계 SSH (0) 2025.05.19 [Linux 공부] Bandit wargames 16~18 단계 nmap & ssl 통신 & diff (0) 2025.05.19 [Linux 공부] Bandit wargames 15~16 단계 ssl 통신 (0) 2025.05.18