sshmitm.plugins.scp.store_file module

SCPStorageForwarder: store transferred files from SCP

SCPStorageForwarder is a class that is derived from SCPForwarder. This class provides a capability to store the transferred files from SCP (secure copy) to the file system.

Attributes: file_id (str): A unique identifier for each file, generated using uuid. scp_storage_dir (str): A path to the directory where files are stored.

Methods: parser_arguments: This method adds a command line argument ‘–store-scp-files’ for storing SCP files to the file system. init: This method initializes the SCPStorageForwarder class. It creates a scp_storage_dir if it doesn’t exist. process_data: This method stores the data transmitted during SCP file transfer to the file system. The files are stored in the scp_storage_dir directory.

class sshmitm.plugins.scp.store_file.SCPStorageForwarder(session)

Bases: SCPForwarder

Saves files transferred via SCP to the local file system.

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

Usage example

ssh-mitm server --scp-forwarder store_file --store-scp-files --log-dir /tmp/scp-logs

Notes

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

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

  • Non-interactive SSH command data can also be captured with --store-command-data; output is written to <log-dir>/<session-id>/command/.

Parameters:

session (Session)

__init__(session)

Resolves the storage directory from the session log path.

Parameters:

session (Session) – the active SSH session being intercepted.

classmethod parser_arguments()
Return type:

None

process_command_data(command, data, isclient)
Parameters:
  • command (bytes)

  • data (bytes)

  • isclient (bool)

Return type:

bytes

process_data(data)
Parameters:

data (bytes)

Return type:

bytes

store_command_data(file_id, data, suffix)
Parameters:
  • file_id (str)

  • data (bytes)

  • suffix (str)

Return type:

None