mirror of
https://github.com/mvt-project/mvt.git
synced 2026-07-02 03:15:35 +02:00
Continuing enforcement of line length and simplifying date conversions
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
# https://license.mvt.re/1.1/
|
||||
|
||||
import io
|
||||
import logging
|
||||
import os
|
||||
import tarfile
|
||||
|
||||
@@ -19,7 +18,7 @@ class TestBackupModule:
|
||||
|
||||
def test_module_folder(self):
|
||||
backup_path = get_android_backup_folder()
|
||||
mod = SMS(target_path=backup_path, log=logging)
|
||||
mod = SMS(target_path=backup_path)
|
||||
files = []
|
||||
for root, subdirs, subfiles in os.walk(os.path.abspath(backup_path)):
|
||||
for fname in subfiles:
|
||||
@@ -32,7 +31,7 @@ class TestBackupModule:
|
||||
|
||||
def test_module_file(self):
|
||||
fpath = os.path.join(get_android_backup_folder(), "backup.ab")
|
||||
mod = SMS(target_path=fpath, log=logging)
|
||||
mod = SMS(target_path=fpath)
|
||||
with open(fpath, "rb") as f:
|
||||
data = f.read()
|
||||
tardata = parse_backup_file(data)
|
||||
@@ -48,7 +47,7 @@ class TestBackupModule:
|
||||
|
||||
def test_module_file2(self):
|
||||
fpath = os.path.join(get_android_backup_folder(), "backup2.ab")
|
||||
mod = SMS(target_path=fpath, log=logging)
|
||||
mod = SMS(target_path=fpath)
|
||||
with open(fpath, "rb") as f:
|
||||
data = f.read()
|
||||
tardata = parse_backup_file(data, password="123456")
|
||||
@@ -64,7 +63,7 @@ class TestBackupModule:
|
||||
|
||||
def test_module_file3(self):
|
||||
fpath = os.path.join(get_android_backup_folder(), "backup3.ab")
|
||||
mod = SMS(target_path=fpath, log=logging)
|
||||
mod = SMS(target_path=fpath)
|
||||
with open(fpath, "rb") as f:
|
||||
data = f.read()
|
||||
tardata = parse_backup_file(data)
|
||||
|
||||
@@ -52,6 +52,7 @@ class TestBackupParsing:
|
||||
m.update(ddata)
|
||||
assert m.hexdigest() == "33e73df2ede9798dcb3a85c06200ee41c8f52dd2f2e50ffafcceb0407bc13e3a"
|
||||
sms = parse_tar_for_sms(ddata)
|
||||
print(sms)
|
||||
assert isinstance(sms, list)
|
||||
assert len(sms) == 1
|
||||
assert len(sms[0]["links"]) == 1
|
||||
|
||||
@@ -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 logging
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
@@ -17,7 +16,7 @@ class TestAppopsModule:
|
||||
|
||||
def test_appops_parsing(self):
|
||||
fpath = os.path.join(get_artifact_folder(), "android_data/bugreport/")
|
||||
m = Appops(target_path=fpath, log=logging, results=[])
|
||||
m = Appops(target_path=fpath)
|
||||
folder_files = []
|
||||
parent_path = Path(fpath).absolute().as_posix()
|
||||
for root, subdirs, subfiles in os.walk(os.path.abspath(fpath)):
|
||||
|
||||
@@ -14,6 +14,7 @@ class TestDumpsysParsing:
|
||||
file = get_artifact("android_data/dumpsys_appops.txt")
|
||||
with open(file) as f:
|
||||
data = f.read()
|
||||
|
||||
res = parse_dumpsys_appops(data)
|
||||
|
||||
assert len(res) == 12
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
# Mobile Verification Toolkit (MVT)
|
||||
# Copyright (c) 2021-2022 Claudio Guarnieri.
|
||||
# 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.utils import convert_mactime_to_iso, convert_unix_to_iso
|
||||
|
||||
TEST_DATE_EPOCH = 1626566400
|
||||
TEST_DATE_ISO = "2021-07-18 00:00:00.000000"
|
||||
TEST_DATE_MAC = TEST_DATE_EPOCH - 978307200
|
||||
|
||||
|
||||
class TestDateConversions:
|
||||
|
||||
def test_convert_unix_to_iso(self):
|
||||
assert convert_unix_to_iso(TEST_DATE_EPOCH) == TEST_DATE_ISO
|
||||
|
||||
def test_convert_mactime_to_iso(self):
|
||||
assert convert_mactime_to_iso(TEST_DATE_MAC) == TEST_DATE_ISO
|
||||
@@ -3,8 +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 logging
|
||||
|
||||
from mvt.common.module import run_module
|
||||
from mvt.ios.modules.backup.backup_info import BackupInfo
|
||||
|
||||
@@ -14,7 +12,7 @@ from ..utils import get_ios_backup_folder
|
||||
class TestBackupInfoModule:
|
||||
|
||||
def test_manifest(self):
|
||||
m = BackupInfo(target_path=get_ios_backup_folder(), log=logging)
|
||||
m = BackupInfo(target_path=get_ios_backup_folder())
|
||||
run_module(m)
|
||||
assert m.results["Build Version"] == "18C66"
|
||||
assert m.results["IMEI"] == "42"
|
||||
|
||||
@@ -15,15 +15,16 @@ from ..utils import get_ios_backup_folder
|
||||
class TestDatausageModule:
|
||||
|
||||
def test_datausage(self):
|
||||
m = Datausage(target_path=get_ios_backup_folder(), log=logging, results=[])
|
||||
m = Datausage(target_path=get_ios_backup_folder())
|
||||
run_module(m)
|
||||
assert m.results[0]["isodate"][0:19] == "2019-08-27 15:08:09"
|
||||
assert len(m.results) == 42
|
||||
assert len(m.timeline) == 60
|
||||
assert len(m.detected) == 0
|
||||
|
||||
def test_detection(self, indicator_file):
|
||||
m = Datausage(target_path=get_ios_backup_folder(), log=logging, results=[])
|
||||
ind = Indicators(log=logging)
|
||||
m = Datausage(target_path=get_ios_backup_folder())
|
||||
ind = Indicators(log=logging.getLogger())
|
||||
ind.parse_stix2(indicator_file)
|
||||
# Adds a file that exists in the manifest.
|
||||
ind.ioc_collections[0]["processes"].append("CumulativeUsageTracker")
|
||||
|
||||
@@ -15,15 +15,15 @@ from ..utils import get_ios_backup_folder
|
||||
class TestManifestModule:
|
||||
|
||||
def test_manifest(self):
|
||||
m = Manifest(target_path=get_ios_backup_folder(), log=logging, results=[])
|
||||
m = Manifest(target_path=get_ios_backup_folder())
|
||||
run_module(m)
|
||||
assert len(m.results) == 3721
|
||||
assert len(m.timeline) == 5881
|
||||
assert len(m.detected) == 0
|
||||
|
||||
def test_detection(self, indicator_file):
|
||||
m = Manifest(target_path=get_ios_backup_folder(), log=logging, results=[])
|
||||
ind = Indicators(log=logging)
|
||||
m = Manifest(target_path=get_ios_backup_folder())
|
||||
ind = Indicators(log=logging.getLogger())
|
||||
ind.parse_stix2(indicator_file)
|
||||
ind.ioc_collections[0]["file_names"].append("com.apple.CoreBrightness.plist")
|
||||
m.indicators = ind
|
||||
|
||||
@@ -15,7 +15,7 @@ from ..utils import get_ios_backup_folder
|
||||
class TestSafariBrowserStateModule:
|
||||
|
||||
def test_parsing(self):
|
||||
m = SafariBrowserState(target_path=get_ios_backup_folder(), log=logging, results=[])
|
||||
m = SafariBrowserState(target_path=get_ios_backup_folder())
|
||||
m.is_backup = True
|
||||
run_module(m)
|
||||
assert len(m.results) == 1
|
||||
@@ -23,9 +23,9 @@ class TestSafariBrowserStateModule:
|
||||
assert len(m.detected) == 0
|
||||
|
||||
def test_detection(self, indicator_file):
|
||||
m = SafariBrowserState(target_path=get_ios_backup_folder(), log=logging, results=[])
|
||||
m = SafariBrowserState(target_path=get_ios_backup_folder())
|
||||
m.is_backup = True
|
||||
ind = Indicators(log=logging)
|
||||
ind = Indicators(log=logging.getLogger())
|
||||
ind.parse_stix2(indicator_file)
|
||||
# Adds a file that exists in the manifest.
|
||||
ind.ioc_collections[0]["domains"].append("en.wikipedia.org")
|
||||
|
||||
@@ -15,15 +15,15 @@ from ..utils import get_ios_backup_folder
|
||||
class TestSMSModule:
|
||||
|
||||
def test_sms(self):
|
||||
m = SMS(target_path=get_ios_backup_folder(), log=logging, results=[])
|
||||
m = SMS(target_path=get_ios_backup_folder())
|
||||
run_module(m)
|
||||
assert len(m.results) == 1
|
||||
assert len(m.timeline) == 1
|
||||
assert len(m.detected) == 0
|
||||
|
||||
def test_detection(self, indicator_file):
|
||||
m = SMS(target_path=get_ios_backup_folder(), log=logging, results=[])
|
||||
ind = Indicators(log=logging)
|
||||
m = SMS(target_path=get_ios_backup_folder())
|
||||
ind = Indicators(log=logging.getLogger())
|
||||
ind.parse_stix2(indicator_file)
|
||||
# Adds a file that exists in the manifest.
|
||||
ind.ioc_collections[0]["domains"].append("badbadbad.example.org")
|
||||
|
||||
@@ -15,7 +15,7 @@ from ..utils import get_ios_backup_folder
|
||||
class TestTCCtModule:
|
||||
|
||||
def test_tcc(self):
|
||||
m = TCC(target_path=get_ios_backup_folder(), log=logging, results=[])
|
||||
m = TCC(target_path=get_ios_backup_folder())
|
||||
run_module(m)
|
||||
assert len(m.results) == 11
|
||||
assert len(m.timeline) == 11
|
||||
@@ -25,8 +25,8 @@ class TestTCCtModule:
|
||||
assert m.results[0]["auth_value"] == "allowed"
|
||||
|
||||
def test_tcc_detection(self, indicator_file):
|
||||
m = TCC(target_path=get_ios_backup_folder(), log=logging, results=[])
|
||||
ind = Indicators(log=logging)
|
||||
m = TCC(target_path=get_ios_backup_folder())
|
||||
ind = Indicators(log=logging.getLogger())
|
||||
ind.parse_stix2(indicator_file)
|
||||
m.indicators = ind
|
||||
run_module(m)
|
||||
|
||||
Reference in New Issue
Block a user