CCob/gssapi-abuse
GitHub: CCob/gssapi-abuse
一款针对 Active Directory 混合环境中 GSSAPI 滥用向量的枚举与 DNS 记录操纵工具。
Stars: 181 | Forks: 23
# GSSAPI 滥用
gssapi-abuse 是作为我 DEF CON 31 演讲的一部分发布的。关于该滥用向量的完整文章可以在这里找到:
[A Broken Marriage: Abusing Mixed Vendor Kerberos Stacks](https://www.pentestpartners.com/security-blog/a-broken-marriage-abusing-mixed-vendor-kerberos-stacks/)
该工具具有两个功能。第一个功能是枚举加入 Active Directory 且通过 SSH 提供 GSSAPI 身份验证的非 Windows 主机。
第二个功能是为没有正确正向和/或反向查找 DNS 条目的、可被 GSSAPI 滥用的主机执行动态 DNS 更新。基于 GSSAPI 的身份验证在匹配服务主体方面非常严格,因此 DNS 条目应通过主机名和 IP 地址与服务主体名称匹配。
## 前置条件
gssapi-abuse 需要一个可工作的 krb5 栈以及正确配置的 krb5.conf。
### Windows
在 Windows 主机上,除了 `requirements.txt` 中列出的 python 模块外,还应安装 MIT Kerberos 软件,可以从 [MIT Kerberos Distribution Page](https://web.mit.edu/kerberos/dist/index.html) 获取。Windows krb5.conf 位于 `C:\ProgramData\MIT\Kerberos5\krb5.conf`
### Linux
在安装 python 依赖之前,需要先安装 `libkrb5-dev` 软件包
### 所有平台
满足要求后,您可以通过 pip/pip3 工具安装 python 依赖
```
pip install -r requirements.txt
```
## 枚举模式
枚举模式将连接到 Active Directory 并执行 LDAP 搜索,查找操作系统属性中不包含 `Windows` 一词的所有计算机。
获取非 Windows 机器列表后,gssapi-abuse 将尝试通过 SSH 连接到每台主机,并确定是否允许基于 GSSAPI 的身份验证。
### 示例
```
python .\gssapi-abuse.py -d ad.ginge.com enum -u john.doe -p SuperSecret!
[=] Found 2 non Windows machines registered within AD
[!] Host ubuntu.ad.ginge.com does not have GSSAPI enabled over SSH, ignoring
[+] Host centos.ad.ginge.com has GSSAPI enabled over SSH
```
## DNS 模式
DNS 模式利用 Kerberos 和 dnspython,通过 DNS-TSIG 协议在端口 53 上执行经过身份验证的 DNS 更新。目前 `dns` 模式依赖于一个可工作的 krb5 配置,该配置需要具有有效的 TGT 或针对特定域控制器的 DNS 服务票据,例如 `DNS/dc1.victim.local`。
### 示例
为主机 `ahost.ad.ginge.com` 添加 DNS `A` 记录
```
python .\gssapi-abuse.py -d ad.ginge.com dns -t ahost -a add --type A --data 192.168.128.50
[+] Successfully authenticated to DNS server win-af8ki8e5414.ad.ginge.com
[=] Adding A record for target ahost using data 192.168.128.50
[+] Applied 1 updates successfully
```
为主机 `ahost.ad.ginge.com` 添加反向 `PTR` 记录。请注意,`data` 参数以 `.` 结尾,这很重要,否则记录会成为区域的相对记录,而这不是我们想要的。我们还需要指定要更新的目标区域,因为 `PTR` 记录存储在与 `A` 记录不同的区域中。
```
python .\gssapi-abuse.py -d ad.ginge.com dns --zone 128.168.192.in-addr.arpa -t 50 -a add --type PTR --data ahost.ad.ginge.com.
[+] Successfully authenticated to DNS server win-af8ki8e5414.ad.ginge.com
[=] Adding PTR record for target 50 using data ahost.ad.ginge.com.
[+] Applied 1 updates successfully
```
执行后的正向和反向 DNS 查找结果
```
nslookup ahost.ad.ginge.com
Server: WIN-AF8KI8E5414.ad.ginge.com
Address: 192.168.128.1
Name: ahost.ad.ginge.com
Address: 192.168.128.50
```
```
nslookup 192.168.128.50
Server: WIN-AF8KI8E5414.ad.ginge.com
Address: 192.168.128.1
Name: ahost.ad.ginge.com
Address: 192.168.128.50
```
标签:Active Directory, Checkov, DEF CON, DNS动态更新, DNS枚举, GSSAPI, HTTP, PE 加载器, Plaso, Python, SSH认证, 内存分配, 协议滥用, 域环境, 无后门, 枚举工具, 横向移动, 混合供应商Kerberos攻击, 特权提升, 编程规范, 网络安全工具, 自动化部署, 身份验证绕过, 逆向工具