mirror of
https://github.com/mvt-project/mvt.git
synced 2026-11-18 18:04:19 +01:00
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0c1a2ac002 | ||
|
|
1087975d29 | ||
|
|
92683ef788 | ||
|
|
a02c7d8db0 |
No files matched your search
@@ -4,7 +4,8 @@
|
||||
|
||||
# Mobile Verification Toolkit
|
||||
|
||||
|
||||
> [!IMPORTANT]
|
||||
> We recently merged the "v3" branch. This introduced breaking changes. If you relied on mvt output in other scripts They might have broken. More details: https://github.com/mvt-project/mvt/issues/757
|
||||
|
||||
[](https://pypi.org/project/mvt/)
|
||||
[](https://docs.mvt.re/en/latest/?badge=latest)
|
||||
|
||||
@@ -57,31 +57,46 @@ class Calls(IOSExtraction):
|
||||
return
|
||||
conn = self._open_sqlite_db(self.file_path)
|
||||
cur = conn.cursor()
|
||||
cur.execute(
|
||||
"""
|
||||
SELECT
|
||||
ZDATE, ZDURATION, ZLOCATION, ZADDRESS, ZSERVICE_PROVIDER
|
||||
FROM ZCALLRECORD;
|
||||
"""
|
||||
)
|
||||
# names = [description[0] for description in cur.description]
|
||||
|
||||
for row in cur:
|
||||
self.results.append(
|
||||
{
|
||||
"isodate": convert_mactime_to_iso(row[0]),
|
||||
"duration": row[1],
|
||||
"location": row[2],
|
||||
"number": (
|
||||
row[3].decode("utf-8")
|
||||
if isinstance(row[3], bytes)
|
||||
else row[3]
|
||||
),
|
||||
"provider": row[4],
|
||||
}
|
||||
try:
|
||||
cur.execute("PRAGMA table_info(ZCALLRECORD);")
|
||||
columns = {column[1].upper() for column in cur}
|
||||
originated_column = "ZORIGINATED" if "ZORIGINATED" in columns else "NULL"
|
||||
answered_column = "ZANSWERED" if "ZANSWERED" in columns else "NULL"
|
||||
cur.execute(
|
||||
f"""
|
||||
SELECT
|
||||
ZDATE, ZDURATION, ZLOCATION, ZADDRESS, ZSERVICE_PROVIDER,
|
||||
{originated_column}, {answered_column}
|
||||
FROM ZCALLRECORD;
|
||||
"""
|
||||
)
|
||||
|
||||
cur.close()
|
||||
conn.close()
|
||||
for (
|
||||
date,
|
||||
duration,
|
||||
location,
|
||||
address,
|
||||
provider,
|
||||
originated,
|
||||
answered,
|
||||
) in cur:
|
||||
self.results.append(
|
||||
{
|
||||
"isodate": convert_mactime_to_iso(date),
|
||||
"duration": duration,
|
||||
"location": location,
|
||||
"number": (
|
||||
address.decode("utf-8")
|
||||
if isinstance(address, bytes)
|
||||
else address
|
||||
),
|
||||
"provider": provider,
|
||||
"originated": originated,
|
||||
"answered": answered,
|
||||
}
|
||||
)
|
||||
finally:
|
||||
cur.close()
|
||||
conn.close()
|
||||
|
||||
self.log.info("Extracted a total of %d calls", len(self.results))
|
||||
@@ -107,7 +107,7 @@ class SafariBrowserState(IOSExtraction):
|
||||
tabs.last_viewed_time,
|
||||
tab_sessions.session_data
|
||||
FROM tabs
|
||||
JOIN tab_sessions ON tabs.uuid = tab_sessions.tab_uuid
|
||||
LEFT JOIN tab_sessions ON tabs.uuid = tab_sessions.tab_uuid
|
||||
ORDER BY tabs.last_viewed_time;
|
||||
"""
|
||||
)
|
||||
@@ -139,7 +139,9 @@ class SafariBrowserState(IOSExtraction):
|
||||
except plistlib.InvalidFileException:
|
||||
pass
|
||||
|
||||
if "SessionHistoryEntries" in session_data.get("SessionHistory", {}):
|
||||
if "SessionHistoryEntries" in session_data.get(
|
||||
"SessionHistory", {}
|
||||
):
|
||||
for session_entry in session_data["SessionHistory"].get(
|
||||
"SessionHistoryEntries"
|
||||
):
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
# 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/
|
||||
|
||||
import sqlite3
|
||||
|
||||
import pytest
|
||||
|
||||
from mvt.common.module import run_module
|
||||
from mvt.ios.modules.mixed.calls import Calls
|
||||
|
||||
|
||||
@pytest.mark.parametrize("has_flags", [True, False])
|
||||
def test_calls_reads_optional_call_flags(tmp_path, has_flags):
|
||||
db_path = tmp_path / "CallHistory.storedata"
|
||||
conn = sqlite3.connect(db_path)
|
||||
try:
|
||||
conn.execute(
|
||||
"""
|
||||
CREATE TABLE ZCALLRECORD (
|
||||
ZDATE REAL, ZDURATION REAL, ZLOCATION TEXT, ZADDRESS BLOB,
|
||||
ZSERVICE_PROVIDER TEXT
|
||||
)
|
||||
"""
|
||||
)
|
||||
conn.execute(
|
||||
"INSERT INTO ZCALLRECORD VALUES (?, ?, ?, ?, ?)",
|
||||
(700000000, 42, "Berlin", b"+491234", "carrier"),
|
||||
)
|
||||
if has_flags:
|
||||
conn.execute("ALTER TABLE ZCALLRECORD ADD COLUMN ZORIGINATED INTEGER")
|
||||
conn.execute("ALTER TABLE ZCALLRECORD ADD COLUMN ZANSWERED INTEGER")
|
||||
conn.execute("UPDATE ZCALLRECORD SET ZORIGINATED = 1, ZANSWERED = 0")
|
||||
conn.commit()
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
module = Calls(file_path=str(db_path))
|
||||
run_module(module)
|
||||
|
||||
assert len(module.results) == 1
|
||||
record = module.results[0]
|
||||
assert record["number"] == "+491234"
|
||||
assert record["originated"] == (1 if has_flags else None)
|
||||
assert record["answered"] == (0 if has_flags else None)
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
import logging
|
||||
import shutil
|
||||
import sqlite3
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -74,3 +75,39 @@ class TestSafariBrowserStateModule:
|
||||
assert len(m.alertstore.alerts) == 1
|
||||
assert len(m.results) == 1
|
||||
assert m.results[0]["tab_url"] == "https://en.wikipedia.org/wiki/NSO_Group"
|
||||
|
||||
def test_detection_for_tab_without_session_row(self, tmp_path, indicator_file):
|
||||
url = "https://en.wikipedia.org/wiki/NSO_Group"
|
||||
db_path = tmp_path / "private/var/mobile/Library/Safari/BrowserState.db"
|
||||
db_path.parent.mkdir(parents=True)
|
||||
conn = sqlite3.connect(db_path)
|
||||
try:
|
||||
conn.executescript(
|
||||
"""
|
||||
CREATE TABLE tabs (
|
||||
uuid TEXT, title TEXT, url TEXT, user_visible_url TEXT,
|
||||
last_viewed_time REAL
|
||||
);
|
||||
CREATE TABLE tab_sessions (tab_uuid TEXT, session_data BLOB);
|
||||
"""
|
||||
)
|
||||
conn.execute(
|
||||
"INSERT INTO tabs VALUES ('tab-1', 'Example', ?, ?, 700000000)",
|
||||
(url, url),
|
||||
)
|
||||
conn.commit()
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
module = SafariBrowserState(target_path=str(tmp_path))
|
||||
module.is_fs_dump = True
|
||||
indicators = Indicators(log=logging.getLogger())
|
||||
indicators.parse_stix2(indicator_file)
|
||||
indicators.ioc_collections[0]["domains"].append("en.wikipedia.org")
|
||||
module.indicators = indicators
|
||||
run_module(module)
|
||||
|
||||
assert len(module.results) == 1
|
||||
assert module.results[0]["tab_url"] == url
|
||||
assert module.results[0]["session_data"] == []
|
||||
assert len(module.alertstore.alerts) == 1
|
||||
Reference in new issue
Block a user