basic_remote_shell

Entrypoint.

usage: basic_remote_shell [-h] [-k KEY] url
url

URL to connect to

-h, --help

show this help message and exit

-k <key>, --key <key>

Filename of private key


Minimum code needed to connect to a OpenSSH Server.

class basic_remote_shell.Message(initial_bytes=b'')

Message in protocol.

add_binary(s: bytes) None

Write the len then the data.

add_int(n: int) None

Write a int.

add_mpint(n: int) None

Write a mpint.

get_binary() bytes

Read a len then that many bytes.

get_boolean() bool

Read a bool.

get_bytes(n: int) bytes

Read bytes.

get_int() int

Read a int.

get_mpint() int

Read a mpint.

get_remainder() bytes

Get bytes after position.

get_so_far() bytes

Get bytes before position.

class basic_remote_shell.Packetizer(socket: socket.socket)

Implement protocol packetizing.

read_message() Tuple[bytes, basic_remote_shell.Message]

Read a message.

send_message(data: bytes) None

Send a message.

set_inbound_cipher(block_engine: cryptography.hazmat.primitives.ciphers.base.CipherContext, block_size: int, mac_engine: Callable[[], Any], mac_size: int, mac_key: bytes) None

Set the inbound Cipher (must be called).

set_outbound_cipher(block_engine: cryptography.hazmat.primitives.ciphers.base.CipherContext, block_size: int, mac_engine: Callable[[], Any], mac_size: int, mac_key: bytes, sdctr: bool = False) None

Set the outbound Cipher (must be called).

basic_remote_shell.compute_key(id: bytes, nbytes: int, k: int, h: bytes, session_id: bytes) bytes

Serialise key to bytes.

basic_remote_shell.connect(username: str, private_key_file: str = '~/.ssh/id_rsa', host: str = 'localhost', port: int = 22) None

Connect to server.