sshmitm.forwarders.exec module

class sshmitm.forwarders.exec.ExecForwarder(session)

Bases: BaseForwarder

Base class for all exec-command-based forwarders (SCP, NETCONF, Mosh, …).

Provides the bidirectional data loop, reliable sendall helper, and channel-teardown logic that all exec-style protocols share. Subclasses must implement client_channel, _forwarded_command, and forward().

Parameters:

session (Session)

close_session(channel)
Parameters:

channel (Channel)

Return type:

None

close_session_with_status(channel, status)
Parameters:
  • channel (Channel)

  • status (int | None)

Return type:

None

handle_client_data(data)
Parameters:

data (bytes)

Return type:

bytes

handle_error(data)
Parameters:

data (bytes)

Return type:

bytes

handle_server_data(data)
Parameters:

data (bytes)

Return type:

bytes

sendall(channel, data, sendfunc)
Parameters:
  • channel (Channel)

  • data (bytes)

  • sendfunc (Callable[[bytes], int])

Return type:

int

class sshmitm.forwarders.exec.ExecHandlerBasePlugin(session)

Bases: ExecForwarder, ABC

Base class for exec handlers discovered via the sshmitm.ExecHandler entry point group.

Subclasses declare their command prefix and optional flags as class attributes instead of calling ExecHandlerRegistry.register_exec_handler() manually.

Parameters:

session (Session)

command_prefix: ClassVar[bytes] = b''
disable_pty: ClassVar[bool] = False
disable_ssh: ClassVar[bool] = False