https://dreamhack.io/wargame/challenges/702
ssh with
id: pwn
pw: dhctf11
ssh pwn@host8.dreamhack.games -p 24488 을 입력하여 서버에 접속해줍니다.ls -al 를 입력하여 파일 구성을 확인합니다.
중요해 보이는 파일, chal 과 flag 를 확인할 수 있었습니다. ./flag 로 바로 접근을 시도하였지만 역시나 거절당했고, ./chal 을 입력하면 “Tada-!” 라는 문자열이 뜨며 역시 접근을 거부당했습니다.
id 명령어를 통해 현재 사용자의 정보를 출력해봅니다.uid=1000(pwn) gid=1000(pwn) groups=1000(pwn)
이 결과를 통해 pwn 유저임을 알 수 있었습니다. 그렇기에 pwned 그룹에 속한 chal과 flag를 확인할 수 없던 것입니다. pwned 권한을 우회해 flag을 얻어내는게 목표임을 알 수 있었습니다.
echo '#!/bin/sh cat /home/pwn/flag' > clear 를 입력합니다.#!/bin/sh cat /home/pwn/flag 이 내용을 넣는 명령어입니다.#!/bin/sh 은 sh로 실행하는 스트립트 라는 뜻, cat /home/pwn/flag 는 flag 파일 내용을 출력하라는 뜻입니다. 즉, clear 파일을 출력하면 flag를 보여주게 되는 것입니다.chmod +x clear 를 입력합니다.export PATH=.:$PATH 를 입력합니다../chal 를 입력하면 최종적으로 플래그를 획득할 수 있었습니다. chal는 pwned의 권한을 가진 바이너리로, pwn이 아닌 pwned의 권한으로 파일을 열기 때문에 플래그를 획득할 수 있습니다.
chal and flag) using ls -al.flag was denied due to insufficient permissions, since the user belonged to the pwn group while the files belonged to the pwned group.id and understood that the challenge aimed to bypass pwned group restrictions by abusing a privileged binary.clear script that outputs the flag, then made it executable and manipulated the PATH variable so this malicious script would run first.chal binary, which runs with the pwned group’s privileges, causing it to execute the attacker-controlled clear script and reveal the flag.