コンテンツにスキップ

Impacket sambaPipe.py

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

Samba の外部パイプモジュール読み込みを検証するため、共有に .so を配置して名前付きパイプを開きます。

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

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

引数説明
target[[domain/]username[:password]@]
-soso filename to upload and load(必須)
-debugTurn DEBUG output ON
-tsAdds timestamp to every logging output
-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 omitted it will use the domain part (FQDN) specified in the target parameter
-target-ipIP 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
-portDestination port to connect to SMB Server(選択肢: 139, 445、既定値: 445)

SMB 接続後、書き込み可能 share を探索または選択し、指定 shared object を upload します。SMB1/SMB2 の create request で pipe module 名を開き、応答 status を検査します。処理後は可能な範囲で upload file を削除します。

Samba の一部構成では named pipe 名が外部 RPC module の library 名解決に関係し、 writable share に配置した shared object が読み込まれる経路が問題になります。 このコマンドはまず SMB session を作り、share を列挙して書き込み可能な場所を 確認し、指定 .so を remote path へ転送します。

次に pipe create/open request を低水準 SMB1/SMB2 packet として構築します。 通常 file open と named pipe open では path namespace、create options、 impersonation level が異なるため、dialect ごとの structure を明示的に設定します。 server の status code から module lookup/open がどこまで進んだかを判断します。

upload 成功と pipe open 成功は別段階であり、途中失敗では配置 file が残り得ます。 share の writable 判定は一時 file の create/delete まで確認し、既存 file を 上書きしません。対象 Samba version/configuration で挙動が異なるため、拒否応答は 単なる credential failure ではなく mitigation/非該当の可能性があります。

シンボル位置責務を追う入口
PIPEDREAM50__init__()、isShareWritable()、findSuitableShare()、uploadSoFile()、create()、openPipe()、run()
モジュール使用する主な名前
impacketversion
impacket.exampleslogger
impacket.examples.utilsparse_target
impacket.nt_errorsSTATUS_SUCCESS
impacket.smbFILE_DIRECTORY_FILE, FILE_NON_DIRECTORY_FILE, FILE_OPEN, FILE_READ_DATA, FILE_SHARE_READ, FILE_WRITE_DATA, SMB, SMBCommand, SMBNtCreateAndX_Data, SMBNtCreateAndX_Parameters, SMB_DIALECT
impacket.smb3structsSMB2Create, SMB2Create_Response, SMB2Packet, SMB2_CREATE, SMB2_FLAGS_DFS_OPERATIONS, SMB2_IL_IMPERSONATION, SMB2_OPLOCK_LEVEL_NONE, SMB2_SESSION_FLAG_ENCRYPT_DATA
impacket.smbconnectionSMBConnection
impacket.dcerpc.v5srvs, transport
  • 対象の状態を変更する操作があります。変更前に対象名や SID、パスを確認してください。
  • remote service、task、file、share、WMI/RPC resource などの一時資源を利用する経路があります。異常終了時の回収も動作契約です。
  • 失敗時は、名前解決、接続、認証、サービスの状態、権限のどこで止まったかを、プロトコルのステータスから切り分けます。
  • 明示的な cleanup 名がなくても finally 相当の経路と protocol handle の close/delete を確認します。

低水準 smb / smb3structs と SMBConnection に依存し、PIPEDREAM が share probe、upload、create/open を担当します。dialect と path semantics の差、失敗時 cleanup を確認してください。