본문 바로가기

wargame/bandit

Level 20 → Level 21

Level Goal

There is a setuid binary in the homedirectory that does the following: it makes a connection to localhost on the port you specify as a commandline argument. It then reads a line of text from the connection and compares it to the password in the previous level (bandit20). If the password is correct, it will transmit the password for the next level (bandit21).
NOTE: Try connecting to your own network daemon to see if it works as you think
홈 디렉토리에는 당신이 명령행 인수로 지정한 포트로 localhost에 접속하는 setuid 이진파일이 있다. 접속하여 텍스트를 한 줄 읽고 지난 단계의 비밀번호(bandit20)와 비교한다. 만약 비밀번호가 맞다면, 다음 단계의 비밀번호(bandit21)를 전송한다
NOTE: 네트워크 데몬에 접속하여 생각한대로 실행되는지 확인하여라

Code

bandit20@bandit:~$ ls -l
total 12
-rwsr-x--- 1 bandit21 bandit20 12088 Oct 16 14:00 suconnect
bandit20@bandit:~$ ./suconnect # 실행파일 실행
Usage: ./suconnect 
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. # 이 프로그램은 TCP를 이용하여 주어진 포트에 localhost를 연결할 것이다. 만약 other side에서 정확한 비밀번호를 받는다면, 다음 비밀번호를 다시 전송할 것이다
bandit20@bandit:~$ nc -l -p 3000- < /etc/bandit_pass/bandit20& # 후면에서 실행하여 suconnect 명령어를 실행하고자 하였다
[1] 31684
bandit20@bandit:~$ ./suconnect 3000 # suconnect 명령어 실행
Read: GbKksEFF4yrVs6il55v6gwY5aVje5f0j # nc -l 에서 비밀번호 받음
Password matches, sending next password
#비밀번호
[1]+  Done                    nc -l -p 3000- < /etc/bandit_pass/bandit20

처음에는 문제 해석도 어려웠다. 무슨 뜻인지도 모르겠어서 그나마 이해되는 NOTE 부분부터 찾아보기로 했다. 데몬에 대해서 공부하다가 어떤 블로그에서 ps -efg 명령어를 사용하면 데몬을 확인할 수 있다길래 찾아봤더니 명령어 중에서 "nc -l 30000"라는 것을 찾아볼 수 있었다. nc -l는 특정 포트에서 서버와 클라이언트가 소통할 수 있는 명령어였다. nc -l 명령어와 문제와 문제에서 주어진 명령어(터미널을 여러 개 생성하는 명령어인 screen과 tmux가 있었다)와 ./suconnect 명령어를 조합하여 생각해보니 nc -l 명령어로 bandit20 명령어를 특정 포트에 보내고, 보낸 명령어를 ./suconnect로 받으면 비밀번호를 알 수 있다는 말 같았다. 이제 해석까지 됐으니 바로 실행할 수 있을까 했는데 멍청하게도 30000이 특정 포트인줄 알고 또 헤맸다. 문제를 다시 읽고 다시 해석했더니 문제를 제대로 이해할 수 있었다. nc -l 예제를 처음에 보았을 때는 서버와 클라이언트가 따로 있어서 터미널을 여러 개 가지고 있는 screen이나 tmux 명령어를 사용해서 풀려고 했는데 잘 풀리지 않았다. 꼭 명령어를 이용하지 않더라도 ./suconnect 명령어는 특정 포트에서 bandit20 비밀번호를 받기만 하면 되므로 nc -l 명령어를 후면처리하여 동시에 실행에 옮겼더니 성공하였다.
+) nc -l 명령어 예제   screen 명령어 사용법1   screen 명령어 사용법2   screen 명령어 사용법3   daemon 개념   daemon 개념2

#nc -l # screen #tmux

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

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