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
를 사용하여 /etc/bandit_pass
디렉토리에서 패스워드를 찾을 수 있다.
일단 뭔지는 모르겠지만 setuid binary
를 사용해야 한다고 했으므로 홈 디렉토리에 존재하는 파일을 실행해 본다.
ls -al ~
./bandit20-do
인수 없이 실행해보면 사용 예시를 확인할 수 있다.
./bandit20-do id
사용 예시와 같이 실행하면 uid=11019(bandit19) gid=11019(bandit19) euid=11020(bandit20) groups=11019(bandit19)
라는 출력 결과가 나오는데, 이 중에서 euid
를 보면 bandit20
이라고 나와 있다. 이 euid
는 현재 명령을 실행하는 주체의 uid
이다. 즉, 위 파일을 실행할 때 bandit20
의 권한으로 명령을 실행할 수 있다는 의미이다.
./bandit20-do cat /etc/bandit_pass/bandit20
따라서, bandit20
의 권한으로 /etc/bandit_pass
디렉토리에 있는 패스워드 파일 내용을 출력하여 다음 레벨로 가는 패스워드를 얻을 수 있다.
- SetUID
SetUID가 설정된 파일을 실행하면 일시적으로 파일 소유자의 권한으로 실행할 수 있게 된다. SetUID를 설정하려면 기존 퍼미션 앞에 4를 붙이면 된다.
ex) chmod 4600 [파일명]
(기존에 실행 권한이 있으면 s, 없으면 S로 표시된다.)