Impacket getArch.py
RPC Endpoint Mapper への接続結果から、対象ホストが 32 ビットか 64 ビットかを推定します。
| 項目 | 内容 |
|---|---|
| 実装 | examples/getArch.py |
| カテゴリ | SMB / MSRPC / NTLM |
| 規模 | 111 行 |
| 配布 | setup.py の scripts=examples/*.py によりスクリプトとしてインストール |
CLI と入力
Section titled “CLI と入力”オプションの最新の定義は python examples/getArch.py -h で確認できます。
| 引数 | 説明 |
|---|---|
-target | |
-targets | input file with targets system to query Arch from (one per line). |
-timeout | socket timeout out when connecting to the target (default 2 sec) |
-debug | Turn DEBUG output ON |
-ts | Adds timestamp to every logging output |
詳細な処理フロー
Section titled “詳細な処理フロー”TCP 135 の EPM transport を作り、NDR64 transfer syntax を含む bind を試します。成功/特定 fault を architecture 判定へ変換し、timeout や到達不能は個別に記録して次 target へ進みます。
仕組みの詳細
Section titled “仕組みの詳細”DCE/RPC は NDR32 と NDR64 の transfer syntax を negotiation できます。この コマンドは TCP 135 の Endpoint Mapper へ接続し、64-bit 側で利用できる transfer syntax を含む bind を試した際の応答から target architecture を 推定します。OS version string や SMB banner を読む方式ではありません。
各 target は独立した transport/socket で検査され、bind ACK、provider rejection、RPC fault、timeout を分類します。期待する syntax を受け入れた 場合と、特定の transfer syntax rejection を返した場合を 64/32 bit の判断へ 写像します。port が閉じている、EPM が無効、middlebox が応答を変えた状態は architecture 判定不能です。
-targets の batch では一台の timeout が他 target を止めないようにし、
入力順と結果を対応させます。この推定は RPC runtime の behavior に依存する
ため、CPU architecture、process architecture、OS installation architecture
を常に同一視しないことが出力解釈の前提です。
主要な実装要素
Section titled “主要な実装要素”| シンボル | 位置 | 責務を追う入口 |
|---|---|---|
TARGETARCH | 39 | __init__()、run() |
Impacket 内部
Section titled “Impacket 内部”| モジュール | 使用する主な名前 |
|---|---|
impacket | version |
impacket.examples | logger |
impacket.dcerpc.v5.rpcrt | DCERPCException |
impacket.dcerpc.v5.transport | DCERPCTransportFactory |
impacket.dcerpc.v5.epm | MSRPC_UUID_PORTMAP |
出力・副作用・必要権限
Section titled “出力・副作用・必要権限”- 照会や認証の試行が中心です。実行回数が多いと監査ログやアカウントロック、対象の負荷に影響します。
失敗経路と後始末
Section titled “失敗経路と後始末”- 失敗時は、名前解決、接続、認証、サービスの状態、権限のどこで止まったかを、プロトコルのステータスから切り分けます。
実装を変更するとき
Section titled “実装を変更するとき”dcerpc.v5.transport / epm / rpcrt に依存し、TARGETARCH.run() が target loop と probe を所有します。network error と architecture 不一致の RPC error を区別してください。
- 構文:
python -m py_compile examples/getArch.py - CLI:
python examples/getArch.py -h - 関連テスト:
tests/SMB_RPC/test_rpcrt.py - 関連テスト:
tests/dcerpc/test_epm.py

