sshmitm.apps.mosh module
- class sshmitm.apps.mosh.UdpProxy(key, target_ip, target_port, listen_ip='', listen_port=0, buf_size=1024)
Bases:
object
UdpProxy is a class to act as a proxy server for MOSH (Mobile shell) protocol
This class provides the functionality of a proxy server for the MOSH protocol. MOSH is a protocol for mobile shell sessions, which helps maintain shell sessions when network connection is disrupted.
- Parameters:
key (
str
) – Base64 encoded key to be used for decryption of incoming messagestarget_ip (
str
) – IP of target servertarget_port (
int
) – Port number of target serverlisten_ip (
str
, default:''
) – IP to bind the proxy server (default ‘’)listen_port (
int
, default:0
) – Port number to bind the proxy server (default 0)buf_size (
int
, default:1024
) – buffer size for incoming data (default 1024)
- check_pairing(addr)
Get the destination address to forward incoming messages to.
- Parameters:
addr (
Tuple
[str
,int
]) – Address of incoming message- Return type:
Tuple
[str
,int
]- Returns:
Destination address
- get_bind_port()
Get the port number that the proxy server is bound to.
- Return type:
int
- Returns:
Port number
- receive(buff_size)
Receive incoming messages, decrypt and log the data, and forward it to the target server.
- Parameters:
buff_size (
int
) – buffer size for incoming data- Return type:
None
- start()
Start the proxy server.
- Return type:
None
- thread_receive()
Start a separate thread to receive incoming messages.
- Return type:
None
- sshmitm.apps.mosh.handle_mosh(session, traffic, isclient)
Handle encrypted traffic from Mosh, a mobile shell that serves as a replacement for ssh.
- Parameters:
session (
Session
) – A Session object representing the Mosh connection.traffic (
bytes
) – Encrypted traffic from Mosh.isclient (
bool
) – A boolean value indicating whether the current session is a client session.
- Return type:
bytes
- Returns:
The processed traffic.