Impacket DumpNTLMInfo.py
SMB または RPC で NTLM のネゴシエーションを行い、チャレンジに含まれる情報、SMB の設定、時刻などを表示します。
| 項目 | 内容 |
|---|---|
| 実装 | examples/DumpNTLMInfo.py |
| カテゴリ | SMB / MSRPC / NTLM |
| 規模 | 675 行 |
| 配布 | setup.py の scripts=examples/*.py によりスクリプトとしてインストール |
CLI と入力
Section titled “CLI と入力”オプションの最新の定義は python examples/DumpNTLMInfo.py -h で確認できます。
| 引数 | 説明 |
|---|---|
target | |
-debug | Turn DEBUG output ON |
-ts | Adds timestamp to every logging output |
-target-ip | IP 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 |
-port | Destination port to connect to SMB/RPC Server(既定値: 445) |
-protocol | Protocol to use (SMB or RPC). Default is SMB, port 135 uses RPC normally.(選択肢: SMB, RPC) |
詳細な処理フロー
Section titled “詳細な処理フロー”protocol/port から SMB1、SMB2/3、RPC の実装を選び、negotiate、NTLM challenge 取得、必要に応じて anonymous authenticate の順に進みます。DumpNtlm が challenge と protocol 固有応答を共通表示へ変換します。
仕組みの詳細
Section titled “仕組みの詳細”このコマンドは完全な authenticated session を作る前の negotiation 情報を 観察します。SMB では dialect negotiation と Session Setup の途中まで進み、 server が返す NTLM challenge を取り出します。RPC では Endpoint Mapper 等へ bind/request を送り、NTLM security provider が生成する challenge を同様に 解析します。
NTLM challenge の target info は AV pair の集合で、NetBIOS/DNS computer 名、
domain 名、timestamp、flags 等が入ります。DumpNtlm は protocol 固有 packet
から challenge token を切り出した後、この共通構造へ渡します。SMB ではさらに
dialect、signing required/enabled、server time、最大 read/write size などを
negotiate response から表示します。
SMB1 と SMB2/3 は packet header、command、capability の表現が違うため、
SMB1 と SMB3 が低水準 request を別実装しています。wildcard negotiate
から dialect を確定し、同じ socket 上で次 packet を正しく decode することが
重要です。null session の成功/失敗は policy 情報の一部ですが、認証可能な
一般 user の有無を示すものではありません。
主要な実装要素
Section titled “主要な実装要素”| シンボル | 位置 | 責務を追う入口 |
|---|---|---|
RPC | 65 | __init__()、GetChallange() |
SMB1 | 119 | __init__()、GetNegotiateResponse()、GetChallange()、Authenticate()、send()、receive() |
SMB3 | 277 | __init__()、GetNegotiateResponse()、GetChallange()、Authenticate()、send()、receive() |
SmbConnection | 398 | __init__()、IsSmb1Enabled()、NegotiateSession()、GetChallange()、Authenticate() |
DumpNtlm | 483 | __init__()、DisplayInfo()、DisplayRpcInfo()、DisplaySmbInfo()、DisplaySigning()、DisplayDialect()、DisplayIo()、DisplayTime()、DisplayChallangeInfo()、DisplayNullSession() |
Impacket 内部
Section titled “Impacket 内部”| モジュール | 使用する主な名前 |
|---|---|
impacket | nmb, ntlm, version |
impacket.examples | logger |
impacket.smb | NewSMBPacket, SMB, SMBCommand, SMBExtended_Security_Data, SMBExtended_Security_Parameters, SMBNTLMDialect_Data, SMBNTLMDialect_Parameters, SMBSessionSetupAndXResponse_Parameters, SMBSessionSetupAndX_Extended_Data, SMBSessionSetupAndX_Extended_Parameters, SMBSessionSetupAndX_Extended_Response_Data, SMBSessionSetupAndX_Extended_Response_Parameters, SMB_DIALECT, UnsupportedFeature |
impacket.smb3structs | * |
impacket.spnego | SPNEGO_NegTokenInit, SPNEGO_NegTokenResp, TypesMech |
impacket.nt_errors | STATUS_MORE_PROCESSING_REQUIRED, STATUS_SUCCESS |
impacket.uuid | uuidtup_to_bin |
impacket.dcerpc.v5 | epm, transport |
impacket.dcerpc.v5.rpcrt | * |
外部パッケージ(直接使用)
Section titled “外部パッケージ(直接使用)”| import 名 | 配布パッケージ | 経路・宣言状態 |
|---|---|---|
six | six | 直接 import、宣言済み |
出力・副作用・必要権限
Section titled “出力・副作用・必要権限”- 照会や認証の試行が中心です。実行回数が多いと監査ログやアカウントロック、対象の負荷に影響します。
失敗経路と後始末
Section titled “失敗経路と後始末”- 失敗時は、名前解決、接続、認証、サービスの状態、権限のどこで止まったかを、プロトコルのステータスから切り分けます。
実装を変更するとき
Section titled “実装を変更するとき”低水準 smb / smb3structs / ntlm / spnego、dcerpc.v5.rpcrt / transport / epm に依存します。標準 SMBConnection より下位を意図的に扱うため、packet field と dialect ごとの分岐を保ってください。
- 構文:
python -m py_compile examples/DumpNTLMInfo.py - CLI:
python examples/DumpNTLMInfo.py -h - 関連テスト:
tests/SMB_RPC/test_rpcrt.py - 関連テスト:
tests/SMB_RPC/test_smb.py - 関連テスト:
tests/SMB_RPC/test_smbserver.py - 関連テスト:
tests/SMB_RPC/test_spnego.py - 関連テスト:
tests/misc/test_dcerpc_v5_ndr.py

