mirror of
https://github.com/mvt-project/mvt.git
synced 2026-09-03 00:21:07 +02:00
Merge branch 'main' into feature/installed-module-packages
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,105 @@
|
||||
# Mobile Verification Toolkit (MVT)
|
||||
# Copyright (c) 2021-2026 The MVT Authors.
|
||||
# Use of this software is governed by the MVT License 1.1 that can be found at
|
||||
# https://license.mvt.re/1.1/
|
||||
|
||||
from mvt.common.module import run_module
|
||||
from mvt.ios.modules.mixed.interactionc import InteractionC
|
||||
from mvt.ios.modules.mixed.whatsapp_contacts import WhatsappContacts
|
||||
|
||||
from ..utils import get_ios_backup_folder
|
||||
|
||||
|
||||
class TestInteractionCModule:
|
||||
def test_extraction_with_whatsapp_contacts(self):
|
||||
contacts = WhatsappContacts(target_path=get_ios_backup_folder())
|
||||
run_module(contacts)
|
||||
|
||||
m = InteractionC(target_path=get_ios_backup_folder())
|
||||
m.dependency_modules = {WhatsappContacts: contacts}
|
||||
run_module(m)
|
||||
|
||||
assert len(m.results) == 3
|
||||
|
||||
incoming = next(
|
||||
r for r in m.results if r["sender_identifier"] == "100000000000001@lid"
|
||||
)
|
||||
assert incoming["direction"] == "INCOMING"
|
||||
assert incoming["sender_resolved_phone_number"] == "+14155550100"
|
||||
assert incoming["sender_resolved_name"] == "Alice Example"
|
||||
|
||||
outgoing = next(
|
||||
r for r in m.results if r["direction"] == "OUTGOING"
|
||||
)
|
||||
assert outgoing["recipient_identifier"] == "+14155550100"
|
||||
assert outgoing["recipient_resolved_name"] == "Alice Example"
|
||||
assert outgoing["domain_resolved_phone_number"] == "+14155550100"
|
||||
assert outgoing["domain_resolved_name"] == "Alice Example"
|
||||
|
||||
sms = next(
|
||||
r for r in m.results if r["bundle_id"] == "com.apple.MobileSMS"
|
||||
)
|
||||
assert sms.get("sender_resolved_name") is None
|
||||
assert sms["sender_display_name"] == "Bob Example"
|
||||
|
||||
events = [entry["data"] for entry in m.timeline]
|
||||
assert (
|
||||
"[net.whatsapp.WhatsApp] INCOMING from "
|
||||
"Alice Example (+14155550100) to local user" in events
|
||||
)
|
||||
assert (
|
||||
"[net.whatsapp.WhatsApp] OUTGOING from local user to "
|
||||
"Alice Example (+14155550100)" in events
|
||||
)
|
||||
assert (
|
||||
"[com.apple.MobileSMS] INCOMING from "
|
||||
"Bob Example (+14155550101) to local user" in events
|
||||
)
|
||||
|
||||
# The creation date is only serialized when it diverges from the
|
||||
# start date; the SMS record was created 90 days after the event.
|
||||
creation_events = [
|
||||
entry
|
||||
for entry in m.timeline
|
||||
if entry["event"] == "interactions_creation_date"
|
||||
]
|
||||
assert len(creation_events) == 1
|
||||
assert creation_events[0]["timestamp"] == "2025-12-09 12:26:40.000000"
|
||||
assert creation_events[0]["data"] == (
|
||||
"Interaction record created 90 days after the event: "
|
||||
"[com.apple.MobileSMS] INCOMING from "
|
||||
"Bob Example (+14155550101) to local user"
|
||||
)
|
||||
|
||||
# Per-contact aggregate dates use contact-centric data strings.
|
||||
first_seen = [
|
||||
entry
|
||||
for entry in m.timeline
|
||||
if entry["event"] == "first_incoming_sender_date"
|
||||
]
|
||||
assert len(first_seen) == 1
|
||||
assert first_seen[0]["timestamp"] == "2025-09-03 13:46:40.000000"
|
||||
assert first_seen[0]["data"] == (
|
||||
"First incoming interaction from Bob Example (+14155550101)"
|
||||
)
|
||||
assert (
|
||||
"Last incoming interaction from Bob Example (+14155550101)"
|
||||
in events
|
||||
)
|
||||
|
||||
def test_extraction_without_whatsapp_contacts(self):
|
||||
# Without the WhatsappContacts dependency the module still runs, and
|
||||
# unresolvable LIDs are shown as-is.
|
||||
m = InteractionC(target_path=get_ios_backup_folder())
|
||||
run_module(m)
|
||||
|
||||
assert len(m.results) == 3
|
||||
events = [entry["data"] for entry in m.timeline]
|
||||
assert (
|
||||
"[net.whatsapp.WhatsApp] INCOMING from "
|
||||
"100000000000001@lid to local user" in events
|
||||
)
|
||||
assert (
|
||||
"[net.whatsapp.WhatsApp] OUTGOING from local user to "
|
||||
"+14155550100" in events
|
||||
)
|
||||
@@ -6,8 +6,79 @@
|
||||
import logging
|
||||
|
||||
from mvt.common.indicators import Indicators
|
||||
from mvt.common.module import run_module
|
||||
from mvt.ios.modules.mixed.whatsapp import Whatsapp
|
||||
|
||||
from ..utils import get_ios_backup_folder
|
||||
|
||||
|
||||
def test_extraction():
|
||||
m = Whatsapp(target_path=get_ios_backup_folder())
|
||||
run_module(m)
|
||||
|
||||
messages = [r for r in m.results if "ZTEXT" in r]
|
||||
sessions = [r for r in m.results if r.get("record_type") == "chat_session"]
|
||||
pairs = [
|
||||
r for r in m.results
|
||||
if r.get("record_type") == "lid_phone_number_pair"
|
||||
]
|
||||
assert len(messages) == 3
|
||||
assert len(sessions) == 2
|
||||
assert len(pairs) == 1
|
||||
|
||||
assert pairs[0]["lid"] == "100000000000001"
|
||||
assert pairs[0]["phone_number"] == "14155550100"
|
||||
assert pairs[0]["pair_timestamp"] == "2025-08-25 07:33:20.000000"
|
||||
|
||||
linked = next(r for r in messages if r.get("links"))
|
||||
assert linked["links"] == ["https://example.org/news"]
|
||||
|
||||
alice = next(s for s in sessions if s["partner_name"] == "Alice Example")
|
||||
assert alice["contact_jid"] == "100000000000001@lid"
|
||||
assert alice["partner_resolved_phone_number"] == "+14155550100"
|
||||
assert alice["first_stored_message_date"] == "2025-08-27 15:06:40.000000"
|
||||
assert alice["last_message_date"] == "2025-08-28 18:53:20.000000"
|
||||
assert alice["group_creation_date"] is None
|
||||
assert alice["stored_message_count"] == 2
|
||||
|
||||
group = next(s for s in sessions if s["partner_name"] == "Example Group")
|
||||
assert group["group_creation_date"] == "2025-08-21 20:13:20.000000"
|
||||
assert group["first_stored_message_date"] == "2025-08-29 22:40:00.000000"
|
||||
# The last stored message predates the session's own last-message date:
|
||||
# the newest message in this chat was deleted.
|
||||
assert group["last_stored_message_date"] == "2025-08-29 22:40:00.000000"
|
||||
assert group["last_message_date"] == "2025-08-31 02:26:40.000000"
|
||||
|
||||
# 3 message events, first/last per chat, the group creation and the
|
||||
# LID-phone number pair.
|
||||
assert len(m.timeline) == 9
|
||||
events = {
|
||||
(entry["event"], entry["timestamp"]): entry["data"]
|
||||
for entry in m.timeline
|
||||
}
|
||||
# Alice's session is keyed by LID but labelled with the phone number
|
||||
# resolved through LID.sqlite.
|
||||
assert events[("chat_first_message", "2025-08-27 15:06:40.000000")] == (
|
||||
"First stored message in WhatsApp chat with "
|
||||
"'Alice Example' (+14155550100)"
|
||||
)
|
||||
assert events[("chat_last_message", "2025-08-28 18:53:20.000000")] == (
|
||||
"Last message in WhatsApp chat with "
|
||||
"'Alice Example' (+14155550100)"
|
||||
)
|
||||
assert events[("lid_pair_recorded", "2025-08-25 07:33:20.000000")] == (
|
||||
"WhatsApp associated LID 100000000000001 with "
|
||||
"phone number 14155550100"
|
||||
)
|
||||
assert events[("group_created", "2025-08-21 20:13:20.000000")] == (
|
||||
"WhatsApp group chat 'Example Group' "
|
||||
"(120000000000000001@g.us) was created"
|
||||
)
|
||||
assert ("chat_first_message", "2025-08-29 22:40:00.000000") in events
|
||||
assert ("chat_last_message", "2025-08-31 02:26:40.000000") in events
|
||||
|
||||
assert len(m.alertstore.alerts) == 0
|
||||
|
||||
|
||||
def test_collect_url_results_includes_expansion():
|
||||
module = Whatsapp(
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
# Mobile Verification Toolkit (MVT)
|
||||
# Copyright (c) 2021-2026 The MVT Authors.
|
||||
# Use of this software is governed by the MVT License 1.1 that can be found at
|
||||
# https://license.mvt.re/1.1/
|
||||
|
||||
from mvt.common.module import run_module
|
||||
from mvt.ios.modules.mixed.whatsapp_contacts import WhatsappContacts
|
||||
|
||||
from ..utils import get_ios_backup_folder
|
||||
|
||||
|
||||
class TestWhatsappContactsModule:
|
||||
def test_extraction(self):
|
||||
m = WhatsappContacts(target_path=get_ios_backup_folder())
|
||||
run_module(m)
|
||||
assert len(m.results) == 2
|
||||
|
||||
alice = next(r for r in m.results if r["given_name"] == "Alice")
|
||||
assert alice["full_name"] == "Alice Example"
|
||||
assert alice["phone_number"] == "+14155550100"
|
||||
assert alice["whatsapp_id"] == "14155550100@s.whatsapp.net"
|
||||
assert alice["lid"] == "100000000000001@lid"
|
||||
assert alice["user_name"] == "alice.example"
|
||||
assert alice["disappearing_mode_duration"] == 86400.0
|
||||
assert alice["disappearing_mode_is_on"] is True
|
||||
assert alice["disappearing_mode_label"] == "24 hours"
|
||||
assert alice["disappearing_mode_timestamp"] == "2025-07-23 21:46:40.000000"
|
||||
assert alice["about_timestamp"] == "2025-07-12 08:00:00.000000"
|
||||
assert alice["about_expiration_timestamp"] == "2025-08-16 01:20:00.000000"
|
||||
assert alice["last_updated"] == "2025-08-04 11:33:20.000000"
|
||||
|
||||
bob = next(r for r in m.results if r["given_name"] == "Bob")
|
||||
assert bob["lid"] is None
|
||||
assert bob["disappearing_mode_duration"] is None
|
||||
assert bob["disappearing_mode_is_on"] is False
|
||||
assert bob["disappearing_mode_label"] == "off"
|
||||
assert bob["disappearing_mode_timestamp"] is None
|
||||
|
||||
# Alice: disappearing_mode_set, about_changed, about_expiration and
|
||||
# contact_last_updated. Bob: contact_last_updated only.
|
||||
assert len(m.timeline) == 5
|
||||
|
||||
events = {
|
||||
(entry["event"], entry["timestamp"]): entry["data"]
|
||||
for entry in m.timeline
|
||||
}
|
||||
assert (
|
||||
"24 hours"
|
||||
in events[("disappearing_mode_set", "2025-07-23 21:46:40.000000")]
|
||||
)
|
||||
assert (
|
||||
"14155550100@s.whatsapp.net (Alice Example)"
|
||||
in events[("disappearing_mode_set", "2025-07-23 21:46:40.000000")]
|
||||
)
|
||||
assert (
|
||||
'changed to "Hey there! I am using WhatsApp."'
|
||||
in events[("about_changed", "2025-07-12 08:00:00.000000")]
|
||||
)
|
||||
assert (
|
||||
"scheduled to expire"
|
||||
in events[("about_expiration", "2025-08-16 01:20:00.000000")]
|
||||
)
|
||||
|
||||
updated = [
|
||||
entry["data"]
|
||||
for entry in m.timeline
|
||||
if entry["event"] == "contact_last_updated"
|
||||
]
|
||||
assert len(updated) == 2
|
||||
assert all(
|
||||
entry["timestamp"] == "2025-08-04 11:33:20.000000"
|
||||
for entry in m.timeline
|
||||
if entry["event"] == "contact_last_updated"
|
||||
)
|
||||
assert any("14155550101@s.whatsapp.net (Bob Example)" in d for d in updated)
|
||||
|
||||
assert len(m.alertstore.alerts) == 0
|
||||
|
||||
def test_missing_database(self, tmp_path):
|
||||
m = WhatsappContacts(target_path=str(tmp_path))
|
||||
run_module(m)
|
||||
assert m.results == []
|
||||
assert len(m.alertstore.alerts) == 0
|
||||
@@ -15,8 +15,8 @@ class TestFilesystem:
|
||||
def test_filesystem(self):
|
||||
m = Filesystem(target_path=get_ios_backup_folder())
|
||||
run_module(m)
|
||||
assert len(m.results) == 15
|
||||
assert len(m.timeline) == 15
|
||||
assert len(m.results) == 23
|
||||
assert len(m.timeline) == 23
|
||||
assert len(m.alertstore.alerts) == 0
|
||||
|
||||
def test_detection(self, indicator_file):
|
||||
@@ -29,6 +29,6 @@ class TestFilesystem:
|
||||
)
|
||||
m.indicators = ind
|
||||
run_module(m)
|
||||
assert len(m.results) == 15
|
||||
assert len(m.timeline) == 15
|
||||
assert len(m.results) == 23
|
||||
assert len(m.timeline) == 23
|
||||
assert len(m.alertstore.alerts) == 1
|
||||
|
||||
Reference in New Issue
Block a user