diff --git a/mvt/android/modules/adb/dumpsys_accessibility.py b/mvt/android/modules/adb/dumpsys_accessibility.py index 1e2419e..450d3f9 100644 --- a/mvt/android/modules/adb/dumpsys_accessibility.py +++ b/mvt/android/modules/adb/dumpsys_accessibility.py @@ -3,7 +3,6 @@ # Use of this software is governed by the MVT License 1.1 that can be found at # https://license.mvt.re/1.1/ -import io import logging import os @@ -42,9 +41,8 @@ class DumpsysAccessibility(AndroidExtraction): log.info("Found installed accessibility service \"%s\"", service) if self.output_folder: - acc_path = os.path.join(self.output_folder, - "dumpsys_accessibility.txt") - with io.open(acc_path, "w", encoding="utf-8") as handle: + acc_path = os.path.join(self.output_folder, "dumpsys_accessibility.txt") + with open(acc_path, "w", encoding="utf-8") as handle: handle.write(stats) log.info("Records from dumpsys accessibility stored at %s", diff --git a/mvt/android/modules/adb/getprop.py b/mvt/android/modules/adb/getprop.py index e7dbac2..5ef9367 100644 --- a/mvt/android/modules/adb/getprop.py +++ b/mvt/android/modules/adb/getprop.py @@ -4,7 +4,6 @@ # https://license.mvt.re/1.1/ import logging -import os import re from .base import AndroidExtraction diff --git a/mvt/android/modules/adb/settings.py b/mvt/android/modules/adb/settings.py index 4c8240f..2c6e327 100644 --- a/mvt/android/modules/adb/settings.py +++ b/mvt/android/modules/adb/settings.py @@ -4,8 +4,6 @@ # https://license.mvt.re/1.1/ import logging -import os -import re from .base import AndroidExtraction @@ -60,6 +58,7 @@ ANDROID_DANGEROUS_SETTINGS = [ }, ] + class Settings(AndroidExtraction): """This module extracts Android system settings.""" diff --git a/mvt/common/indicators.py b/mvt/common/indicators.py index e283707..a493fdd 100644 --- a/mvt/common/indicators.py +++ b/mvt/common/indicators.py @@ -3,7 +3,6 @@ # Use of this software is governed by the MVT License 1.1 that can be found at # https://license.mvt.re/1.1/ -import io import json import os @@ -436,7 +435,7 @@ def download_indicators_files(log): ioc_path = os.path.join(data_dir, clean_file_name) # Write file to disk. This will overwrite any older version of the STIX2 file. - with io.open(ioc_path, "w") as f: + with open(ioc_path, "w", encoding="utf-8") as f: f.write(res.text) log.info("Saved indicator file to '%s'", os.path.basename(ioc_path)) diff --git a/mvt/common/module.py b/mvt/common/module.py index fc13852..32f1994 100644 --- a/mvt/common/module.py +++ b/mvt/common/module.py @@ -4,7 +4,6 @@ # https://license.mvt.re/1.1/ import csv -import io import os import re @@ -91,7 +90,7 @@ class MVTModule(object): if self.results: results_file_name = f"{name}.json" results_json_path = os.path.join(self.output_folder, results_file_name) - with io.open(results_json_path, "w", encoding="utf-8") as handle: + with open(results_json_path, "w", encoding="utf-8") as handle: try: json.dump(self.results, handle, indent=4, default=str) except Exception as e: @@ -101,7 +100,7 @@ class MVTModule(object): if self.detected: detected_file_name = f"{name}_detected.json" detected_json_path = os.path.join(self.output_folder, detected_file_name) - with io.open(detected_json_path, "w", encoding="utf-8") as handle: + with open(detected_json_path, "w", encoding="utf-8") as handle: json.dump(self.detected, handle, indent=4, default=str) def serialize(self, record): @@ -192,7 +191,7 @@ def save_timeline(timeline, timeline_path): :param timeline_path: Path to the csv file to store the timeline to """ - with io.open(timeline_path, "a+", encoding="utf-8") as handle: + with open(timeline_path, "a+", encoding="utf-8") as handle: csvoutput = csv.writer(handle, delimiter=",", quotechar="\"") csvoutput.writerow(["UTC Timestamp", "Plugin", "Event", "Description"]) for event in sorted(timeline, key=lambda x: x["timestamp"] if x["timestamp"] is not None else ""): diff --git a/mvt/ios/cli.py b/mvt/ios/cli.py index 308692d..3b6b277 100644 --- a/mvt/ios/cli.py +++ b/mvt/ios/cli.py @@ -184,7 +184,7 @@ def check_backup(ctx, iocs, output, fast, backup_path, list_modules, module): if len(timeline_detected) > 0: log.warning("The analysis of the backup produced %d detections!", - len(timeline_detected)) + len(timeline_detected)) #============================================================================== @@ -247,6 +247,7 @@ def check_fs(ctx, iocs, output, fast, dump_path, list_modules, module): log.warning("The analysis of the filesystem produced %d detections!", len(timeline_detected)) + #============================================================================== # Command: check-iocs #============================================================================== diff --git a/mvt/ios/modules/mixed/tcc.py b/mvt/ios/modules/mixed/tcc.py index 3dfd8e5..2270769 100644 --- a/mvt/ios/modules/mixed/tcc.py +++ b/mvt/ios/modules/mixed/tcc.py @@ -97,7 +97,6 @@ class TCC(IOSExtraction): FROM access;""") db_version = "v1" - for row in cur: service = row[0] client = row[1] @@ -113,7 +112,7 @@ class TCC(IOSExtraction): if service in ["kTCCServiceMicrophone", "kTCCServiceCamera"]: device = "microphone" if service == "kTCCServiceMicrophone" else "camera" self.log.info("Found client \"%s\" with access %s to %s on %s by %s", - client, auth_value_desc, device, last_modified, auth_reason_desc) + client, auth_value_desc, device, last_modified, auth_reason_desc) self.results.append({ "service": service, @@ -132,7 +131,7 @@ class TCC(IOSExtraction): if service in ["kTCCServiceMicrophone", "kTCCServiceCamera"]: device = "microphone" if service == "kTCCServiceMicrophone" else "camera" self.log.info("Found client \"%s\" with access %s to %s at %s", - client, allowed_desc, device, last_modified) + client, allowed_desc, device, last_modified) self.results.append({ "service": service, "client": client, @@ -145,7 +144,7 @@ class TCC(IOSExtraction): if service in ["kTCCServiceMicrophone", "kTCCServiceCamera"]: device = "microphone" if service == "kTCCServiceMicrophone" else "camera" self.log.info("Found client \"%s\" with access %s to %s", - client, allowed_desc, device) + client, allowed_desc, device) self.results.append({ "service": service, "client": client, diff --git a/tests/ios/test_safari_browserstate.py b/tests/ios/test_safari_browserstate.py index a89ca55..4658ee3 100644 --- a/tests/ios/test_safari_browserstate.py +++ b/tests/ios/test_safari_browserstate.py @@ -17,7 +17,7 @@ class TestSafariBrowserStateModule: m = SafariBrowserState(base_folder=get_backup_folder(), log=logging, results=[]) m.is_backup = True run_module(m) - assert m.file_path != None + assert m.file_path is not None assert len(m.results) == 1 assert len(m.timeline) == 1 assert len(m.detected) == 0