Impacket rbcd.py
computer account の msDS-AllowedToActOnBehalfOfOtherIdentity を読み取り、委任先アカウントを追加・削除します。
| 項目 | 内容 |
|---|---|
| 実装 | examples/rbcd.py |
| カテゴリ | Active Directory / LDAP / アカウント管理 |
| 規模 | 331 行 |
| 配布 | setup.py の scripts=examples/*.py によりスクリプトとしてインストール |
CLI と入力
Section titled “CLI と入力”オプションの最新の定義は python examples/rbcd.py -h で確認できます。
| 引数 | 説明 |
|---|---|
identity | domain.local/username[:password] |
-delegate-to | Target account the DACL is to be read/edited/etc.(必須) |
-delegate-from | Attacker controlled account to write on the rbcd property of -delegate-to (only when using `-action write`) |
-action | Action to operate on msDS-AllowedToActOnBehalfOfOtherIdentity(選択肢: read, write, remove, flush、既定値: read) |
-ldaps / -use-ldaps | Use LDAPS instead of LDAP |
-ts | Adds timestamp to every logging output |
-debug | Turn DEBUG output ON |
-hashes | NTLM hashes, format is LMHASH:NTHASH |
-no-pass | don’t ask for password (useful for -k) |
-k | Use 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 |
-aesKey | AES key to use for Kerberos Authentication (128 or 256 bits) |
-dc-ip | IP Address of the domain controller or KDC (Key Distribution Center) for Kerberos. If omitted it will use the domain part (FQDN) specified in the identity parameter |
-dc-host | Hostname of the domain controller or KDC (Key Distribution Center) for Kerberos. If omitted, -dc-ip will be used |
関連技術: LDAP の self-relative SD、Kerberos の S4U2proxy / PA_PAC_OPTIONS。
詳細な処理フロー
Section titled “詳細な処理フロー”LDAP で delegate-to と delegate-from を SID へ解決し、対象属性の security descriptor を取得します。read は許可 SID を表示し、write は allow ACE を追加、remove は該当 ACE を除去、flush は空の descriptor を書き戻します。
仕組みの詳細
Section titled “仕組みの詳細”RBCD の許可情報は委任元ではなく委任先 computer object の
msDS-AllowedToActOnBehalfOfOtherIdentity に格納されます。値は SID の単純な
配列ではなく self-relative security descriptor です。read は descriptor の
DACL を解析し、allow ACE の trustee SID を account 名へ解決して表示します。
write は delegate-from の SID を取得し、必要な access mask を持つ allow
ACE を構築して既存 DACL へ追加します。remove は指定 SID の ACE だけを除き、
flush は属性全体を空にします。したがって remove と flush は影響範囲が
大きく違い、既存の別 delegate を保持するかどうかが操作の中心です。
LDAP modify へ渡す binary descriptor では revision、owner/group、ACL size、 ACE count が整合していなければなりません。重複 ACE、未知 ACE、解決不能 SID があっても既存情報を失わないよう、parse と再シリアライズの round-trip を 確認します。
主要な実装要素
Section titled “主要な実装要素”| シンボル | 位置 | 責務を追う入口 |
|---|---|---|
RBCD | 69 | __init__()、read()、write()、remove()、flush()、get_allowed_to_act()、get_user_info()、get_sid_info() |
create_empty_sd() | 36 | モジュール関数 |
create_allow_ace() | 56 | モジュール関数 |
parse_args() | 258 | モジュール関数 |
main() | 300 | モジュール関数 |
Impacket 内部
Section titled “Impacket 内部”| モジュール | 使用する主な名前 |
|---|---|
impacket | version |
impacket.examples | logger, utils |
impacket.ldap | ldaptypes |
impacket.examples.utils | init_ldap_session, parse_identity |
外部パッケージ(直接使用)
Section titled “外部パッケージ(直接使用)”| import 名 | 配布パッケージ | 経路・宣言状態 |
|---|---|---|
ldap3 | ldap3 | 直接 import、宣言済み |
ldapdomaindump | ldapdomaindump | 直接 import、宣言済み |
出力・副作用・必要権限
Section titled “出力・副作用・必要権限”- 対象の状態を変更する操作があります。変更前に対象名や SID、パスを確認してください。
失敗経路と後始末
Section titled “失敗経路と後始末”- 失敗時は、名前解決、接続、認証、サービスの状態、権限のどこで止まったかを、プロトコルのステータスから切り分けます。
実装を変更するとき
Section titled “実装を変更するとき”ldap3、ldapdomaindump、ldaptypes に依存します。create_empty_sd() と create_allow_ace() が binary descriptor を構築します。既存 ACE を保持する action と全消去を混同しないようにしてください。
- 構文:
python -m py_compile examples/rbcd.py - CLI:
python examples/rbcd.py -h - 関連テスト:
tests/SMB_RPC/test_ldap.py

