Impacket keylistattack.py
RODC の番号と鍵を使って Kerberos Key List 要求を送り、指定または列挙したアカウントの長期鍵を要求します。
| 項目 | 内容 |
|---|---|
| 実装 | examples/keylistattack.py |
| カテゴリ | Kerberos / チケット処理 |
| 規模 | 283 行 |
| 配布 | setup.py の scripts=examples/*.py によりスクリプトとしてインストール |
CLI と入力
Section titled “CLI と入力”オプションの最新の定義は python examples/keylistattack.py -h で確認できます。
| 引数 | 説明 |
|---|---|
target | [[domain/]username[:password]@] |
-rodcNo | Number of the RODC krbtgt account |
-rodcKey | AES key of the Read Only Domain Controller |
-full | Run the attack against all domain users. Noisy! It could lead to more TGS requests being rejected |
-debug | Turn DEBUG output ON |
-ts | Adds timestamp to every logging output |
-domain | The fully qualified domain name (only works with LIST) |
-kdc | KDC HostName or FQDN (only works with LIST) |
-t | Attack only the username specified (only works with LIST) |
-tf | File that contains a list of target usernames (only works with LIST) |
-domain-sid | LIST モードで PAC に入れるドメイン SID。PAC の検証が厳しい Domain Controller では指定を推奨します。 |
-hashes | Use NTLM hashes to authenticate to SMB and list domain users. |
-no-pass | don’t ask for password (useful for -k) |
-k | Use Kerberos to authenticate to SMB and list domain users. 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 |
-aesKey | AES key to use for Kerberos Authentication (128 or 256 bits) |
-dc-ip | IP Address of the domain controller. If ommited it use the domain part (FQDN) specified in the target parameter |
-target-ip | IP Address of the target machine. If omitted it will use whatever was specified as target. This is useful when target is the NetBIOS name and you cannot resolve it |
関連技術: Kerberos の KERB_KEY_LIST_REQ、DPAPI / SAM / LSA / NTDS の KeyListSecrets。
詳細な処理フロー
Section titled “詳細な処理フロー”資格情報と RODC 情報を検証し、必要なら LDAP/DRS 経由で domain user を列挙します。対象 user ごとに KDC へ key-list 対応 request を送信し、復号した key material を表示します。-t / -tf と -full が対象の決定方法を切り替えます。
LIST モードでは SAMR からドメイン SID を自動取得しないため、PAC の検証で
要求が拒否される場合は -domain-sid を指定します。
仕組みの詳細
Section titled “仕組みの詳細”RODC は保持する account secret を限定でき、Kerberos Key List request は RODC 用 ticket と権限条件の下で account key 一覧を返す仕組みです。この コマンドは RODC 番号と krbtgt key から必要な Kerberos material を作り、 対象 principal ごとに key list を要求します。
対象は単一名、file、または -full で取得した domain user 一覧から作られます。
一覧取得経路と KDC request 経路は独立しており、LDAP/DRS の列挙に失敗しても
明示 target まで無効になるわけではありません。request には RODC identity、
ticket、nonce、対応 enctype が関係し、応答 encrypted part は request で
確立した key と正しい key usage で復号します。
返る key は account ごと、enctype/key version ごとに意味が違います。 「一つ応答があった」ことと「要求した全 account の全 key が得られた」ことを 区別します。RODC が secret を cache していない、replication policy で拒否、 KVNO/RODC 番号が不一致という状態を個別に診断できるようにします。
主要な実装要素
Section titled “主要な実装要素”| シンボル | 位置 | 責務を追う入口 |
|---|---|---|
KeyListDump | 49 | __init__()、connect()、run()、getAllDomainUsers() |
Impacket 内部
Section titled “Impacket 内部”| モジュール | 使用する主な名前 |
|---|---|
impacket.examples | logger |
impacket.examples.secretsdump | KeyListSecrets, RemoteOperations |
impacket.examples.utils | parse_target |
impacket.krb5 | constants |
impacket.krb5.types | Principal |
impacket.smbconnection | SMBConnection |
impacket | version |
外部パッケージ(直接使用)
Section titled “外部パッケージ(直接使用)”| import 名 | 配布パッケージ | 経路・宣言状態 |
|---|---|---|
pyasn1 | pyasn1 | 直接 import、宣言済み |
出力・副作用・必要権限
Section titled “出力・副作用・必要権限”- 照会や認証の試行が中心です。実行回数が多いと監査ログやアカウントロック、対象の負荷に影響します。
- オプションによりローカルファイルを作成または更新します。既存ファイルの扱いと秘密情報を含む出力の権限を確認してください。
失敗経路と後始末
Section titled “失敗経路と後始末”- 失敗時は、名前解決、接続、認証、サービスの状態、権限のどこで止まったかを、プロトコルのステータスから切り分けます。
実装を変更するとき
Section titled “実装を変更するとき”Kerberos ASN.1/crypto、LDAP/DRS、SMB/RPC helper に依存し、KeyListDump.connect()、getAllDomainUsers()、run() が主要境界です。RODC key version と enctype の対応を維持してください。
- 構文:
python -m py_compile examples/keylistattack.py - CLI:
python examples/keylistattack.py -h - 関連テスト:
tests/misc/test_krb5_crypto.py - 関連テスト:
tests/misc/test_krb5_gssapi.py

