From 09b16ea2f7adba34eba488f36e278d45226b0511 Mon Sep 17 00:00:00 2001 From: Janik Besendorf Date: Wed, 8 Apr 2026 16:55:27 +0200 Subject: [PATCH] handle empty sms databases --- src/mvt/ios/modules/mixed/sms.py | 5 +++ src/mvt/ios/modules/mixed/sms_attachments.py | 37 ++++++++++++-------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/mvt/ios/modules/mixed/sms.py b/src/mvt/ios/modules/mixed/sms.py index 34c064b..a8db73b 100644 --- a/src/mvt/ios/modules/mixed/sms.py +++ b/src/mvt/ios/modules/mixed/sms.py @@ -123,6 +123,11 @@ class SMS(IOSExtraction): """ ) items = list(cur) + elif "no such table" in str(exc): + self.log.info( + "No SMS tables found in the database, skipping: %s", exc + ) + return else: raise exc names = [description[0] for description in cur.description] diff --git a/src/mvt/ios/modules/mixed/sms_attachments.py b/src/mvt/ios/modules/mixed/sms_attachments.py index ea9b477..e11fb69 100644 --- a/src/mvt/ios/modules/mixed/sms_attachments.py +++ b/src/mvt/ios/modules/mixed/sms_attachments.py @@ -4,6 +4,7 @@ # https://license.mvt.re/1.1/ import logging +import sqlite3 from base64 import b64encode from typing import Optional, Union @@ -79,21 +80,29 @@ class SMSAttachments(IOSExtraction): conn = self._open_sqlite_db(self.file_path) cur = conn.cursor() - cur.execute( + try: + cur.execute( + """ + SELECT + attachment.ROWID as "attachment_id", + attachment.*, + message.service as "service", + handle.id as "phone_number" + FROM attachment + LEFT JOIN message_attachment_join ON + message_attachment_join.attachment_id = attachment.ROWID + LEFT JOIN message ON + message.ROWID = message_attachment_join.message_id + LEFT JOIN handle ON handle.ROWID = message.handle_id; """ - SELECT - attachment.ROWID as "attachment_id", - attachment.*, - message.service as "service", - handle.id as "phone_number" - FROM attachment - LEFT JOIN message_attachment_join ON - message_attachment_join.attachment_id = attachment.ROWID - LEFT JOIN message ON - message.ROWID = message_attachment_join.message_id - LEFT JOIN handle ON handle.ROWID = message.handle_id; - """ - ) + ) + except sqlite3.OperationalError as exc: + self.log.info( + "No SMS attachment tables found in the database, skipping: %s", exc + ) + cur.close() + conn.close() + return names = [description[0] for description in cur.description] for item in cur: