Skip to content

Commit

Permalink
Dis 3281/improved security scheme (#847)
Browse files Browse the repository at this point in the history
Ignoring codecov because feature is POC and subject to design changes.
  • Loading branch information
twiggler authored Sep 12, 2024
1 parent acb8d15 commit 4533ba8
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions dissect/target/loaders/mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
Expand Down

0 comments on commit 4533ba8

Please sign in to comment.