2022-08-23 11:18:05 +00:00
|
|
|
# Mobile Verification Toolkit (MVT)
|
2023-09-09 15:55:27 +00:00
|
|
|
# Copyright (c) 2021-2023 The MVT Authors.
|
2022-08-23 11:18:05 +00:00
|
|
|
# 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
|
|
|
|
|
2023-07-31 16:38:41 +00:00
|
|
|
import pytest
|
|
|
|
|
2022-08-23 11:18:05 +00:00
|
|
|
from mvt.common.indicators import Indicators
|
|
|
|
from mvt.common.module import run_module
|
|
|
|
from mvt.ios.modules.fs.filesystem import Filesystem
|
|
|
|
|
2023-07-31 16:38:41 +00:00
|
|
|
from ..utils import delete_tmp_db_files, get_ios_backup_folder
|
2023-07-31 09:45:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture()
|
|
|
|
def cleanup_tmp_artifacts():
|
|
|
|
ios_backup_folder = get_ios_backup_folder()
|
|
|
|
delete_tmp_db_files(ios_backup_folder)
|
|
|
|
return
|
2022-08-23 11:18:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
class TestFilesystem:
|
2023-07-31 09:45:53 +00:00
|
|
|
def test_filesystem(self, cleanup_tmp_artifacts):
|
2022-08-23 11:18:05 +00:00
|
|
|
m = Filesystem(target_path=get_ios_backup_folder())
|
|
|
|
run_module(m)
|
2023-08-02 13:28:16 +00:00
|
|
|
assert len(m.results) == 15
|
|
|
|
assert len(m.timeline) == 15
|
2022-08-23 11:18:05 +00:00
|
|
|
assert len(m.detected) == 0
|
|
|
|
|
2023-07-31 09:45:53 +00:00
|
|
|
def test_detection(self, indicator_file, cleanup_tmp_artifacts):
|
2022-08-23 11:18:05 +00:00
|
|
|
m = Filesystem(target_path=get_ios_backup_folder())
|
|
|
|
ind = Indicators(log=logging.getLogger())
|
|
|
|
ind.parse_stix2(indicator_file)
|
|
|
|
# Adds a filename that exist in the folder
|
2023-06-01 21:40:26 +00:00
|
|
|
ind.ioc_collections[0]["processes"].append(
|
|
|
|
"64d0019cb3d46bfc8cce545a8ba54b93e7ea9347"
|
|
|
|
)
|
2022-08-23 11:18:05 +00:00
|
|
|
m.indicators = ind
|
|
|
|
run_module(m)
|
2023-08-02 13:28:16 +00:00
|
|
|
assert len(m.results) == 15
|
|
|
|
assert len(m.timeline) == 15
|
2022-08-23 11:18:05 +00:00
|
|
|
assert len(m.detected) == 1
|