コンテンツにスキップ

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

LDAP からユーザーアカウントの SPN を列挙します。指定時には TGS も取得し、オフライン解析用の形式で出力します。

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

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

引数説明
targetdomain[/username[:password]]
-target-domainDomain to query/request if different than the domain of the user. Allows for Kerberoasting across trusts.
-no-preauthaccount that does not require preauth, to obtain Service Ticket through the AS
-stealthRemoves the (servicePrincipalName=*) filter from the LDAP query for added stealth. May cause huge memory consumption / errors on large domains.
-machine-onlyQueries for machine accounts only, by adjusting `objectCategory=person` to `objectCategory=computer`. Active Directory may limit results to 1,000 objects by default. LDAP paging is required to retrieve more.
-usersfileFile with user per line to test
-requestRequests TGS for users and output them in JtR/hashcat format (default False)
-request-userRequests TGS for the SPN associated to the user specified (just the username, no domain needed)
-request-machineRequests TGS for the SPN associated to the machine specified. Example: `workstation01$`
-saveSaves TGS requested to disk. Format is .ccache. Auto selects -request
-outputfileOutput filename to write ciphers in JtR/hashcat format. Auto selects -request
-no-rc4Does not force RC4-HMAC for the TGT
-tsAdds timestamp to every logging output.
-debugTurn DEBUG output ON
-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 ommited it use the domain part (FQDN) specified in the target parameter. Ignoredif -target-domain is specified.
-dc-hostHostname of the domain controller to use. If ommited, the domain part (FQDN) specified in the account parameter will be used
-ldaps / -use-ldapsUse LDAPS instead of LDAP

関連技術: Kerberos の TGS-REP enc-part、LDAP の SPN 検索。

LDAP で SPN、UAC、delegation 属性を検索・表示します。-request / -request-user / -request-machine では TGT を用意し、各 SPN の TGS-REQ を KDC へ送信、応答 enctype ごとに文字列表現または ccache を生成します。-stealth や -usersfile は検索/request の入口を変えます。

Kerberoasting の対象になるのは SPN 文字列そのものではなく、user account の long-term key で暗号化された service ticket 部分です。最初の LDAP 検索では servicePrincipalName を持つ account と UAC/delegation 属性を集め、どの account がどの service identity を所有しているかを表示します。

ticket を要求する場合、呼び出し元の TGT を password/hash/AES/ccache から 用意し、対象 SPN ごとに TGS-REQ を送ります。KDC が返す TGS-REP の ticket encrypted part は service account key で保護されており、enctype と checksum/ cipher の配置に合わせて hashcat/John 形式へ変換されます。-save は応答を ccache credential として保存する別の出力経路です。

-no-rc4 は client が提示する enctype の選好を変え、-stealth や -usersfile は LDAP の探索方法を変えます。KDC が実際に選んだ enctype が 最終的な出力形式を決めるため、要求側の希望だけで RC4/AES と断定してはいけません。 cross-domain では認証 domain、検索 domain、KDC の三者を明示的に分けます。

シンボル位置責務を追う入口
GetUserSPNs54__init__()、printTable()、getUnixTime()、getTGT()、outputTGS()、run()、request_users_file_TGSs()、request_multiple_TGSs()
モジュール使用する主な名前
impacketversion
impacket.dcerpc.v5.samrUF_ACCOUNTDISABLE, UF_TRUSTED_FOR_DELEGATION, UF_TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION
impacket.exampleslogger
impacket.examples.utilsldap_login, parse_identity
impacket.krb5constants
impacket.krb5.asn1AS_REP, TGS_REP
impacket.krb5.ccacheCCache
impacket.krb5.kerberosv5getKerberosTGS, getKerberosTGT
impacket.krb5.typesPrincipal
impacket.ldapldap, ldapasn1
impacket.ntlmcompute_lmhash, compute_nthash
import 名配布パッケージ経路・宣言状態
pyasn1pyasn1直接 import、宣言済み
  • 照会や認証の試行が中心です。実行回数が多いと監査ログやアカウントロック、対象の負荷に影響します。
  • オプションによりローカルファイルを作成または更新します。既存ファイルの扱いと秘密情報を含む出力の権限を確認してください。
  • 失敗時は、名前解決、接続、認証、サービスの状態、権限のどこで止まったかを、プロトコルのステータスから切り分けます。

LDAP、krb5.kerberosv5 / ccache / asn1 / crypto、pyasn1、NTLM hash helper に依存します。LDAP record と TGS 出力形式は GetUserSPNs 内で分離されています。