Bandit Level 20 → Level 21
문제
https://overthewire.org/wargames/bandit/bandit21.html
목표
다음 레벨의 패스워드를 찾는다.
홈 디렉토리에 위치한 setuid 바이너리는 지정한 로컬호스트의 포트로 연결해주는 파일이다. 연결에서 텍스트 한 줄을 읽고 이를 이전 레벨의 비밀번호와 비교하여 맞다면 다음 레벨의 비밀번호를 전송해준다.
풀이
홈 디렉토리에 suconnect 라는 파일이 있다.
1
2
bandit20@bandit:~$ ls
suconnect
실행시켜보니 TCP를 사용해 지정한 포트에 연결한다고 한다.
1
2
Usage: ./suconnect <portnumber>
This program will connect to the given port on localhost using TCP. If it receives the correct password from the other side, the next password is transmitted back.
suconnect로 연결한 포트에서 이전 레벨의 패스워드를 읽으려면 한 쪽에서 포트를 열고 한 쪽에서 접속하는 식으로 해야 한다.
한 쪽에서는 nc
명령어의 -lp
옵션으로 응답 대기 상태로 포트에 연결한다.
1
2
bandit20@bandit:~$ nc -lp 5555
한 쪽에서는 ./suconnect
로 포트에 연결한다.
1
2
bandit20@bandit:~$ ./suconnect 5555
포트를 연 쪽에서 이전 레벨의 패스워드를 입력해보니 다음 레벨의 패스워드가 출력된다.
1
2
3
bandit20@bandit:~$ nc -lp 5555
VxCazJaVykI6W36BkBU0mJTCM8rR95XT
NvEJF7oVjkddltPSrdKEFOllh9V1IBcq
Password : NvEJF7oVjkddltPSrdKEFOllh9V1IBcq
배운 것
nc
명령어의-lp
옵션으로 응답 대기 상태로 포트에 연결할 수 있다.
This post is licensed under CC BY 4.0 by the author.