티스토리 뷰

Wargame/Bandit

Bandit Level 20 → Level 21

장일영 2024. 5. 16. 13:26

 

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

home 디렉토리에 setuid가 걸린 바이너리 파일의 기능은 다음과 같다. 커맨드라인에서 인자로 입력한 포트를 통해 localhost에 연결한다. 이후 텍스트 한 줄을 읽고 이전 레벨(bandit20)의 패스워드와 비교한다. 일치하면 다음 레벨(bandit21)의 패스워드를 전송할 것이다.

노트: 당신의 네트워크 데몬에 연결해 당신이 생각한 대로 동작하는지 확인해라.

 

Commands you may need to solve this level

`ssh`, `nc`, `cat`, `bash`, `screen`, `tmux`, Unix ‘job control’ (bg, fg, jobs, &, CTRL-Z, …)

 

Write Up

bandit20@bandit:~$ ls -al
total 36
drwxr-xr-x  2 root     root      4096 Oct  5  2023 .
drwxr-xr-x 70 root     root      4096 Oct  5  2023 ..
-rw-r--r--  1 root     root       220 Jan  6  2022 .bash_logout
-rw-r--r--  1 root     root      3771 Jan  6  2022 .bashrc
-rw-r--r--  1 root     root       807 Jan  6  2022 .profile
-rwsr-x---  1 bandit21 bandit20 15600 Oct  5  2023 suconnect

bandit20@bandit:~$ file suconnect
suconnect: setuid ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, BuildID[sha1]=4d95c75f0fe296f2477bfaad8b17039de5a56534, for GNU/Linux 3.2.0, not stripped

bandit20@bandit:~$ ./suconnect
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` 파일이 setuid가 걸린 바이너리 파일이다. 이 파일의 동작은 다음과 같다.

  1. localhost:xxx에 연결한다.
  2. 텍스트 한 줄을 읽어들인다.
  3. 이전 레벨의 패스워드와 비교한다.
  4. 일치하면 다음 레벨의 패스워드를 반환한다.

그렇다면 `suconnect` 파일이 특정 포트에 접속했을 때 bandit20 패스워드를 읽어들일 수 있도록 하면 다음 레벨의 패스워드를 반환할 것이다.

bandit20@bandit:~$ nc -l -p 12345 < /etc/bandit_pass/bandit20

 

이렇게 하면 12345번 포트가 열리고 접속 시 `/etc/bandit_pass/bandit20` 파일의 내용을 출력하게 된다.

'Wargame > Bandit' 카테고리의 다른 글

Bandit Level 22 → Level 23  (0) 2024.05.16
Bandit Level 21 → Level 22  (0) 2024.05.16
Bandit Level 19 → Level 20  (0) 2024.05.16
Bandit Level 18 → Level 19  (0) 2024.05.16
Bandit Level 17 → Level 18  (0) 2024.05.16
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2026/06   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함