본문 바로가기

wargame/bandit

Level 19 → Level 20

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. The password for this level can be found in the usual place (/etc/bandit_pass), after you have used the setuid binary.
다음 단계에 접근하기 위해서, 홈 디렉토리에 있는 setuid binary를 사용해야 한다. 어떻게 쓰는지 알아내기 위하여 인수 없이 실행해라. 이 단계의 비밀번호는 setuid binary를 사용한 후, usual place(/etc/bandit_pass)에 있다.

Code

bandit19@bandit:~$ ls
bandit20-do
bandit19@bandit:~$ ls -l
total 8
-rwsr-x--- 1 bandit20 bandit19 7296 Oct 16 14:00 bandit20-do # bandit20 권한이 있다
bandit19@bandit:~$ ./bandit20-do # 파일을 실행할 때 항상./을 앞에 붙임
Run a command as another user.
  Example: ./bandit20-do id
bandit19@bandit:~$ id
uid=11019(bandit19) gid=11019(bandit19) groups=11019(bandit19)
bandit19@bandit:~$ ./bandit20-do id # 실행파일에서 하란대로 실행함
uid=11019(bandit19) gid=11019(bandit19) euid=11020(bandit20) groups=11019(bandit19)
bandit19@bandit:~$ cd /etc/bandit_pass
bandit19@bandit:/etc/bandit_pass$ cat bandit20
cat: bandit20: Permission denied # 파일을 실행하면 출력할 수 있을 줄 알았음
bandit19@bandit:/etc/bandit_pass$ cd ~
bandit19@bandit:~$ ./bandit20-do cat /etc/bandit_pass/bandit20 # 파일을 실행할 때는 bandit20 권한을 가지므로 그 동안은 bandit20을 출력할 수 있음
#비밀번호

"set-user-id(set user ID upon execution)이라는 특별한 실행권한이 설정된 실행파일을 실행하면 이 프로세스의 유효 사용자 ID는 그 실행파일의 소유자로 바뀌게 되어 결과적으로 이 프로세스는 실행되는 동안 그 파일의 소유자 권한을 갖게 된다." 이전에 배웠던 내용을 예제로 확인할 수 있는 기회가 되었다. 또한 다른 홈페이지를 참고하였는데 거기서는 setuid를 설정한 cat 명령어를 실행시키면 파일을 읽을 수 있었다. 이 문제에서 ./bandit20-do를 실행시켜보니 ./bandit20-do + 명령어를 하면 bandit20의 실행권한을 얻은 명령어를 실행할 수 있음을 알게 되었다.
+) 특수권한 활용 예시

#setuid

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

Level 21 → Level 22  (0) 2019.02.28
Level 20 → Level 21  (0) 2019.02.28
Level 18 → Level 19  (0) 2019.02.24
Level 17 → Level 18  (0) 2019.02.24
Level 16 → Level 17  (0) 2019.02.24