コンテンツにスキップ

Impacket smbserver.py

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

ローカルディレクトリを SMB1/SMB2 共有として公開します。NTLM/Kerberos 認証や読み取り専用設定も指定できます。

項目内容
実装examples/smbserver.py
カテゴリSMB / MSRPC / NTLM
規模138 行
配布setup.py の scripts=examples/*.py によりスクリプトとしてインストール

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

引数説明
shareNamename of the share to add
sharePathpath of the share to add
-commentshare’s comment to display when asked for shares
-usernameUsername to authenticate clients
-passwordPassword for the Username
-computeraccountnamecomputer account name to authenticate arbitrary clients with signing via NetLogon/Kerberos
-computeraccounthashcomputer account NT hash to authenticate arbitrary clients with signing via NetLogon/Kerberos
-computeraccountaescomputer account AES key to authenticate arbitrary clients with signing via NetLogon/Kerberos
-computeraccountpasswordcomputer account NT hash to authenticate arbitrary clients with signing via NetLogon/Kerberos
-computeraccountdomaincomputer account domain to authenticate arbitrary clients with signing via NetLogon/Kerberos
-dc-ipIP of domain controller to authenticate arbitrary clients with signing via NetLogon/Kerberos
-hashesNTLM hashes for the Username, format is LMHASH:NTHASH
-tsAdds timestamp to every logging output
-debugTurn DEBUG output ON
-ip / --interface-addressip address of listening interface (“0.0.0.0” or ”::” if omitted)
-readonlyOnly allow reading of files
-disablekerberosDo not offer Kerberos authentication
-disablentlmDo not offer NTLM authentication
-portTCP port for listening incoming connections (default 445)
-dropsspDisable NTLM ESS/SSP during negotiation
-6 / --ipv6Listen on IPv6
-smb2supportSMB2 Support (experimental!)
-outputfileOutput file to log smbserver output messages

share 名/path と server option から SimpleSMBServer を構築し、credential/hash、SMB2、listen address/port、authentication policy を設定します。Kerberos 時は machine account と DC 情報を登録し、start() で request loop に入ります。

SimpleSMBServer は local directory を share namespace に割り当て、SMB negotiate、session setup、tree connect、file operation を server 側で処理します。 CLI は share 名/path、listen address/port、SMB2 可否、read-only、認証 policy を server configuration へ変換して request loop を開始します。

NTLM 認証では user と LM/NT hash を credential database に登録し、client の challenge/response を検証します。Kerberos を使う場合は server SPN を表す machine account key と domain/DC 情報が必要です。-disablekerberos と -disablentlm は negotiation 可能な mechanism を変え、両方無効な構成を どのように扱うかを明示する必要があります。

file operation は client path を share root 以下の local path へ安全に解決します。 ..、symlink、case sensitivity、read-only enforcement は protocol access mask だけでなく local filesystem と合わせて確認します。port 445 の bind 権限、 IPv4/IPv6、複数 client の session/file ID、log file の秘密情報も server lifecycle の一部です。

シンボル位置責務を追う入口
module-level entry1トップレベルで引数解析と処理を実行
モジュール使用する主な名前
impacket.exampleslogger
impacketsmbserver, version
impacket.ntlmcompute_lmhash, compute_nthash
  • 照会や認証の試行が中心です。実行回数が多いと監査ログやアカウントロック、対象の負荷に影響します。
  • 待受 socket または長時間 loop を開始します。bind address、port、停止方法、同時接続時の共有状態を確認してください。
  • 停止要求、client 切断、partial read/write、worker 例外で listener 全体が不整合にならないことを確認します。

impacket.smbserver、ntlm.compute_*hash に依存します。トップレベル CLI が server config を直接組み立てます。認証の enable/disable 組み合わせと privileged port の失敗を明示的に扱ってください。