[File upload] Web shell upload via extension blacklist bypass

2025. 4. 17. 17:02·Web Security Academy

This lab contains a vulnerable image upload function. Certain file extensions are blacklisted, but this defense can be bypassed due to a fundamental flaw in the configuration of this blacklist.

To solve the lab, upload a basic PHP web shell, then 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

You need to upload two different files to solve this lab.

 

https://portswigger.net/web-security/file-upload/lab-file-upload-web-shell-upload-via-extension-blacklist-bypass

 

Lab: Web shell upload via extension blacklist bypass | Web Security Academy

This lab contains a vulnerable image upload function. Certain file extensions are blacklisted, but this defense can be bypassed due to a fundamental flaw in ...

portswigger.net


이번 실습 페이지에는 취약한 이미지 업로드 기능이 포함되어 있다. 특정 파일 확장자는 블랙리스트에 등록되어 있지만, 이 블랙리스트 구성의 근본적인 결함 때문에 방어책을 우회할 수 있다. 

문제를 해결하려면 기본 PHP 웹 셸을 업로드한 후, 이를 사용해서 /home/carlos/secret 파일 내용을 추출해야 한다. 랩 배너에 제공된 버튼을 사용하여 플래그?를 제출하면 된다.

로그인 계정: wiener/peter

랩으로 들어오면 기본적인 블로그 형태의 웹페이지를 볼 수 있다.

파일 업로드를 위해 주어진 계정으로 로그인을 한다.

로그인을 완료하면 My Account 페이지로 이동되고 파일 업로드 기능을 확인할 수 있다. 임의의 이미지 파일을 업로드한다.

정상적으로 업로드가 되었다는 메시지를 확인할 수 있다. 다시 My Account 페이지로 이동한다.

내가 올린 이미지 파일이 업로드된 것을 볼 수 있다.

이번에는 PHP 웹 셸을 업로드 시도를 했다.

.php 확장자가 필터링되어 업로드가 실패한 것을 알 수 있었다.

세상에 없는 확장자로 변경해서 업로드 시도를 했다.

업로드 성공 시 출력되는 메시지가 출력됐다.

My Account 페이지로 돌아와 보면 위와 같이 되어 있다.

응답 데이터를 확인해 본 결과 위와 같이 업로드된 파일 내용 그대로 나타나는 것을 확인할 수 있다.

 

현재까지 알 수 있는 것)

  1. php 확장자는 필터링되어 업로드가 불가능하다.
  2. 블랙리스트에 포함되지 않는 확장자는 업로드가 가능하다.
  3. 업로드된 내용을 그대로 볼 수 있다.

AddType application/x-httpd-php .jwajwa

.htaccess 는 다음과 같다.

htaccess 확장자의 파일이 업로드를 먼저 하고

.jwajwa 확장자의 웹 셸을 다시 업로드하면

이번에도 마찬가지로 업로드가 된다.

하지만 .htaccess를 업로드하기 전과 다르게 웹 셸 파일의 내용이 텍스트 그대로 출력되는 게 아니라 PHP 코드로 인식해 실행되어 /home/carlos/secret 파일의 내용 볼 수 있다.

이제 해당 파일의 내용을 상단 배너 Submit 버튼을 눌러 제출하면 해결할 수 있다.

'Web Security Academy' 카테고리의 다른 글

[Path traversal] File path traversal, traversal sequences stripped with superfluous URL-decode  (0) 2025.04.18
[File upload] Remote code execution via web shell upload  (1) 2025.04.17
'Web Security Academy' 카테고리의 다른 글
  • [Path traversal] File path traversal, traversal sequences stripped with superfluous URL-decode
  • [File upload] Remote code execution via web shell upload
min8282
min8282
  • min8282
    min8282
    min8282
  • 전체
    오늘
    어제
    • 분류 전체보기 (110)
      • Security (33)
        • System & Network (2)
        • Application (5)
        • Cloud (20)
      • Dev (18)
        • Node.js (12)
        • Hadoop (3)
        • BOJ (2)
      • Web3 & Blockchain (2)
        • Web3 (2)
      • K-Shield.Jr (15)
      • Web Security Academy (3)
      • Wargame (13)
        • Dreamhack (3)
        • Bandit (10)
      • NS (16)
        • CTF (6)
  • 블로그 메뉴

    • 홈
  • 링크

    • github
  • 공지사항

  • 인기 글

  • 태그

    오블완
    메타코드
    metacodem
    splunk db connect
    스마트 컨트랙트
    prepared statement
    티스토리챌린지
    정처기필기
    탈중앙화
    web3 보안
    web security academy
    web3
    Session Manager
    File Upload
    metacode
    amazon s3 트리거
    ESC1
    정처기
    systems manager
    AWS CLI
    aws 트리거
    정보처리기사
    Path Traversal
    스마트컨트랙트
    보안 그룹
    aws lambda
    정처기 필기
    ELB
    메타코드M
    AWS SSM
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.4
min8282
[File upload] Web shell upload via extension blacklist bypass
상단으로

티스토리툴바