min8282

[File upload] Remote code execution via web shell upload 본문

Web Security Academy

[File upload] Remote code execution via web shell upload

min8282 2025. 4. 17. 16:34

This lab contains a vulnerable image upload function. It doesn't perform any validation on the files users upload before storing them on the server's filesystem.

To solve the lab, upload a basic PHP web shell and use it to exfiltrate the contents of the file /home/carlos/secret. Submit this secret using the button provided in the lab banner.

You can log in to your own account using the following credentials: wiener:peter

https://portswigger.net/web-security/file-upload/lab-file-upload-remote-code-execution-via-web-shell-upload

 

Lab: Remote code execution via web shell upload | Web Security Academy

This lab contains a vulnerable image upload function. It doesn't perform any validation on the files users upload before storing them on the server's ...

portswigger.net


실습 페이지로 이동하면 블로그 형태의 웹페이지로 이동된다.

문제에서 주어진 계정으로 로그인을 한다.(wiener/peter)

로그인에 성공하면 My Account 페이지로 이동하게 되고, 해당 페이지에는 업로드 기능이 존재한다. 

먼저 정상적인 케이스를 시도하기 위해 임의의 이미지 파일을 업로드 한다.

출력된 메시지를 보아 avatars라는 폴더 하위에 이미지가 업로드된 것을 알 수 있다.

다시 My Account 페이지로 돌아와보면 업로드한 이미지 파일을 볼 수 있다.

이번에는 웹 셸을 업로드 해봤다. 웹 셸 코드는 다음과 같다.

<?php echo file_get_contents('/home/carlos/secret'); ?>

웹 셸 파일도 아무런 필터링 없이 업로드된 것을 알 수 있다.

버프스위트를 사용해서 요청 데이터와 응답 데이터를 확인해 보면 위와 같이 플래그?를 확인할 수 있다.

상단 배너에 있는 솔루션 제출 버튼을 클릭하고

응답 데이터에서 찾은 플래그를 입력한다.

문제 해결 완료