コンテンツにスキップ

カテゴリ目次へ戻る / コマンド全体目次へ戻る

TGS の取得、S4U2self/S4U2proxy、U2U、チケット更新を扱い、得たサービスチケットを ccache に保存します。

項目内容
実装examples/getST.py
カテゴリKerberos / チケット処理
規模918 行
配布setup.py の scripts=examples/*.py によりスクリプトとしてインストール

オプションの最新の定義は python examples/getST.py -h で確認できます。

引数説明
identity[domain/]username[:password]
-spnSPN (service/server) of the target service the service ticket will be generated for
-altserviceNew sname/SPN to set in the ticket
-dmsaUse DMSA (Delegated Managed Service Accounts)
-impersonatetarget username that will be impersonated (thru S4U2Self) for quering the ST. Keep in mind this will only work if the identity provided in this scripts is allowed for delegation to the SPN specified
-additional-ticketinclude a forwardable service ticket in a S4U2Proxy request for RBCD + KCD Kerberos only
-tsAdds timestamp to every logging output
-debugTurn DEBUG output ON
-u2uRequest User-to-User ticket
-selfOnly do S4U2self, no S4U2proxy
-force-forwardableForce the service ticket obtained through S4U2Self to be forwardable. For best results, the -hashes and -aesKey values for the specified -identity should be provided. This allows impresonation of protected users and bypass of “Kerberos-only” constrained delegation restrictions. See CVE-2020-17049
-renewSets the RENEW ticket option to renew the TGT used for authentication. Set -spn to ‘krbtgt/DOMAINFQDN’
-hashesNTLM hashes, format is LMHASH:NTHASH
-no-passdon’t ask for password (useful for -k)
-kUse Kerberos authentication. Grabs credentials from ccache file (KRB5CCNAME) based on target parameters. If valid credentials cannot be found, it will use the ones specified in the command line
-aesKeyAES key to use for Kerberos Authentication (128 or 256 bits)
-dc-ipIP Address of the domain controller. If omitted it use the domain part (FQDN) specified in the target parameter

関連技術: Kerberos の TGS、S4U2self/S4U2proxy、U2U、PAC。S4U は getKerberosTGS ではなくこのファイル側です。

password/hash/AES/既存 ccache から TGT を確保し、オプションに応じて通常 TGS、impersonation、additional-ticket、dMSA、renew の経路へ分岐します。KDC 応答を検証し、-altservice 等の必要な調整を施して saveTicket() で ccache を書き出します。

このコマンドは service ticket 取得の複数経路を一つの CLI にまとめています。 通常経路では TGT とその session key を準備し、目的 SPN の TGS-REQ を送ります。 ccache の TGT は要求したユーザー名とドメインが一致する場合だけ使い、 一致しなければ警告して新しい TGT を要求します。 -impersonate では S4U2self で別 user の identity を表す evidence ticket を 得て、必要なら S4U2proxy で最終 service ticket に交換します。

S4U2proxy では evidence ticket、delegation 対象 SPN、PAC option、ticket flags の組み合わせが KDC の authorization 判定に使われます。 -additional-ticket は外部から渡された evidence ticket を使う経路、 -u2u は別 ticket の session key を利用する経路、-renew は renewable ticket の期間更新経路です。これらは request ASN.1 の field と key usage が 異なるため、単一の「TGS request」関数へ無理に畳み込んでいません。

応答の client/service principal、flags、session key、暗号種別を確認してから CCache credential を作ります。-altservice は保存前に service principal 表現を調整しますが、暗号化済み ticket の鍵自体を変えるものではありません。 -force-forwardable などの flag 操作では、ticket encrypted part を復号・ 再暗号化できる key が本当にあるかを先に検証する必要があります。

シンボル位置責務を追う入口
GETST81__init__()、saveTicket()、doS4U2ProxyWithAdditionalTicket()、doS4U()、run()
モジュール使用する主な名前
impacketversion
impacket.exampleslogger
impacket.examples.utilsparse_identity
impacket.krb5ccache, constants, crypto, types
impacket.krb5.asn1AP_REQ, AS_REP, Authenticator, EncTGSRepPart, EncTicketPart, KERB_DMSA_KEY_PACKAGE, PA_FOR_USER_ENC, PA_PAC_OPTIONS, PA_S4U_X509_USER, S4UUserID, TGS_REP, TGS_REQ, Ticket, seq_set, seq_set_iter
impacket.krb5.ccacheCCache, Credential
impacket.krb5.cryptoCksumtype, Enctype, Key, _AES256CTS, _HMACMD5, _enctype_table, _get_checksum_profile, string_to_key
impacket.krb5.constantsApplicationTagNumbers, TicketFlags, encodeFlags
impacket.krb5.kerberosv5getKerberosTGS, getKerberosTGT, sendReceive
impacket.krb5.typesKerberosTime, Principal, Ticket
impacket.ntlmcompute_nthash
impacket.winregistryhexdump
import 名配布パッケージ経路・宣言状態
pyasn1pyasn1直接 import、宣言済み
sixsix直接 import、宣言済み
  • 照会や認証の試行が中心です。実行回数が多いと監査ログやアカウントロック、対象の負荷に影響します。
  • オプションによりローカルファイルを作成または更新します。既存ファイルの扱いと秘密情報を含む出力の権限を確認してください。
  • 失敗時は、名前解決、接続、認証、サービスの状態、権限のどこで止まったかを、プロトコルのステータスから切り分けます。

krb5.asn1 / constants / crypto / kerberosv5 / ccache、pyasn1、NT hash helper に依存します。中心は GETST.run()、doS4U()、doS4U2ProxyWithAdditionalTicket() です。ticket flags と session key の対応を崩さないでください。