sshmitm.plugins.sftp.store_file module

class sshmitm.plugins.sftp.store_file.SFTPHandlerStoragePlugin(sftp, filename)

Bases: SFTPHandlerPlugin

Saves files transferred via SFTP to the local file system.

For each intercepted SFTP file handle, data is written to <log-dir>/<session-id>/sftp/ under a UUID-based filename. The original transfer continues unmodified — storage is transparent to both client and server.

Usage example

ssh-mitm server --sftp-handler store_file --store-sftp-files --log-dir /tmp/sftp-logs

Notes

  • --log-dir must be configured; without it no files are stored even if --store-sftp-files is set.

  • Each file is saved with a UUID filename. The original filename is logged alongside the UUID so transfers can be correlated.

Parameters:
__init__(sftp, filename)

Creates the storage directory and opens the output file for writing.

Parameters:
  • sftp (SFTPBaseHandle) – the SFTP file handle for the intercepted transfer.

  • filename (str) – the original filename as requested by the client.

close()
Return type:

None

handle_data(data, *, offset=None, length=None)
Parameters:
  • data (bytes)

  • offset (int | None, default: None)

  • length (int | None, default: None)

Return type:

bytes

classmethod parser_arguments()
Return type:

None