コンテンツにスキップ

Impacket exchanger.py

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

Exchange の NSPI に RPC で接続し、アドレス帳の列挙や GUID・DNT による検索を行います。

項目内容
実装examples/exchanger.py
カテゴリMSSQL / Exchange / MQTT
規模1078 行
配布setup.py の scripts=examples/*.py によりスクリプトとしてインストール

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

subcommand: nspi、list-tables、dump-tables、guid-known、dnt-lookup

引数説明
target[[domain/]username[:password]@]
-debugTurn DEBUG and EXTENDED output ON
-tsAdds timestamp to every logging output
-rpc-hostnameA name of the server in GUID (preferred) or NetBIOS name format (see description in the beggining of this file)
-hashesNTLM hashes, format is LMHASH:NTHASH
-countRequest total number of records in each table
-basicAuthenticate with Basic Auth instead of NTLM
-lookup-typeR|Lookup type: MINIMAL - Request limited set of fields (default) EXTENDED - Request extended set of fields FULL - Request all fields for each row GUIDS - Request only GUIDs(選択肢: MINIMAL, EXTENDED, FULL, GUIDS)
-rows-per-requestLimit the number of rows per request(既定値: 50)
-guidDump table with the specified GUID
-output-typeOutput format for binary objects(選択肢: hex, base64、既定値: hex)
-output-fileOutput filename
-guid-fileDump objects using GUIDs from file
-start-dntA DNT to start from(既定値: 500000)
-stop-dntA DNT to lookup to
-nameDump table with the specified name (inc. GAL)

autodiscover/明示 hostname と資格情報から RPC transport を構築し、NSPI bind と STAT 初期化を行います。nspi list-tables、dump-tables、guid-known、dnt-lookup が table/container を選び、property row を page 単位で取得して table/hex/csv 等へ出力します。

NSPI は Exchange Address Book の table/property model を RPC で公開します。 Exchanger は autodiscover または指定 hostname から RPC endpoint/HTTP proxy 情報を決め、資格情報を transport へ設定します。NSPI bind 後は STAT structure が現在の container、codepage、row position を表す cursor になります。

list-tables は hierarchy/container table を読み、address book の container ID と名前を対応付けます。dump-tables は選択 container で property tag set を 指定し、QueryRows を page 単位に繰り返します。各 property は MAPI type に 応じて string、integer、binary、multi-value 等へ decode されます。row count と STAT position を進めないと同じ page を繰り返します。

GUID lookup と DNT lookup は通常 table scan と異なる NSPI request/identifier を使います。GUID/DN/DNT の相互変換では server が返す property absence や codepage を考慮します。output type/file は protocol layer から分離し、binary property を不可逆な表示文字列だけにしないことが後続解析に重要です。

シンボル位置責務を追う入口
Exchanger63__init__()、conenct_mapi()、connect_rpc()、load_autodiscover()、set_credentials()、set_extended_output()、set_output_type()、set_output_file()、print()
NSPIAttacks135__init__()、connect_rpc()、update_stat()、load_htable()、load_htable_stat()、load_htable_containerid()、print_htable()、disconnect()、print_row()、load_props()、req_print_table_rows()、req_print_guid() ほか
ExchangerHelper721__init__()、run()、nspi_run()、nspi_check()、nspi_list_tables()、nspi_dump_tables()、nspi_guid_known()、nspi_dnt_lookup()
モジュール使用する主な名前
impacketuuid, version
impacket.httpAUTH_BASIC
impacket.exampleslogger
impacket.examples.utilsparse_target
impacket.structureparse_bitmask
impacket.dcerpc.v5nspi, transport
impacket.mapi_constantsMAPI_PROPERTIES, PR_CONTAINER_FLAGS_VALUES
impacket.dcerpc.v5.nspiCP_TELETEX, ExchBinaryObject, get_dn_from_guid, get_guid_from_dn
impacket.dcerpc.v5.rpchRPC_PROXY_CONN_A1_0X6BA_ERR, RPC_PROXY_CONN_A1_401_ERR, RPC_PROXY_CONN_A1_404_ERR, RPC_PROXY_HTTP_IN_DATA_401_ERR, RPC_PROXY_REMOTE_NAME_NEEDED_ERR, RPC_PROXY_RPC_OUT_DATA_404_ERR
import 名配布パッケージ経路・宣言状態
sixsix直接 import、宣言済み
  • 照会や認証の試行が中心です。実行回数が多いと監査ログやアカウントロック、対象の負荷に影響します。
  • オプションによりローカルファイルを作成または更新します。既存ファイルの扱いと秘密情報を含む出力の権限を確認してください。
  • 失敗時は、名前解決、接続、認証、サービスの状態、権限のどこで止まったかを、プロトコルのステータスから切り分けます。
  • 後始末に関係する実装として disconnect() があります。新しい早期 return や例外経路でも到達するか確認します。

dcerpc.v5.nspi / transport / rpch、mapi_constants、HTTP Basic/NTLM に依存します。Exchanger が接続、NSPIAttacks が request/row parse、ExchangerHelper が CLI dispatch を担当します。