sshmitm.forwarders.tunnel module

class sshmitm.forwarders.tunnel.BaseClientTunnelHandler(session)

Bases: object

Parameters:

session (Session)

class sshmitm.forwarders.tunnel.LocalPortForwardingBaseForwarder(args=None, namespace=None, **kwargs)

Bases: BaseModule

Parameters:
  • args (Optional[Sequence[str]], default: None)

  • namespace (Optional[Namespace], default: None)

  • kwargs (Any)

class sshmitm.forwarders.tunnel.LocalPortForwardingForwarder(session, chanid, origin, destination)

Bases: TunnelForwarder, LocalPortForwardingBaseForwarder

Handles tunnel forwarding when the client is requesting a tunnel connection

Then forward traffic between direct-tcpip channels connecting to local and to remote through the ssh-mitm
  • implements Proxyjump (-W / -J) feature, client side port forwarding (-L)

Parameters:
  • session (Session)

  • chanid (int)

  • origin (Optional[Tuple[str, int]])

  • destination (Optional[Tuple[str, int]])

run()

Method representing the thread’s activity.

You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.

Return type:

None

classmethod setup(session)
Parameters:

session (Session)

Return type:

None

class sshmitm.forwarders.tunnel.RemotePortForwardingBaseForwarder(args=None, namespace=None, **kwargs)

Bases: BaseModule

Parameters:
  • args (Optional[Sequence[str]], default: None)

  • namespace (Optional[Namespace], default: None)

  • kwargs (Any)

class sshmitm.forwarders.tunnel.RemotePortForwardingForwarder(session, server_interface, destination)

Bases: RemotePortForwardingBaseForwarder

Handles Tunnel forwarding when the server is requesting a tunnel connection

Actually just used to wrap data around a handler to parse to the transport.request_port_forward -> that is why it does not inherit the TunnelForwarder; it just uses it in the handler

Parameters:
close()
Return type:

None

handler(channel, origin, destination)
Parameters:
  • channel (Channel)

  • origin (Optional[Tuple[str, int]])

  • destination (Optional[Tuple[str, int]])

Return type:

None

join()
Return type:

None

class sshmitm.forwarders.tunnel.TunnelForwarder(local_ch, remote_ch)

Bases: Thread

Parameters:
  • local_ch (Union[socket, Channel, None])

  • remote_ch (Union[socket, Channel, None])

close()

Comparable with Channels and Sockets

Return type:

None

close_channel(channel)
Parameters:

channel (Union[socket, Channel])

Return type:

None

handle_data(data)
Parameters:

data (bytes)

Return type:

bytes

handle_data_from_local(data)
Parameters:

data (bytes)

Return type:

bytes

handle_data_from_remote(data)
Parameters:

data (bytes)

Return type:

bytes

run()

Method representing the thread’s activity.

You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.

Return type:

None

tunnel(chunk_size=1024)

Connect two SSH channels (socket like objects).

Parameters:

chunk_size (int, default: 1024)

Return type:

None