コンテンツにスキップ

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

委任管理サービスアカウント(dMSA)を作成・変更・削除し、関連する AD 属性を調べます。

項目内容
実装examples/badsuccessor.py
カテゴリActive Directory / LDAP / アカウント管理
規模747 行
配布setup.py の scripts=examples/*.py によりスクリプトとしてインストール

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

引数説明
accountAccount used to authenticate to DC.
-dmsa-nameName of dMSA to add. If omitted, a random dMSA-[A-Z0-9]{8} will be used.
-actionAction to perform: add (requires -target-ou), delete (requires -dmsa-name, -target-ou), modify (requires -dmsa-name, -target-ou and -target-account), or search a dMSA.(選択肢: add, delete, modify, search、既定値: search)
-target-ouSpecific OU to check for dMSA creation capabilities (e.g., “OU=weakOU,DC=domain,DC=local”)
-principals-allowedUsername allowed to retrieve the managed password. If omitted, current username will be used.
-target-accountTarget user or computer account DN to set for msDS-ManagedAccountPrecededByLink (can target Domain Controllers, Domain Admins, Protected Users, etc.)(既定値: Administrator)
-dns-hostnameDNS hostname for the dMSA. If omitted, will be generated as dmsaname.domain.
-tsAdds timestamp to every logging output
-debugTurn DEBUG output ON
-methodMethod of adding the computer. LDAPS has some certificate requirements and isn’t always available.(選択肢: LDAP, LDAPS、既定値: LDAPS)
-portDestination port to connect to. LDAP defaults to 389, LDAPS to 636.(選択肢: 389, 636)
-baseDNSet baseDN for LDAP. If ommited, the domain part (FQDN) specified in the account parameter will be used.
-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 account 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-hostHostname of the domain controller to use. If ommited, the domain part (FQDN) specified in the account parameter will be used
-dc-ipIP of the domain controller to use. Useful if you can’t translate the FQDN.

LDAP session を作成後、action に応じて OU の探索、アカウント存在確認、security descriptor 構築、dMSA object の追加または属性変更へ進みます。SID を名前へ解決し、許可 principal や対象 account を検証してから書き込みます。

このコマンドは dMSA object を通常の user/computer と同じように追加するのでは なく、dMSA 固有の schema 属性と、移行対象 account との関連を構築します。 search_ous() と check_account_exists() が配置先と参照先を先に検証し、 build_security_descriptor() が dMSA を利用できる principal の SID を access control structure へ変換します。

add_dmsa() は objectClass、account 名、DNS host 名、managed account に必要な 属性をまとめて作成します。modify_dmsa() は既存 object に対して対象 account や許可 principal を更新します。追加と更新を分けるのは、LDAP add と modify で 失敗単位が異なり、既存 object の予期しない属性を消さないためです。

SID 除外、OU 選択、名前自動生成は単なる表示補助ではなく、誤った privileged principal や保護 container を対象にしないための guard です。Windows Server の schema/機能レベルに依存するため、noSuchAttribute や objectClassViolation を一般的な認証失敗として扱わず、対象 DC が dMSA を 理解しているかまで切り分けます。

シンボル位置責務を追う入口
BADSUCCESSOR34__init__()、run()、delete_dmsa()、check_account_exists()、search_ous()、is_excluded_sid()、resolve_sid_to_name()、generate_dmsa_name()、convert_sid_to_string()、build_security_descriptor()、add_dmsa()、modify_dmsa()
モジュール使用する主な名前
impacketversion
impacket.exampleslogger
impacket.examples.utilsinit_ldap_session, parse_identity, parse_target
impacket.ldapldaptypes
import 名配布パッケージ経路・宣言状態
ldap3ldap3直接 import、宣言済み
  • 対象の状態を変更する操作があります。変更前に対象名や SID、パスを確認してください。
  • 失敗時は、名前解決、接続、認証、サービスの状態、権限のどこで止まったかを、プロトコルのステータスから切り分けます。

ldap3、impacket.ldap.ldaptypes、init_ldap_session を使用し、処理は BADSUCCESSOR が所有します。schema/機能レベル依存が強いため、属性名、objectClass、SID 除外規則を変更する場合は対応する Windows Server 世代で確認してください。

  • 構文: python -m py_compile examples/badsuccessor.py
  • CLI: python examples/badsuccessor.py -h
  • 関連テスト: tests/SMB_RPC/test_ldap.py