From 661d0a8669bf2309993b7b2fd0922852c4d5d0e6 Mon Sep 17 00:00:00 2001 From: Nex Date: Fri, 12 Aug 2022 16:29:43 +0200 Subject: [PATCH] Using Union type hints in order to support older versions of Python --- mvt/android/modules/adb/chrome_history.py | 3 ++- mvt/android/modules/adb/dumpsys_appops.py | 3 ++- .../modules/adb/dumpsys_battery_daily.py | 3 ++- mvt/android/modules/adb/files.py | 3 ++- mvt/android/modules/adb/packages.py | 3 ++- mvt/android/modules/adb/sms.py | 3 ++- mvt/android/modules/adb/whatsapp.py | 3 ++- mvt/android/modules/bugreport/appops.py | 3 ++- .../modules/bugreport/battery_daily.py | 3 ++- mvt/android/modules/bugreport/packages.py | 3 ++- mvt/common/indicators.py | 23 ++++++++++--------- mvt/common/module.py | 4 ++-- .../modules/backup/configuration_profiles.py | 3 ++- mvt/ios/modules/backup/profile_events.py | 3 ++- mvt/ios/modules/fs/analytics.py | 3 ++- mvt/ios/modules/fs/analytics_ios_versions.py | 3 ++- mvt/ios/modules/fs/cache_files.py | 3 ++- mvt/ios/modules/fs/filesystem.py | 3 ++- mvt/ios/modules/fs/safari_favicon.py | 3 ++- mvt/ios/modules/fs/shutdownlog.py | 3 ++- mvt/ios/modules/fs/version_history.py | 3 ++- mvt/ios/modules/fs/webkit_indexeddb.py | 3 ++- mvt/ios/modules/fs/webkit_localstorage.py | 3 ++- mvt/ios/modules/mixed/calls.py | 3 ++- mvt/ios/modules/mixed/chrome_favicon.py | 3 ++- mvt/ios/modules/mixed/chrome_history.py | 3 ++- mvt/ios/modules/mixed/firefox_favicon.py | 3 ++- mvt/ios/modules/mixed/firefox_history.py | 3 ++- mvt/ios/modules/mixed/idstatuscache.py | 3 ++- mvt/ios/modules/mixed/interactionc.py | 3 ++- mvt/ios/modules/mixed/locationd.py | 3 ++- mvt/ios/modules/mixed/osanalytics_addaily.py | 3 ++- mvt/ios/modules/mixed/safari_browserstate.py | 3 ++- mvt/ios/modules/mixed/safari_history.py | 3 ++- mvt/ios/modules/mixed/shortcuts.py | 3 ++- mvt/ios/modules/mixed/sms.py | 3 ++- mvt/ios/modules/mixed/sms_attachments.py | 3 ++- mvt/ios/modules/mixed/tcc.py | 3 ++- mvt/ios/modules/mixed/whatsapp.py | 3 ++- mvt/ios/modules/net_base.py | 3 ++- 40 files changed, 90 insertions(+), 51 deletions(-) diff --git a/mvt/android/modules/adb/chrome_history.py b/mvt/android/modules/adb/chrome_history.py index ccaef8f..8a51bbb 100644 --- a/mvt/android/modules/adb/chrome_history.py +++ b/mvt/android/modules/adb/chrome_history.py @@ -6,6 +6,7 @@ import logging import os import sqlite3 +from typing import Union from mvt.common.utils import (convert_chrometime_to_unix, convert_timestamp_to_iso) @@ -26,7 +27,7 @@ class ChromeHistory(AndroidExtraction): results_path=results_path, fast_mode=fast_mode, log=log, results=results) - def serialize(self, record: dict) -> dict | list: + def serialize(self, record: dict) -> Union[dict, list]: return { "timestamp": record["isodate"], "module": self.__class__.__name__, diff --git a/mvt/android/modules/adb/dumpsys_appops.py b/mvt/android/modules/adb/dumpsys_appops.py index ab70b8f..e8b8b17 100644 --- a/mvt/android/modules/adb/dumpsys_appops.py +++ b/mvt/android/modules/adb/dumpsys_appops.py @@ -4,6 +4,7 @@ # https://license.mvt.re/1.1/ import logging +from typing import Union from mvt.android.parsers.dumpsys import parse_dumpsys_appops @@ -23,7 +24,7 @@ class DumpsysAppOps(AndroidExtraction): results_path=results_path, fast_mode=fast_mode, log=log, results=results) - def serialize(self, record: dict) -> dict | list: + def serialize(self, record: dict) -> Union[dict, list]: records = [] for perm in record["permissions"]: if "entries" not in perm: diff --git a/mvt/android/modules/adb/dumpsys_battery_daily.py b/mvt/android/modules/adb/dumpsys_battery_daily.py index 5884903..55d28d3 100644 --- a/mvt/android/modules/adb/dumpsys_battery_daily.py +++ b/mvt/android/modules/adb/dumpsys_battery_daily.py @@ -4,6 +4,7 @@ # https://license.mvt.re/1.1/ import logging +from typing import Union from mvt.android.parsers import parse_dumpsys_battery_daily @@ -21,7 +22,7 @@ class DumpsysBatteryDaily(AndroidExtraction): results_path=results_path, fast_mode=fast_mode, log=log, results=results) - def serialize(self, record: dict) -> dict | list: + def serialize(self, record: dict) -> Union[dict, list]: return { "timestamp": record["from"], "module": self.__class__.__name__, diff --git a/mvt/android/modules/adb/files.py b/mvt/android/modules/adb/files.py index bb88fb6..eb43175 100644 --- a/mvt/android/modules/adb/files.py +++ b/mvt/android/modules/adb/files.py @@ -7,6 +7,7 @@ import datetime import logging import os import stat +from typing import Union from mvt.common.utils import convert_timestamp_to_iso @@ -34,7 +35,7 @@ class Files(AndroidExtraction): log=log, results=results) self.full_find = False - def serialize(self, record: dict) -> dict | list: + def serialize(self, record: dict) -> Union[dict, list]: if "modified_time" in record: return { "timestamp": record["modified_time"], diff --git a/mvt/android/modules/adb/packages.py b/mvt/android/modules/adb/packages.py index a2436a0..abf206b 100644 --- a/mvt/android/modules/adb/packages.py +++ b/mvt/android/modules/adb/packages.py @@ -4,6 +4,7 @@ # https://license.mvt.re/1.1/ import logging +from typing import Union from rich.console import Console from rich.progress import track @@ -78,7 +79,7 @@ class Packages(AndroidExtraction): results_path=results_path, fast_mode=fast_mode, log=log, results=results) - def serialize(self, record: dict) -> dict | list: + def serialize(self, record: dict) -> Union[dict, list]: records = [] timestamps = [ diff --git a/mvt/android/modules/adb/sms.py b/mvt/android/modules/adb/sms.py index 74b29d7..4f3f93c 100644 --- a/mvt/android/modules/adb/sms.py +++ b/mvt/android/modules/adb/sms.py @@ -6,6 +6,7 @@ import logging import os import sqlite3 +from typing import Union from mvt.android.parsers.backup import (AndroidBackupParsingError, parse_tar_for_sms) @@ -54,7 +55,7 @@ class SMS(AndroidExtraction): self.sms_db_type = 0 - def serialize(self, record: dict) -> dict | list: + def serialize(self, record: dict) -> Union[dict, list]: body = record["body"].replace("\n", "\\n") return { "timestamp": record["isodate"], diff --git a/mvt/android/modules/adb/whatsapp.py b/mvt/android/modules/adb/whatsapp.py index 1445201..a715749 100644 --- a/mvt/android/modules/adb/whatsapp.py +++ b/mvt/android/modules/adb/whatsapp.py @@ -7,6 +7,7 @@ import base64 import logging import os import sqlite3 +from typing import Union from mvt.common.utils import check_for_links, convert_timestamp_to_iso @@ -26,7 +27,7 @@ class Whatsapp(AndroidExtraction): results_path=results_path, fast_mode=fast_mode, log=log, results=results) - def serialize(self, record: dict) -> dict | list: + def serialize(self, record: dict) -> Union[dict, list]: text = record["data"].replace("\n", "\\n") return { "timestamp": record["isodate"], diff --git a/mvt/android/modules/bugreport/appops.py b/mvt/android/modules/bugreport/appops.py index 1fad632..e9d8edf 100644 --- a/mvt/android/modules/bugreport/appops.py +++ b/mvt/android/modules/bugreport/appops.py @@ -4,6 +4,7 @@ # https://license.mvt.re/1.1/ import logging +from typing import Union from mvt.android.parsers import parse_dumpsys_appops @@ -21,7 +22,7 @@ class Appops(BugReportModule): results_path=results_path, fast_mode=fast_mode, log=log, results=results) - def serialize(self, record: dict) -> dict | list: + def serialize(self, record: dict) -> Union[dict, list]: records = [] for perm in record["permissions"]: if "entries" not in perm: diff --git a/mvt/android/modules/bugreport/battery_daily.py b/mvt/android/modules/bugreport/battery_daily.py index cd42a4c..c22a2fd 100644 --- a/mvt/android/modules/bugreport/battery_daily.py +++ b/mvt/android/modules/bugreport/battery_daily.py @@ -4,6 +4,7 @@ # https://license.mvt.re/1.1/ import logging +from typing import Union from mvt.android.parsers import parse_dumpsys_battery_daily @@ -21,7 +22,7 @@ class BatteryDaily(BugReportModule): results_path=results_path, fast_mode=fast_mode, log=log, results=results) - def serialize(self, record: dict) -> dict | list: + def serialize(self, record: dict) -> Union[dict, list]: return { "timestamp": record["from"], "module": self.__class__.__name__, diff --git a/mvt/android/modules/bugreport/packages.py b/mvt/android/modules/bugreport/packages.py index 7742d2e..3299a50 100644 --- a/mvt/android/modules/bugreport/packages.py +++ b/mvt/android/modules/bugreport/packages.py @@ -5,6 +5,7 @@ import logging import re +from typing import Union from mvt.android.modules.adb.packages import (DANGEROUS_PERMISSIONS, DANGEROUS_PERMISSIONS_THRESHOLD, @@ -24,7 +25,7 @@ class Packages(BugReportModule): results_path=results_path, fast_mode=fast_mode, log=log, results=results) - def serialize(self, record: dict) -> dict | list: + def serialize(self, record: dict) -> Union[dict, list]: records = [] timestamps = [ diff --git a/mvt/common/indicators.py b/mvt/common/indicators.py index 51ac456..9911e68 100644 --- a/mvt/common/indicators.py +++ b/mvt/common/indicators.py @@ -6,6 +6,7 @@ import json import logging import os +from typing import Union from appdirs import user_data_dir @@ -198,7 +199,7 @@ class Indicators: self._check_stix2_env_variable() self.log.info("Loaded a total of %d unique indicators", self.total_ioc_count) - def get_iocs(self, ioc_type: str) -> dict | None: + def get_iocs(self, ioc_type: str) -> Union[dict, None]: for ioc_collection in self.ioc_collections: for ioc in ioc_collection.get(ioc_type, []): yield { @@ -208,7 +209,7 @@ class Indicators: "stix2_file_name": ioc_collection["stix2_file_name"], } - def check_domain(self, url: str) -> dict | None: + def check_domain(self, url: str) -> Union[dict, None]: """Check if a given URL matches any of the provided domain indicators. :param url: URL to match against domain indicators @@ -282,7 +283,7 @@ class Indicators: return None - def check_domains(self, urls: list) -> dict | None: + def check_domains(self, urls: list) -> Union[dict, None]: """Check a list of URLs against the provided list of domain indicators. :param urls: List of URLs to check against domain indicators @@ -300,7 +301,7 @@ class Indicators: return None - def check_process(self, process: str) -> dict | None: + def check_process(self, process: str) -> Union[dict, None]: """Check the provided process name against the list of process indicators. @@ -327,7 +328,7 @@ class Indicators: return None - def check_processes(self, processes: list) -> dict | None: + def check_processes(self, processes: list) -> Union[dict, None]: """Check the provided list of processes against the list of process indicators. @@ -346,7 +347,7 @@ class Indicators: return None - def check_email(self, email: str) -> dict | None: + def check_email(self, email: str) -> Union[dict, None]: """Check the provided email against the list of email indicators. :param email: Email address to check against email indicators @@ -365,7 +366,7 @@ class Indicators: return None - def check_file_name(self, file_name: str) -> dict | None: + def check_file_name(self, file_name: str) -> Union[dict, None]: """Check the provided file name against the list of file indicators. :param file_name: File name to check against file @@ -385,7 +386,7 @@ class Indicators: return None - def check_file_path(self, file_path: str) -> dict | None: + def check_file_path(self, file_path: str) -> Union[dict, None]: """Check the provided file path against the list of file indicators (both path and name). :param file_path: File path or file name to check against file @@ -410,7 +411,7 @@ class Indicators: return None - def check_profile(self, profile_uuid: str) -> dict | None: + def check_profile(self, profile_uuid: str) -> Union[dict, None]: """Check the provided configuration profile UUID against the list of indicators. :param profile_uuid: Profile UUID to check against configuration profile indicators @@ -429,7 +430,7 @@ class Indicators: return None - def check_file_hash(self, file_hash: str) -> dict | None: + def check_file_hash(self, file_hash: str) -> Union[dict, None]: """Check the provided SHA256 file hash against the list of indicators. :param file_hash: SHA256 hash to check @@ -448,7 +449,7 @@ class Indicators: return None - def check_app_id(self, app_id: str) -> dict | None: + def check_app_id(self, app_id: str) -> Union[dict, None]: """Check the provided app identifier (typically an Android package name) against the list of indicators. diff --git a/mvt/common/module.py b/mvt/common/module.py index 0533d80..673e51f 100644 --- a/mvt/common/module.py +++ b/mvt/common/module.py @@ -7,7 +7,7 @@ import csv import logging import os import re -from typing import Callable +from typing import Callable, Union import simplejson as json @@ -106,7 +106,7 @@ class MVTModule: with open(detected_json_path, "w", encoding="utf-8") as handle: json.dump(self.detected, handle, indent=4, default=str) - def serialize(self, record: dict) -> dict | list: + def serialize(self, record: dict) -> Union[dict, list]: raise NotImplementedError @staticmethod diff --git a/mvt/ios/modules/backup/configuration_profiles.py b/mvt/ios/modules/backup/configuration_profiles.py index 3d2932b..26b9360 100644 --- a/mvt/ios/modules/backup/configuration_profiles.py +++ b/mvt/ios/modules/backup/configuration_profiles.py @@ -7,6 +7,7 @@ import logging import os import plistlib from base64 import b64encode +from typing import Union from mvt.common.utils import convert_timestamp_to_iso @@ -26,7 +27,7 @@ class ConfigurationProfiles(IOSExtraction): results_path=results_path, fast_mode=fast_mode, log=log, results=results) - def serialize(self, record: dict) -> dict | list: + def serialize(self, record: dict) -> Union[dict, list]: if not record["install_date"]: return {} diff --git a/mvt/ios/modules/backup/profile_events.py b/mvt/ios/modules/backup/profile_events.py index 8451ff6..0325460 100644 --- a/mvt/ios/modules/backup/profile_events.py +++ b/mvt/ios/modules/backup/profile_events.py @@ -5,6 +5,7 @@ import logging import plistlib +from typing import Union from mvt.common.utils import convert_timestamp_to_iso @@ -27,7 +28,7 @@ class ProfileEvents(IOSExtraction): results_path=results_path, fast_mode=fast_mode, log=log, results=results) - def serialize(self, record: dict) -> dict | list: + def serialize(self, record: dict) -> Union[dict, list]: return { "timestamp": record.get("timestamp"), "module": self.__class__.__name__, diff --git a/mvt/ios/modules/fs/analytics.py b/mvt/ios/modules/fs/analytics.py index 83c0587..a27056c 100644 --- a/mvt/ios/modules/fs/analytics.py +++ b/mvt/ios/modules/fs/analytics.py @@ -6,6 +6,7 @@ import logging import plistlib import sqlite3 +from typing import Union from mvt.common.utils import convert_mactime_to_unix, convert_timestamp_to_iso @@ -27,7 +28,7 @@ class Analytics(IOSExtraction): results_path=results_path, fast_mode=fast_mode, log=log, results=results) - def serialize(self, record: dict) -> dict | list: + def serialize(self, record: dict) -> Union[dict, list]: return { "timestamp": record["isodate"], "module": self.__class__.__name__, diff --git a/mvt/ios/modules/fs/analytics_ios_versions.py b/mvt/ios/modules/fs/analytics_ios_versions.py index 6d3c74e..8735350 100644 --- a/mvt/ios/modules/fs/analytics_ios_versions.py +++ b/mvt/ios/modules/fs/analytics_ios_versions.py @@ -5,6 +5,7 @@ import logging from datetime import datetime +from typing import Union from mvt.ios.versions import find_version_by_build @@ -25,7 +26,7 @@ class AnalyticsIOSVersions(IOSExtraction): results_path=results_path, fast_mode=fast_mode, log=log, results=results) - def serialize(self, record: dict) -> dict | list: + def serialize(self, record: dict) -> Union[dict, list]: return { "timestamp": record["isodate"], "module": self.__class__.__name__, diff --git a/mvt/ios/modules/fs/cache_files.py b/mvt/ios/modules/fs/cache_files.py index 9723076..d500a77 100644 --- a/mvt/ios/modules/fs/cache_files.py +++ b/mvt/ios/modules/fs/cache_files.py @@ -6,6 +6,7 @@ import logging import os import sqlite3 +from typing import Union from ..base import IOSExtraction @@ -20,7 +21,7 @@ class CacheFiles(IOSExtraction): results_path=results_path, fast_mode=fast_mode, log=log, results=results) - def serialize(self, record: dict) -> dict | list: + def serialize(self, record: dict) -> Union[dict, list]: records = [] for item in self.results[record]: records.append({ diff --git a/mvt/ios/modules/fs/filesystem.py b/mvt/ios/modules/fs/filesystem.py index 9e06496..1d7fc21 100644 --- a/mvt/ios/modules/fs/filesystem.py +++ b/mvt/ios/modules/fs/filesystem.py @@ -6,6 +6,7 @@ import datetime import logging import os +from typing import Union from mvt.common.utils import convert_timestamp_to_iso @@ -27,7 +28,7 @@ class Filesystem(IOSExtraction): results_path=results_path, fast_mode=fast_mode, log=log, results=results) - def serialize(self, record: dict) -> dict | list: + def serialize(self, record: dict) -> Union[dict, list]: return { "timestamp": record["modified"], "module": self.__class__.__name__, diff --git a/mvt/ios/modules/fs/safari_favicon.py b/mvt/ios/modules/fs/safari_favicon.py index 4bb4809..8023fa4 100644 --- a/mvt/ios/modules/fs/safari_favicon.py +++ b/mvt/ios/modules/fs/safari_favicon.py @@ -5,6 +5,7 @@ import logging import sqlite3 +from typing import Union from mvt.common.utils import convert_mactime_to_unix, convert_timestamp_to_iso @@ -27,7 +28,7 @@ class SafariFavicon(IOSExtraction): results_path=results_path, fast_mode=fast_mode, log=log, results=results) - def serialize(self, record: dict) -> dict | list: + def serialize(self, record: dict) -> Union[dict, list]: return { "timestamp": record["isodate"], "module": self.__class__.__name__, diff --git a/mvt/ios/modules/fs/shutdownlog.py b/mvt/ios/modules/fs/shutdownlog.py index a2b541c..06f509d 100644 --- a/mvt/ios/modules/fs/shutdownlog.py +++ b/mvt/ios/modules/fs/shutdownlog.py @@ -4,6 +4,7 @@ # https://license.mvt.re/1.1/ import logging +from typing import Union from mvt.common.utils import convert_mactime_to_unix, convert_timestamp_to_iso @@ -25,7 +26,7 @@ class ShutdownLog(IOSExtraction): results_path=results_path, fast_mode=fast_mode, log=log, results=results) - def serialize(self, record: dict) -> dict | list: + def serialize(self, record: dict) -> Union[dict, list]: return { "timestamp": record["isodate"], "module": self.__class__.__name__, diff --git a/mvt/ios/modules/fs/version_history.py b/mvt/ios/modules/fs/version_history.py index ad838be..670c0cd 100644 --- a/mvt/ios/modules/fs/version_history.py +++ b/mvt/ios/modules/fs/version_history.py @@ -6,6 +6,7 @@ import datetime import json import logging +from typing import Union from mvt.common.utils import convert_timestamp_to_iso @@ -27,7 +28,7 @@ class IOSVersionHistory(IOSExtraction): results_path=results_path, fast_mode=fast_mode, log=log, results=results) - def serialize(self, record: dict) -> dict | list: + def serialize(self, record: dict) -> Union[dict, list]: return { "timestamp": record["isodate"], "module": self.__class__.__name__, diff --git a/mvt/ios/modules/fs/webkit_indexeddb.py b/mvt/ios/modules/fs/webkit_indexeddb.py index 45e903a..ab5d821 100644 --- a/mvt/ios/modules/fs/webkit_indexeddb.py +++ b/mvt/ios/modules/fs/webkit_indexeddb.py @@ -4,6 +4,7 @@ # https://license.mvt.re/1.1/ import logging +from typing import Union from .webkit_base import WebkitBase @@ -29,7 +30,7 @@ class WebkitIndexedDB(WebkitBase): results_path=results_path, fast_mode=fast_mode, log=log, results=results) - def serialize(self, record: dict) -> dict | list: + def serialize(self, record: dict) -> Union[dict, list]: return { "timestamp": record["isodate"], "module": self.__class__.__name__, diff --git a/mvt/ios/modules/fs/webkit_localstorage.py b/mvt/ios/modules/fs/webkit_localstorage.py index 30c03ff..e9f3ea7 100644 --- a/mvt/ios/modules/fs/webkit_localstorage.py +++ b/mvt/ios/modules/fs/webkit_localstorage.py @@ -4,6 +4,7 @@ # https://license.mvt.re/1.1/ import logging +from typing import Union from .webkit_base import WebkitBase @@ -27,7 +28,7 @@ class WebkitLocalStorage(WebkitBase): results_path=results_path, fast_mode=fast_mode, log=log, results=results) - def serialize(self, record: dict) -> dict | list: + def serialize(self, record: dict) -> Union[dict, list]: return { "timestamp": record["isodate"], "module": self.__class__.__name__, diff --git a/mvt/ios/modules/mixed/calls.py b/mvt/ios/modules/mixed/calls.py index e0293d7..15d634e 100644 --- a/mvt/ios/modules/mixed/calls.py +++ b/mvt/ios/modules/mixed/calls.py @@ -5,6 +5,7 @@ import logging import sqlite3 +from typing import Union from mvt.common.utils import convert_mactime_to_unix, convert_timestamp_to_iso @@ -29,7 +30,7 @@ class Calls(IOSExtraction): results_path=results_path, fast_mode=fast_mode, log=log, results=results) - def serialize(self, record: dict) -> dict | list: + def serialize(self, record: dict) -> Union[dict, list]: return { "timestamp": record["isodate"], "module": self.__class__.__name__, diff --git a/mvt/ios/modules/mixed/chrome_favicon.py b/mvt/ios/modules/mixed/chrome_favicon.py index 4575cf5..1f53da6 100644 --- a/mvt/ios/modules/mixed/chrome_favicon.py +++ b/mvt/ios/modules/mixed/chrome_favicon.py @@ -5,6 +5,7 @@ import logging import sqlite3 +from typing import Union from mvt.common.utils import (convert_chrometime_to_unix, convert_timestamp_to_iso) @@ -32,7 +33,7 @@ class ChromeFavicon(IOSExtraction): results_path=results_path, fast_mode=fast_mode, log=log, results=results) - def serialize(self, record: dict) -> dict | list: + def serialize(self, record: dict) -> Union[dict, list]: return { "timestamp": record["isodate"], "module": self.__class__.__name__, diff --git a/mvt/ios/modules/mixed/chrome_history.py b/mvt/ios/modules/mixed/chrome_history.py index cbda552..8c721dc 100644 --- a/mvt/ios/modules/mixed/chrome_history.py +++ b/mvt/ios/modules/mixed/chrome_history.py @@ -5,6 +5,7 @@ import logging import sqlite3 +from typing import Union from mvt.common.utils import (convert_chrometime_to_unix, convert_timestamp_to_iso) @@ -31,7 +32,7 @@ class ChromeHistory(IOSExtraction): results_path=results_path, fast_mode=fast_mode, log=log, results=results) - def serialize(self, record: dict) -> dict | list: + def serialize(self, record: dict) -> Union[dict, list]: return { "timestamp": record["isodate"], "module": self.__class__.__name__, diff --git a/mvt/ios/modules/mixed/firefox_favicon.py b/mvt/ios/modules/mixed/firefox_favicon.py index 3bb3f87..858a532 100644 --- a/mvt/ios/modules/mixed/firefox_favicon.py +++ b/mvt/ios/modules/mixed/firefox_favicon.py @@ -6,6 +6,7 @@ import logging import sqlite3 from datetime import datetime +from typing import Union from mvt.common.utils import convert_timestamp_to_iso @@ -30,7 +31,7 @@ class FirefoxFavicon(IOSExtraction): results_path=results_path, fast_mode=fast_mode, log=log, results=results) - def serialize(self, record: dict) -> dict | list: + def serialize(self, record: dict) -> Union[dict, list]: return { "timestamp": record["isodate"], "module": self.__class__.__name__, diff --git a/mvt/ios/modules/mixed/firefox_history.py b/mvt/ios/modules/mixed/firefox_history.py index b106052..8a457b4 100644 --- a/mvt/ios/modules/mixed/firefox_history.py +++ b/mvt/ios/modules/mixed/firefox_history.py @@ -6,6 +6,7 @@ import logging import sqlite3 from datetime import datetime +from typing import Union from mvt.common.utils import convert_timestamp_to_iso @@ -34,7 +35,7 @@ class FirefoxHistory(IOSExtraction): results_path=results_path, fast_mode=fast_mode, log=log, results=results) - def serialize(self, record: dict) -> dict | list: + def serialize(self, record: dict) -> Union[dict, list]: return { "timestamp": record["isodate"], "module": self.__class__.__name__, diff --git a/mvt/ios/modules/mixed/idstatuscache.py b/mvt/ios/modules/mixed/idstatuscache.py index e616933..bb76498 100644 --- a/mvt/ios/modules/mixed/idstatuscache.py +++ b/mvt/ios/modules/mixed/idstatuscache.py @@ -6,6 +6,7 @@ import collections import logging import plistlib +from typing import Union from mvt.common.utils import convert_mactime_to_unix, convert_timestamp_to_iso @@ -31,7 +32,7 @@ class IDStatusCache(IOSExtraction): results_path=results_path, fast_mode=fast_mode, log=log, results=results) - def serialize(self, record: dict) -> dict | list: + def serialize(self, record: dict) -> Union[dict, list]: return { "timestamp": record["isodate"], "module": self.__class__.__name__, diff --git a/mvt/ios/modules/mixed/interactionc.py b/mvt/ios/modules/mixed/interactionc.py index 1253fbe..2f9393a 100644 --- a/mvt/ios/modules/mixed/interactionc.py +++ b/mvt/ios/modules/mixed/interactionc.py @@ -5,6 +5,7 @@ import logging import sqlite3 +from typing import Union from mvt.common.utils import convert_mactime_to_unix, convert_timestamp_to_iso @@ -42,7 +43,7 @@ class InteractionC(IOSExtraction): "last_outgoing_recipient_date", ] - def serialize(self, record: dict) -> dict | list: + def serialize(self, record: dict) -> Union[dict, list]: records = [] processed = [] for timestamp in self.timestamps: diff --git a/mvt/ios/modules/mixed/locationd.py b/mvt/ios/modules/mixed/locationd.py index 1cbf0d1..d353723 100644 --- a/mvt/ios/modules/mixed/locationd.py +++ b/mvt/ios/modules/mixed/locationd.py @@ -5,6 +5,7 @@ import logging import plistlib +from typing import Union from mvt.common.utils import convert_mactime_to_unix, convert_timestamp_to_iso @@ -42,7 +43,7 @@ class LocationdClients(IOSExtraction): "BeaconRegionTimeStopped", ] - def serialize(self, record: dict) -> dict | list: + def serialize(self, record: dict) -> Union[dict, list]: records = [] for timestamp in self.timestamps: if timestamp in record.keys(): diff --git a/mvt/ios/modules/mixed/osanalytics_addaily.py b/mvt/ios/modules/mixed/osanalytics_addaily.py index 3e2a089..e17ee3b 100644 --- a/mvt/ios/modules/mixed/osanalytics_addaily.py +++ b/mvt/ios/modules/mixed/osanalytics_addaily.py @@ -5,6 +5,7 @@ import logging import plistlib +from typing import Union from mvt.common.utils import convert_timestamp_to_iso @@ -29,7 +30,7 @@ class OSAnalyticsADDaily(IOSExtraction): results_path=results_path, fast_mode=fast_mode, log=log, results=results) - def serialize(self, record: dict) -> dict | list: + def serialize(self, record: dict) -> Union[dict, list]: record_data = f"{record['package']} WIFI IN: {record['wifi_in']}, WIFI OUT: {record['wifi_out']} - " \ f"WWAN IN: {record['wwan_in']}, WWAN OUT: {record['wwan_out']}" return { diff --git a/mvt/ios/modules/mixed/safari_browserstate.py b/mvt/ios/modules/mixed/safari_browserstate.py index d90a6b5..38ae07d 100644 --- a/mvt/ios/modules/mixed/safari_browserstate.py +++ b/mvt/ios/modules/mixed/safari_browserstate.py @@ -8,6 +8,7 @@ import logging import os import plistlib import sqlite3 +from typing import Union from mvt.common.utils import (convert_mactime_to_unix, convert_timestamp_to_iso, keys_bytes_to_string) @@ -34,7 +35,7 @@ class SafariBrowserState(IOSExtraction): self._session_history_count = 0 - def serialize(self, record: dict) -> dict | list: + def serialize(self, record: dict) -> Union[dict, list]: return { "timestamp": record["last_viewed_timestamp"], "module": self.__class__.__name__, diff --git a/mvt/ios/modules/mixed/safari_history.py b/mvt/ios/modules/mixed/safari_history.py index 878b1cd..64d2944 100644 --- a/mvt/ios/modules/mixed/safari_history.py +++ b/mvt/ios/modules/mixed/safari_history.py @@ -6,6 +6,7 @@ import logging import os import sqlite3 +from typing import Union from mvt.common.url import URL from mvt.common.utils import convert_mactime_to_unix, convert_timestamp_to_iso @@ -34,7 +35,7 @@ class SafariHistory(IOSExtraction): results_path=results_path, fast_mode=fast_mode, log=log, results=results) - def serialize(self, record: dict) -> dict | list: + def serialize(self, record: dict) -> Union[dict, list]: return { "timestamp": record["isodate"], "module": self.__class__.__name__, diff --git a/mvt/ios/modules/mixed/shortcuts.py b/mvt/ios/modules/mixed/shortcuts.py index 0f751d8..1fae12d 100644 --- a/mvt/ios/modules/mixed/shortcuts.py +++ b/mvt/ios/modules/mixed/shortcuts.py @@ -8,6 +8,7 @@ import itertools import logging import plistlib import sqlite3 +from typing import Union from mvt.common.utils import (check_for_links, convert_mactime_to_unix, convert_timestamp_to_iso) @@ -33,7 +34,7 @@ class Shortcuts(IOSExtraction): results_path=results_path, fast_mode=fast_mode, log=log, results=results) - def serialize(self, record: dict) -> dict | list: + def serialize(self, record: dict) -> Union[dict, list]: found_urls = "" if record["action_urls"]: found_urls = f"- URLs in actions: {', '.join(record['action_urls'])}" diff --git a/mvt/ios/modules/mixed/sms.py b/mvt/ios/modules/mixed/sms.py index 1c82224..2ed20bc 100644 --- a/mvt/ios/modules/mixed/sms.py +++ b/mvt/ios/modules/mixed/sms.py @@ -6,6 +6,7 @@ import logging import sqlite3 from base64 import b64encode +from typing import Union from mvt.common.utils import (check_for_links, convert_mactime_to_unix, convert_timestamp_to_iso) @@ -31,7 +32,7 @@ class SMS(IOSExtraction): results_path=results_path, fast_mode=fast_mode, log=log, results=results) - def serialize(self, record: dict) -> dict | list: + def serialize(self, record: dict) -> Union[dict, list]: text = record["text"].replace("\n", "\\n") return { "timestamp": record["isodate"], diff --git a/mvt/ios/modules/mixed/sms_attachments.py b/mvt/ios/modules/mixed/sms_attachments.py index be927d3..4f864b0 100644 --- a/mvt/ios/modules/mixed/sms_attachments.py +++ b/mvt/ios/modules/mixed/sms_attachments.py @@ -6,6 +6,7 @@ import logging import sqlite3 from base64 import b64encode +from typing import Union from mvt.common.utils import convert_mactime_to_unix, convert_timestamp_to_iso @@ -30,7 +31,7 @@ class SMSAttachments(IOSExtraction): results_path=results_path, fast_mode=fast_mode, log=log, results=results) - def serialize(self, record: dict) -> dict | list: + def serialize(self, record: dict) -> Union[dict, list]: return { "timestamp": record["isodate"], "module": self.__class__.__name__, diff --git a/mvt/ios/modules/mixed/tcc.py b/mvt/ios/modules/mixed/tcc.py index 3cd7b52..e84a923 100644 --- a/mvt/ios/modules/mixed/tcc.py +++ b/mvt/ios/modules/mixed/tcc.py @@ -6,6 +6,7 @@ import logging import sqlite3 from datetime import datetime +from typing import Union from mvt.common.utils import convert_timestamp_to_iso @@ -56,7 +57,7 @@ class TCC(IOSExtraction): results_path=results_path, fast_mode=fast_mode, log=log, results=results) - def serialize(self, record: dict) -> dict | list: + def serialize(self, record: dict) -> Union[dict, list]: if "last_modified" in record: if "allowed_value" in record: msg = f"Access to {record['service']} by {record['client']} {record['allowed_value']}" diff --git a/mvt/ios/modules/mixed/whatsapp.py b/mvt/ios/modules/mixed/whatsapp.py index ffbebc6..d8912c4 100644 --- a/mvt/ios/modules/mixed/whatsapp.py +++ b/mvt/ios/modules/mixed/whatsapp.py @@ -5,6 +5,7 @@ import logging import sqlite3 +from typing import Union from mvt.common.utils import (check_for_links, convert_mactime_to_unix, convert_timestamp_to_iso) @@ -30,7 +31,7 @@ class Whatsapp(IOSExtraction): results_path=results_path, fast_mode=fast_mode, log=log, results=results) - def serialize(self, record: dict) -> dict | list: + def serialize(self, record: dict) -> Union[dict, list]: text = record.get("ZTEXT", "").replace("\n", "\\n") links_text = "" if record["links"]: diff --git a/mvt/ios/modules/net_base.py b/mvt/ios/modules/net_base.py index 4906c2b..741fcb2 100644 --- a/mvt/ios/modules/net_base.py +++ b/mvt/ios/modules/net_base.py @@ -7,6 +7,7 @@ import logging import operator import sqlite3 from pathlib import Path +from typing import Union from mvt.common.utils import convert_mactime_to_unix, convert_timestamp_to_iso @@ -81,7 +82,7 @@ class NetBase(IOSExtraction): self.log.info("Extracted information on %d processes", len(self.results)) - def serialize(self, record: dict) -> dict | list: + def serialize(self, record: dict) -> Union[dict, list]: record_data = f"{record['proc_name']} (Bundle ID: {record['bundle_id']}, ID: {record['proc_id']})" record_data_usage = record_data + f" WIFI IN: {record['wifi_in']}, WIFI OUT: {record['wifi_out']} - " \ f"WWAN IN: {record['wwan_in']}, WWAN OUT: {record['wwan_out']}"