コンテンツにスキップ

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

LSA に RID ごとの SID を問い合わせ、ドメイン SID とアカウント名の対応を列挙します。

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

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

引数説明
target[[domain/]username[:password]@]
maxRidmax Rid to check (default 4000)
-debugTurn DEBUG output ON
-tsAdds timestamp to every logging output
-target-ipIP 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
-portDestination port to connect to SMB Server(選択肢: 139, 445、既定値: 445)
-domain-sidsEnumerate Domain SIDs (will likely forward requests to the DC)
-hashesNTLM hashes, format is LMHASH:NTHASH
-no-passdon’t ask for password (useful when proxying through smbrelayx)
-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

SMB named pipe の LSARPC へ bind し、policy 情報から domain SID を取得します。その SID に RID を付加して lookup を繰り返し、解決できた SID、種類、名前を表示します。-domain-sids は発見した domain SID の出力に重点を置きます。

LSA lookup は名前一覧を返す API ではないため、このコマンドは domain SID に RID を順番に付けた候補 SID を作り、server に名前解決させます。最初に policy handle から account domain SID を取得し、S-1-5-...-RID を一定数ずつ LsarLookupSids に渡すことで user/group/alias を発見します。

多くの RID は存在しないので、STATUS_NONE_MAPPED や STATUS_SOME_NOT_MAPPED は探索中の通常応答です。batch 内の一部だけ解決された 場合も、translated name 配列と domain list の index を正しく対応付ける必要が あります。例外を一括して終了すると RID 空間の最初の穴で列挙が止まります。

結果は directory の完全な object 一覧ではありません。削除済み RID、lookup 権限、RID 上限、別 domain SID によって見え方が変わります。-domain-sids は 発見した domain 情報の収集に用途を寄せますが、推測した SID と server が 返した domain 名を区別して出力することが重要です。

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

dcerpc.v5.transport / lsad / lsat と共通 target parser を使用します。LSALookupSid.dump() が接続から列挙までを所有し、STATUS_SOME_NOT_MAPPED を通常の探索結果として扱う必要があります。