sshmitm.tutorial.hosts package

Base classes for scenario assets: users, segments, services, hosts, scenarios.

class sshmitm.tutorial.hosts.HTTPService(port, tls=False)

Bases: Service

Parameters:
  • port (int)

  • tls (bool, default: False)

__init__(port, tls=False)
Parameters:
  • port (int)

  • tls (bool, default: False)

protocol: ClassVar[str] = 'HTTP'
class sshmitm.tutorial.hosts.Host

Bases: object

A mock server in the scenario.

Subclass this for each host in the lab. Set class variables to describe the host; override configure(), start(), and stop() to provide mock behaviour.

__init__()
address: ClassVar[str] = ''
configure(session_data)

Inject session values (passwords, keys, secrets) before start.

Parameters:

session_data (dict)

Return type:

None

get_service(protocol)
Parameters:

protocol (str)

Return type:

Service | None

hostname: ClassVar[str] = ''
label: ClassVar[str] = ''
property port_ssh: int | None
segment: ClassVar[type[Segment] | None] = None
services: ClassVar[list[Service]] = []
async start(events)

Start mock services. Store the event queue for later use.

Parameters:

events (Queue[AuthEvent | FileTransferEvent | ExecEvent | SessionEvent | FingerprintEvent])

Return type:

None

start_services(session_data)

Start any non-SSH services (HTTP, Git, SNMP, …) for this host.

Called synchronously by the runner. Returns additional session data to merge (e.g. {"git_server_url": "http://…"}) so that step command/hint templates can reference it.

Override in hosts that run supplemental services alongside SSH.

Parameters:

session_data (dict)

Return type:

dict

async stop()

Stop all running mock services.

Return type:

None

stop_services()

Stop any services started by start_services().

Return type:

None

users: ClassVar[list[type[User]]] = []
class sshmitm.tutorial.hosts.PostgreSQLService(port)

Bases: Service

Parameters:

port (int)

__init__(port)
Parameters:

port (int)

protocol: ClassVar[str] = 'PostgreSQL'
class sshmitm.tutorial.hosts.SFTPService(port)

Bases: Service

Parameters:

port (int)

__init__(port)
Parameters:

port (int)

protocol: ClassVar[str] = 'SFTP'
class sshmitm.tutorial.hosts.SNMPService(port)

Bases: Service

Parameters:

port (int)

__init__(port)
Parameters:

port (int)

protocol: ClassVar[str] = 'SNMP'
class sshmitm.tutorial.hosts.SSHService(port, auth=None)

Bases: Service

Parameters:
  • port (int)

  • auth (list[str] | None, default: None)

__init__(port, auth=None)
Parameters:
  • port (int)

  • auth (list[str] | None, default: None)

protocol: ClassVar[str] = 'SSH'
class sshmitm.tutorial.hosts.Scenario

Bases: object

Groups the hosts and users that belong to one assessment scenario.

hosts: ClassVar[list[type[Host]]] = []
name: ClassVar[str] = ''
users: ClassVar[list[type[User]]] = []
class sshmitm.tutorial.hosts.Segment

Bases: object

A network segment in the lab topology.

name: ClassVar[str] = ''
subnet: ClassVar[str] = ''
class sshmitm.tutorial.hosts.Service(port)

Bases: object

A single network service on a host.

Parameters:

port (int)

__init__(port)
Parameters:

port (int)

protocol: ClassVar[str] = ''
class sshmitm.tutorial.hosts.User

Bases: object

A person who appears in the scenario.

full_name: ClassVar[str] = ''
role: ClassVar[str] = ''
username: ClassVar[str] = ''

Subpackages