diff --git a/.flake8 b/.flake8 index 1de1c6d..bad9a6a 100644 --- a/.flake8 +++ b/.flake8 @@ -5,4 +5,6 @@ ignore = C901, E265, E127, - F401 + F401, + W503, + E226 diff --git a/mvt/android/modules/adb/base.py b/mvt/android/modules/adb/base.py index 36834b5..cce06f2 100644 --- a/mvt/android/modules/adb/base.py +++ b/mvt/android/modules/adb/base.py @@ -248,12 +248,11 @@ class AndroidExtraction(MVTModule): self._adb_disconnect() def _generate_backup(self, package_name): - # Run ADB command to create a backup of SMS app self.log.warning("Please check phone and accept Android backup prompt. You may need to set a backup password. \a") - # Run ADB command to create a backup of SMS app # TODO: Base64 encoding as temporary fix to avoid byte-mangling over the shell transport... - backup_output_b64 = self._adb_command("/system/bin/bu backup -nocompress '{}' | base64".format(package_name)) + backup_output_b64 = self._adb_command("/system/bin/bu backup -nocompress '{}' | base64".format( + package_name)) backup_output = base64.b64decode(backup_output_b64) header = parse_ab_header(backup_output) @@ -264,14 +263,13 @@ class AndroidExtraction(MVTModule): if header["encryption"] == "none": return parse_backup_file(backup_output, password=None) - # Backup encrypted. Request password from user. for password_retry in range(0, 3): - backup_password = getpass.getpass(prompt="Backup Password: ", stream=None) + backup_password = getpass.getpass(prompt="Backup password: ", stream=None) try: decrypted_backup_tar = parse_backup_file(backup_output, backup_password) return decrypted_backup_tar except InvalidBackupPassword: - self.log.info("Invalid backup password") + self.log.error("You provided the wrong password! Please try again...") self.log.warn("All attempts to decrypt backup with password failed!") diff --git a/mvt/ios/modules/fs/shutdownlog.py b/mvt/ios/modules/fs/shutdownlog.py index da6886c..0c9a0ce 100644 --- a/mvt/ios/modules/fs/shutdownlog.py +++ b/mvt/ios/modules/fs/shutdownlog.py @@ -64,7 +64,7 @@ class ShutdownLog(IOSExtraction): mac_timestamp = int(line[line.find("[")+1:line.find("]")]) except ValueError: try: - start = line.find(" @")+2 + start = line.find(" @") + 2 mac_timestamp = int(line[start:start+10]) except Exception: mac_timestamp = 0 diff --git a/mvt/ios/modules/mixed/sms.py b/mvt/ios/modules/mixed/sms.py index 150e1fb..2c53f60 100644 --- a/mvt/ios/modules/mixed/sms.py +++ b/mvt/ios/modules/mixed/sms.py @@ -88,9 +88,8 @@ class SMS(IOSExtraction): for index, value in enumerate(item): # We base64 escape some of the attributes that could contain # binary data. - if (names[index] == "attributedBody" or - names[index] == "payload_data" or - names[index] == "message_summary_info") and value: + if (names[index] == "attributedBody" or names[index] == "payload_data" + or names[index] == "message_summary_info") and value: value = b64encode(value).decode() # We store the value of each column under the proper key. diff --git a/mvt/ios/modules/mixed/sms_attachments.py b/mvt/ios/modules/mixed/sms_attachments.py index af4ecbf..ab5b930 100644 --- a/mvt/ios/modules/mixed/sms_attachments.py +++ b/mvt/ios/modules/mixed/sms_attachments.py @@ -73,8 +73,8 @@ class SMSAttachments(IOSExtraction): attachment["service"] = attachment["service"] or "Unknown" attachment["filename"] = attachment["filename"] or "NULL" - if (attachment["filename"].startswith("/var/tmp/") and attachment["filename"].endswith("-1") and - attachment["direction"] == "received"): + if (attachment["filename"].startswith("/var/tmp/") and attachment["filename"].endswith("-1") + and attachment["direction"] == "received"): self.log.warn(f"Suspicious iMessage attachment '{attachment['filename']}' on {attachment['isodate']}") self.detected.append(attachment) diff --git a/tests/android/test_backup_parser.py b/tests/android/test_backup_parser.py index f02c491..e3032e1 100644 --- a/tests/android/test_backup_parser.py +++ b/tests/android/test_backup_parser.py @@ -22,7 +22,7 @@ class TestBackupParsing: m.update(ddata) assert m.hexdigest() == "0799b583788908f06bccb854608cede375041ee878722703a39182edeb008324" sms = parse_tar_for_sms(ddata) - assert isinstance(sms, list) == True + assert isinstance(sms, list) assert len(sms) == 1 assert len(sms[0]["links"]) == 1 assert sms[0]["links"][0] == "https://google.com/" @@ -37,7 +37,7 @@ class TestBackupParsing: m.update(ddata) assert m.hexdigest() == "f365ace1effbc4902c6aeba241ca61544f8a96ad456c1861808ea87b7dd03896" sms = parse_tar_for_sms(ddata) - assert isinstance(sms, list) == True + assert isinstance(sms, list) assert len(sms) == 1 assert len(sms[0]["links"]) == 1 assert sms[0]["links"][0] == "https://google.com/" @@ -52,7 +52,7 @@ class TestBackupParsing: m.update(ddata) assert m.hexdigest() == "33e73df2ede9798dcb3a85c06200ee41c8f52dd2f2e50ffafcceb0407bc13e3a" sms = parse_tar_for_sms(ddata) - assert isinstance(sms, list) == True + assert isinstance(sms, list) assert len(sms) == 1 assert len(sms[0]["links"]) == 1 assert sms[0]["links"][0] == "https://google.com/"