コンテンツにスキップ

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

SAMR から対象ホストまたはドメインのユーザーとアカウント情報を取得し、表または CSV に出力します。

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

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

引数説明
target[[domain/]username[:password]@]
-csvTurn CSV output
-tsAdds timestamp to every logging output
-debugTurn DEBUG output ON
-dc-ipIP Address of the domain controller. If ommited it use the domain part (FQDN) specified in the target parameter
-target-ipIP Address of the target machine. If ommited it will use whatever was specified as target. This is useful when target is the NetBIOS name and you cannot resolve it
-portDestination port to connect to SMB Server(選択肢: 139, 445、既定値: 445)
-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)

SAMR named pipe へ接続し、server/domain handle を開いて user をページング列挙します。各 RID の user information を追加取得し、最終ログオンやパスワード時刻を変換して出力します。

SAMR の user enumeration は user 詳細を一度に返しません。dump() は最初に server/domain handle を開き、EnumerateUsersInDomain で RID と account 名の 一覧を page 単位に受け取ります。その後、各 RID の user handle を開き、 QueryInformationUser で追加属性を取得します。

STATUS_MORE_ENTRIES は失敗ではなく continuation marker です。resume handle を 次の要求へ渡し、最後の page まで集約する必要があります。各 user の照会だけが access denied になった場合でも、列挙済みの他 user を破棄せず、どの RID の詳細 が欠けたかを扱える構造が望まれます。

account 時刻は Windows time から変換され、CSV と表で同じ意味を持つ必要が あります。CSV は機械処理されるため、表示用の空欄、delimiter、文字 encoding を安易に変えないことが互換性上重要です。domain user と local SAM user は 接続先 domain handle によって決まります。

シンボル位置責務を追う入口
ListUsersException36構造体/定数定義
SAMRDump39__init__()、getUnixTime()、dump()
モジュール使用する主な名前
impacket.exampleslogger
impacket.examples.utilsparse_target
impacketversion
impacket.nt_errorsSTATUS_MORE_ENTRIES
impacket.dcerpc.v5samr, transport
impacket.dcerpc.v5.rpcrtDCERPCException
  • 照会や認証の試行が中心です。実行回数が多いと監査ログやアカウントロック、対象の負荷に影響します。
  • 失敗時は、名前解決、接続、認証、サービスの状態、権限のどこで止まったかを、プロトコルのステータスから切り分けます。

dcerpc.v5.samr / transport、STATUS_MORE_ENTRIES に依存します。SAMRDump.dump() と getUnixTime() が主要実装です。ページング status をエラー終了とせず、取得済み record を保持してください。