コンテンツにスキップ

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

ドメイン内のホストを探し、SMB セッションとログオンユーザーを調べて、指定ユーザーの接続先を見つけます。

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

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

引数説明
identity[domain/]username[:password]
-userFilter output by this user
-usersinput file with list of users to filter to output for
-targettarget system to query info from. If not specified script will run in domain mode.
-targetsinput file with targets system to query info from (one per line). If not specified script will run in domain mode.
-noloopStop after the first probe
-delayseconds delay between starting each batch probe (default 10 seconds)
-max-connectionsMax amount of connections to keep opened (default 1000)
-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. If ommited it use the domain part (FQDN) specified in the target parameter

LDAP/RPC から候補 machine または入力 target list を作り、worker thread と queue で各ホストへ接続します。WKST/SRVS/SAMR を使って session と user を収集し、filter に一致した結果を表示します。既定は周期実行、-noloop で一巡して終了します。

目的は host の単純な生存確認ではなく、「指定 user がどの machine に session または logon を持つか」を横断的に探すことです。最初に domain から machine 候補を得るか、-target(s) の明示リストを読み、別途 -user(s) から探したい identity の filter を構築します。

各 worker は SMB/RPC で対象へ接続し、Server Service の session 情報と Workstation Service の logged-on user 情報を取得します。この二つは観測する 状態が違い、前者は network session、後者は machine 側で認識される user です。 結果を統合して filter に一致した host/user/source を表示しますが、権限不足で 片方だけ取得できる場合もあります。

queue、接続数上限、delay、loop は大規模 domain で負荷と取りこぼしを制御する ための仕組みです。worker 例外で queue item が未完了になったり、停止 event 後に 新規接続を始めたりしないことが重要です。-noloop は一巡後に終わるため、 継続監視と snapshot の意味を混同しないでください。

シンボル位置責務を追う入口
USERENUM111__init__()、getDomainMachines()、getTargets()、filterUsers()、run()、getSessions()、getLoggedIn()、stop()
checkMachines()76モジュール関数
モジュール使用する主な名前
impacket.exampleslogger
impacket.examples.utilsparse_identity
impacketversion
impacket.smbconnectionSessionError
impacket.dcerpc.v5samr, srvs, transport, wkst
impacket.dcerpc.v5.ndrNULL
impacket.dcerpc.v5.rpcrtDCERPCException
impacket.nt_errorsSTATUS_MORE_ENTRIES
  • 照会や認証の試行が中心です。実行回数が多いと監査ログやアカウントロック、対象の負荷に影響します。
  • 失敗時は、名前解決、接続、認証、サービスの状態、権限のどこで止まったかを、プロトコルのステータスから切り分けます。
  • 後始末に関係する実装として stop() があります。新しい早期 return や例外経路でも到達するか確認します。

smbconnection、dcerpc.v5.wkst / srvs / samr、threading/queue に依存します。USERENUM.stop()、接続上限、delay の扱いは大量接続を避けるための重要な制御です。