:py:mod:`dissect.target.loaders.mqtt` ===================================== .. py:module:: dissect.target.loaders.mqtt Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: dissect.target.loaders.mqtt.InfoMessage dissect.target.loaders.mqtt.DiskMessage dissect.target.loaders.mqtt.SeekMessage dissect.target.loaders.mqtt.MqttTransferRatePerSecond dissect.target.loaders.mqtt.MqttStream dissect.target.loaders.mqtt.MqttDiagnosticLine dissect.target.loaders.mqtt.MqttConnection dissect.target.loaders.mqtt.Broker dissect.target.loaders.mqtt.MqttLoader Functions ~~~~~~~~~ .. autoapisummary:: :nosignatures: dissect.target.loaders.mqtt.suppress dissect.target.loaders.mqtt.strictly_positive dissect.target.loaders.mqtt.port dissect.target.loaders.mqtt.case Attributes ~~~~~~~~~~ .. autoapisummary:: dissect.target.loaders.mqtt.HAS_PAHO dissect.target.loaders.mqtt.log dissect.target.loaders.mqtt.DISK_INDEX_OFFSET dissect.target.loaders.mqtt.R .. py:data:: HAS_PAHO :value: True .. py:data:: log .. py:data:: DISK_INDEX_OFFSET :value: 9 .. py:data:: R .. py:function:: suppress(func: collections.abc.Callable[Ellipsis, R]) -> collections.abc.Callable[Ellipsis, R | None] .. py:class:: InfoMessage .. py:attribute:: disks :type: list[DiskMessage] .. py:class:: DiskMessage .. py:attribute:: index :type: int :value: 0 .. py:attribute:: sector_size :type: int :value: 0 .. py:attribute:: total_size :type: int :value: 0 .. py:class:: SeekMessage .. py:attribute:: data :type: bytes :value: b'' .. py:class:: MqttTransferRatePerSecond(window_size: int = 10) .. py:attribute:: window_size :value: 10 .. py:attribute:: timestamps :value: [] .. py:attribute:: bytes :value: [] .. py:method:: record(timestamp: float, byte_count: int) -> MqttTransferRatePerSecond .. py:method:: value(current_time: float) -> float .. py:class:: MqttStream(stream: MqttConnection, disk_id: int, size: int | None = None) Bases: :py:obj:`dissect.util.stream.AlignedStream` Basic buffered stream that provides aligned reads. Must be subclassed for various stream implementations. Subclasses can implement: - :meth:`~AlignedStream._read` - :meth:`~AlignedStream._seek` The offset and length for ``_read`` are guaranteed to be aligned for streams of a known size. If your stream has an unknown size (i.e. ``size == None``), reads of length ``-1`` (i.e. read until EOF) will be passed through to your implementation of ``_read``. The only time that overriding ``_seek`` would make sense is if there's no known size of your stream, but still want to provide ``SEEK_END`` functionality. Most subclasses of ``AlignedStream`` take one or more file-like objects as source. Operations on these subclasses, like reading, will modify the source file-like object as a side effect. :param size: The size of the stream. This is used in read and seek operations. ``None`` if unknown. :param align: The alignment size. Read operations are aligned on this boundary. Also determines buffer size. .. automethod:: _read .. automethod:: _seek .. py:attribute:: stream .. py:attribute:: disk_id .. py:class:: MqttDiagnosticLine(connection: MqttConnection, total_peers: int) .. py:attribute:: connection .. py:attribute:: total_peers .. py:method:: display() -> None .. py:method:: start() -> None .. py:class:: MqttConnection(broker: Broker, host: str) .. py:attribute:: broker :value: None .. py:attribute:: host :value: None .. py:attribute:: prev :value: -1 .. py:attribute:: factor :value: 1 .. py:attribute:: prefetch_factor_inc :value: 10 .. py:attribute:: retries :value: 0 .. py:attribute:: info .. py:attribute:: read .. py:method:: topo(peers: int) -> list[str] .. py:class:: Broker(broker: str, port: str, key: str, crt: str, ca: str, case: str, username: str, password: str, **kwargs) .. py:attribute:: broker_host :value: None .. py:attribute:: broker_port :value: None .. py:attribute:: private_key_file :value: None .. py:attribute:: certificate_file :value: None .. py:attribute:: cacert_file :value: None .. py:attribute:: mqtt_client :value: None .. py:attribute:: connected :value: False .. py:attribute:: case :value: None .. py:attribute:: bytes_received :value: 0 .. py:attribute:: monitor :value: False .. py:attribute:: username :value: None .. py:attribute:: password :value: None .. py:attribute:: diskinfo :type: ClassVar[dict] .. py:attribute:: index :type: ClassVar[dict] .. py:attribute:: topo :type: ClassVar[dict] .. py:attribute:: factor :value: 1 .. py:attribute:: command .. py:method:: clear_cache() -> None .. py:method:: read(host: str, disk_id: int, seek_address: int, read_length: int) -> SeekMessage .. py:method:: disk(host: str) -> DiskMessage .. py:method:: peers(host: str) -> list[str] .. py:method:: seek(host: str, disk_id: int, offset: int, flength: int, optimization_strategy: int) -> None .. py:method:: info(host: str) -> None .. py:method:: topology(host: str) -> None .. py:method:: connect() -> None .. py:function:: strictly_positive(value: str) -> int Validates that the provided value is a strictly positive integer. This function is intended to be used as a type for argparse arguments. :param value: The value to validate. :type value: str :returns: The validated integer value. :rtype: int :raises argparse.ArgumentTypeError: If the value is not a strictly positive integer. .. py:function:: port(value: str) -> int Convert a string value to an integer representing a valid port number. This function is intended to be used as a type for argparse arguments. :param value: The string representation of the port number. :type value: str :returns: The port number as an integer. :rtype: int :raises argparse.ArgumentTypeError: If the port number is not an integer or out of the valid range (1-65535). .. py:function:: case(value: str) -> str Validates that the given value is a valid case name consisting of alphanumeric characters and underscores only. This function is intended to be used as a type for argparse arguments. :param value: The case name to validate. :type value: str :returns: The validated case name if it matches the required pattern. :rtype: str :raises argparse.ArgumentTypeError: If the case name does not match the required pattern. .. py:class:: MqttLoader(path: pathlib.Path, **kwargs) Bases: :py:obj:`dissect.target.loader.Loader` Load remote targets through a broker. .. py:attribute:: connection :value: None .. py:attribute:: broker :value: None .. py:attribute:: peers :type: ClassVar[list] :value: [] .. py:method:: detect(path: pathlib.Path) -> bool :staticmethod: Detects wether this ``Loader`` class can load this specific ``path``. :param path: The target path to check. :returns: ``True`` if the ``path`` can be loaded by a ``Loader`` instance. ``False`` otherwise. .. py:method:: find_all(path: pathlib.Path, parsed_path: urllib.parse.ParseResult | None = None) -> collections.abc.Iterator[str] :staticmethod: Finds all targets to load from ``path``. This can be used to open multiple targets from a target path that doesn't necessarily map to files on a disk. For example, a wildcard in a hostname a loader that opens targets from an API or Unix socket, such as the Carbon Black loader. :param path: The location to a target to try and open multiple paths from. :param parsed_path: A URI parsed path to use. :returns: All the target paths found from the source path. .. py:method:: map(target: dissect.target.target.Target) -> None Maps the loaded path into a ``Target``. :param target: The target that we're mapping into.