From 4533ba86a8f064f4384fd72586a73ec6b0a6519e Mon Sep 17 00:00:00 2001 From: twiggler Date: Thu, 12 Sep 2024 17:05:10 +0200 Subject: [PATCH] Dis 3281/improved security scheme (#847) Ignoring codecov because feature is POC and subject to design changes. --- dissect/target/loaders/mqtt.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/dissect/target/loaders/mqtt.py b/dissect/target/loaders/mqtt.py index 5deecc7e5..f0962089c 100644 --- a/dissect/target/loaders/mqtt.py +++ b/dissect/target/loaders/mqtt.py @@ -341,9 +341,20 @@ def _on_id(self, hostname: str, payload: bytes) -> None: self.mqtt_client.subscribe(f"{self.case}/{host}/DISKS") self.mqtt_client.subscribe(f"{self.case}/{host}/READ/#") if self.command is not None: + self.mqtt_client.subscribe(f"{self.case}/{host}/CALLID") self.mqtt_client.publish(f"{self.case}/{host}/COMM", self.command.encode("utf-8")) time.sleep(1) + def _on_call_id(self, hostname: str, payload: bytes) -> None: + try: + decoded_payload = payload.decode("utf-8") + except UnicodeDecodeError as e: + log.error(f"Failed to decode payload for hostname {hostname}: {e}") + return + + # The payload with the username and password is comma separated + print(f'"{hostname}",{decoded_payload}') + def _on_log(self, client: mqtt.Client, userdata: Any, log_level: int, message: str) -> None: log.debug(message) @@ -365,6 +376,8 @@ def _on_message(self, client: mqtt.Client, userdata: Any, msg: mqtt.client.MQTTM self._on_read(hostname, tokens, msg.payload) elif response == "ID": self._on_id(hostname, msg.payload) + elif response == "CALLID": + self._on_call_id(hostname, msg.payload) def seek(self, host: str, disk_id: int, offset: int, flength: int, optimization_strategy: int) -> None: length = int(flength / self.factor)