コンテンツにスキップ

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

LDAP オブジェクトのセキュリティ記述子から所有者を読み取り、指定した SID に変更します。

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

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

引数説明
identitydomain.local/username[:password]
-ldaps / -use-ldapsUse LDAPS instead of LDAP
-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 or KDC (Key Distribution Center) for Kerberos. If omitted it will use the domain part (FQDN) specified in the identity parameter
-dc-hostHostname of the domain controller or KDC (Key Distribution Center) for Kerberos. If omitted, -dc-ip will be used
-new-ownersAMAccountName
-new-owner-sidSecurity IDentifier
-new-owner-dnDistinguished Name
-targetsAMAccountName
-target-sidSecurity IDentifier
-target-dnDistinguished Name
-actionAction to operate on the owner attribute(選択肢: read, write、既定値: read)

対象と新 owner を名前/SID/DN から解決し、owner security information を要求して descriptor を取得します。read は現在 owner を表示し、write は owner field のみを書き換えて LDAP modify します。

security descriptor の owner は DACL の ACE とは別 field です。このコマンドは LDAP security descriptor control で owner 部分を要求し、対象 object と 新 owner principal をそれぞれ name、SID、DN のいずれかから解決します。 read は現在 owner SID を可能なら account 名へ変換して表示します。

write は取得した descriptor の owner field を新 SID に置き換え、owner security information の control mask で LDAP modify します。DACL 全体を再構築 しないのは、対象外の ACE/SACL/group を壊さず、server に「owner だけ変更する」 意図を伝えるためです。新 owner に指定できることと、呼び出し元が owner を変更 する権限を持つことは別の検査です。

SID 解決失敗、object 検索結果 0 件/複数件、WRITE_OWNER 不足を区別する必要が あります。また owner 変更は後続の ACL 編集権限へ影響し得るため、成功時は 対象 DN、旧 owner、新 owner を秘密情報を含まない形で追跡できるようにします。

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

ldap3、ldapdomaindump、ldaptypes、security descriptor control を使用します。OwnerEdit は DACL を扱う dacledit と似ていますが、変更対象を owner に限定します。control mask と未変更部分の descriptor を保持してください。

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