Compare commits

...
18 Commits
Author SHA1 Message Date
besendorf 829becf8e7 Merge pull request #933 from besendorf/fix/androidqf-root-zip-931
Fix AndroidQF artifact discovery in root-level ZIP archives
2026-11-25 12:41:54 +01:00
besendorf 7eaa196892 Merge branch 'main' into fix/androidqf-root-zip-931 2026-11-25 12:18:56 +01:00
besendorf b89af09766 Merge pull request #999 from besendorf/fix/docker-abe-download
Fix Android Backup Extractor download in Docker images
2026-11-24 19:43:33 +01:00
Janik Besendorf 5f3f334dc0 Fix Android Backup Extractor download in Docker images 2026-11-24 19:39:45 +01:00
besendorf fbcf43a9fd Merge pull request #992 from besendorf/fix/androidqf-apk-sha256
Validate AndroidQF APK SHA-256 values before lookup
2026-11-24 19:27:56 +01:00
besendorf 84fdc811d9 Merge branch 'main' into fix/androidqf-apk-sha256 2026-11-24 19:25:15 +01:00
besendorf 8d74cb6d9b Merge pull request #998 from kayaal34/fix/ioc-filename-lstrip
Fix mangled IOC file names when downloading indicators
2026-11-24 17:30:57 +01:00
Janik Besendorf ac61b3425b Respect filesystem case sensitivity when retiring cached IOCs 2026-11-24 14:15:47 +01:00
Janik Besendorf 38c5ef233a Retire legacy IOC cache files after refresh 2026-11-24 13:56:53 +01:00
Yahya Kayaal e44563f158 Fix mangled IOC file names when downloading indicators 2026-11-24 11:11:20 +03:00
Donncha Ó Cearbhaill 4c97897638 Propagate the module filter to the AndroidQF nested commands (#997)
mvt-android check-androidqf -m MODULE filtered only the top-level
AndroidQF modules: when the archive holds bugreport.zip, backup.ab or
an intrusion_logs folder the nested commands were built without
module_name, so every nested module ran regardless of the filter.
Pass self.module_name to all three nested commands; a filter naming
an AndroidQF module now runs exactly that module, and a filter naming
a nested module selects it from the nested command.
2026-11-23 20:36:27 +01:00
besendorf 126354b758 Merge branch 'main' into fix/androidqf-root-zip-931 2026-11-18 10:06:03 +01:00
Janik Besendorf 4a2561eb6f Validate AndroidQF APK SHA-256 values before lookup 2026-11-18 09:42:29 +01:00
Janik Besendorf 301616a296 Read AndroidQF process lists and skip ZIP directory entries 2026-11-18 00:03:12 +01:00
Janik Besendorf 086dde4b8f Merge main into fix/androidqf-root-zip-931 2026-11-18 00:02:50 +01:00
besendorf c7ee545c62 Merge branch 'main' into fix/androidqf-root-zip-931 2026-09-28 16:24:36 +02:00
besendorf 2a32bd431d Merge branch 'main' into fix/androidqf-root-zip-931 2026-09-27 19:27:17 +02:00
Janik Besendorf 2d6b1efc48 Fix AndroidQF artifact discovery in root-level ZIP archives 2026-09-17 10:55:47 +02:00
11 changed files with 444 additions and 50 deletions

No files matched your search

+2 -2
View File
@@ -47,8 +47,8 @@ RUN apt-get update \
&& mvt-ios --help > /dev/null
# Installing ABE
ADD --checksum=sha256:a20e07f8b2ea47620aff0267f230c3f1f495f097081fd709eec51cf2a2e11632 \
https://github.com/nelenkov/android-backup-extractor/releases/download/master-20221109063121-8fdfc5e/abe.jar /opt/abe/abe.jar
ADD --checksum=sha256:3f42f011b6b567431ab8cd9d4ae5c36cf19a82da835168718d1735d995a3ba1a \
https://github.com/nelenkov/android-backup-extractor/releases/download/v1.2.0/abe-v1.2.0.jar /opt/abe/abe.jar
# Create alias for abe
RUN echo 'alias abe="java -jar /opt/abe/abe.jar"' >> ~/.bashrc
+2 -2
View File
@@ -25,8 +25,8 @@ RUN apk add --no-cache --virtual .build-deps gcc musl-dev \
&& apk del .build-deps gcc musl-dev && rm -rf ./mvt
# Installing ABE
ADD --checksum=sha256:a20e07f8b2ea47620aff0267f230c3f1f495f097081fd709eec51cf2a2e11632 \
https://github.com/nelenkov/android-backup-extractor/releases/download/master-20221109063121-8fdfc5e/abe.jar /opt/abe/abe.jar
ADD --checksum=sha256:3f42f011b6b567431ab8cd9d4ae5c36cf19a82da835168718d1735d995a3ba1a \
https://github.com/nelenkov/android-backup-extractor/releases/download/v1.2.0/abe-v1.2.0.jar /opt/abe/abe.jar
# Create alias for abe
RUN echo 'alias abe="java -jar /opt/abe/abe.jar"' >> ~/.bashrc
+6 -1
View File
@@ -95,7 +95,9 @@ class CmdAndroidCheckAndroidQF(Command):
elif os.path.isfile(self.target_path):
self.__format = "zip"
self.__zip = zipfile.ZipFile(self.target_path)
self.__files = self.__zip.namelist()
self.__files = [
entry.filename for entry in self.__zip.infolist() if not entry.is_dir()
]
self._load_acquisition_context()
@@ -259,6 +261,7 @@ class CmdAndroidCheckAndroidQF(Command):
hashes=self.hashes,
sub_command=True,
custom_modules=self.custom_modules,
module_name=self.module_name,
)
cmd.from_zip(bugreport)
cmd.run()
@@ -290,6 +293,7 @@ class CmdAndroidCheckAndroidQF(Command):
hashes=self.hashes,
sub_command=True,
custom_modules=self.custom_modules,
module_name=self.module_name,
)
try:
cmd.from_ab(backup)
@@ -376,6 +380,7 @@ class CmdAndroidCheckAndroidQF(Command):
hashes=self.hashes,
sub_command=True,
custom_modules=self.custom_modules,
module_name=self.module_name,
)
cmd.run()
@@ -5,8 +5,9 @@
import json
import logging
import re
import time
from typing import Optional
from typing import Optional, TypeGuard
from rich.progress import track
@@ -24,6 +25,12 @@ from mvt.common.virustotal import VTNoKey, VTQuotaExceeded, virustotal_lookup
from .base import AndroidQFModule
def _is_sha256(value: object) -> TypeGuard[str]:
return (
isinstance(value, str) and re.fullmatch(r"[0-9a-fA-F]{64}", value) is not None
)
class AQFPackages(AndroidQFModule):
"""This module examines the installed packages in packages.json"""
@@ -97,9 +104,7 @@ class AQFPackages(AndroidQFModule):
self._check_exact_indicators(result)
if self.module_options.get("virustotal", False):
self.check_virustotal(
delay=self.module_options.get("virustotal_delay", 0)
)
self.check_virustotal(delay=self.module_options.get("virustotal_delay", 0))
def _check_exact_indicators(self, result: ModuleAtomicResult) -> None:
"""Check exact matches independently of package heuristics."""
@@ -119,16 +124,20 @@ class AQFPackages(AndroidQFModule):
for package_file in package_files:
if not isinstance(package_file, dict):
self.log.warning("Invalid file metadata for package %s", result.get("name"))
self.log.warning(
"Invalid file metadata for package %s", result.get("name")
)
continue
file_hash = package_file.get("sha256")
if file_hash is not None and not isinstance(file_hash, str):
self.log.warning("Invalid SHA-256 metadata for package %s", result.get("name"))
file_hash = None
ioc_match = self.indicators.check_file_hash(file_hash or "")
if ioc_match:
self.alertstore.critical(
ioc_match.message, "", result, matched_indicator=ioc_match.ioc
if _is_sha256(file_hash):
ioc_match = self.indicators.check_file_hash(file_hash)
if ioc_match:
self.alertstore.critical(
ioc_match.message, "", result, matched_indicator=ioc_match.ioc
)
elif file_hash not in (None, ""):
self.log.warning(
"Invalid SHA-256 metadata for package %s", result.get("name")
)
if "certificate" not in package_file:
@@ -136,7 +145,9 @@ class AQFPackages(AndroidQFModule):
certificate = package_file["certificate"]
if not isinstance(certificate, dict):
self.log.warning("Invalid certificate metadata for package %s", result.get("name"))
self.log.warning(
"Invalid certificate metadata for package %s", result.get("name")
)
continue
# The keys generated by AndroidQF have a leading uppercase character.
@@ -145,12 +156,11 @@ class AQFPackages(AndroidQFModule):
if not isinstance(certificate_hash, str):
self.log.warning(
"Missing or invalid %s certificate metadata for package %s",
hash_type, result.get("name"),
hash_type,
result.get("name"),
)
continue
ioc_match = self.indicators.check_app_certificate_hash(
certificate_hash
)
ioc_match = self.indicators.check_app_certificate_hash(certificate_hash)
if ioc_match:
self.alertstore.critical(
ioc_match.message,
@@ -170,7 +180,7 @@ class AQFPackages(AndroidQFModule):
for package_file in package.get("files", []):
file_hash = package_file.get("sha256")
if not file_hash:
if not _is_sha256(file_hash):
continue
files_by_hash.setdefault(file_hash, []).append((package, package_file))
@@ -34,7 +34,9 @@ class AQFProcesses(ProcessesArtifact, AndroidQFModule):
)
def run(self) -> None:
ps_files = self._get_files_by_pattern("*/ps.txt")
ps_files = self._get_files_by_pattern(
"*/processes.txt"
) or self._get_files_by_pattern("*/ps.txt")
if not ps_files:
return
+16 -2
View File
@@ -46,8 +46,22 @@ class AndroidQFModule(MVTModule):
self.archive = archive
self.files = files
def _get_files_by_pattern(self, pattern: str):
return fnmatch.filter(self.files, pattern)
def _get_files_by_pattern(self, pattern: str) -> List[str]:
pattern = pattern.replace("\\", "/")
patterns = [pattern]
# ZIPs may store artifacts at their root, without the acquisition
# directory prefix present in paths collected by from_dir().
if pattern.startswith("*/"):
patterns.append(pattern[2:])
return [
file_path
for file_path in self.files
if any(
fnmatch.fnmatch(file_path.replace("\\", "/"), candidate)
for candidate in patterns
)
]
def _get_device_timezone(self):
"""
+41 -2
View File
@@ -9,8 +9,10 @@ import logging
import os
import re
import shlex
import stat
import subprocess
from datetime import datetime
from pathlib import Path
from typing import Optional, Tuple
import requests
@@ -528,6 +530,20 @@ class IndicatorsUpdates:
return yaml.safe_load(res.content)
@staticmethod
def _ioc_file_name(ioc_url: str) -> str:
return ioc_url.split("://", 1)[-1].replace("/", "_")
@staticmethod
def _cached_file_id(path: Path) -> Optional[tuple[int, int]]:
try:
info = path.stat()
except FileNotFoundError:
return None
if stat.S_ISREG(info.st_mode):
return info.st_dev, info.st_ino
return None
def download_remote_ioc(self, ioc_url: str) -> Optional[str]:
try:
res = requests.get(ioc_url, timeout=15)
@@ -543,8 +559,7 @@ class IndicatorsUpdates:
)
return None
clean_file_name = ioc_url.lstrip("https://").replace("/", "_")
ioc_path = os.path.join(MVT_INDICATORS_FOLDER, clean_file_name)
ioc_path = os.path.join(MVT_INDICATORS_FOLDER, self._ioc_file_name(ioc_url))
with open(ioc_path, "w", encoding="utf-8") as handle:
handle.write(res.text)
@@ -561,6 +576,8 @@ class IndicatorsUpdates:
if not index:
return
legacy_names: set[str] = set()
protected_names: set[str] = set()
for ioc in index.get("indicators", []):
ioc_type = ioc.get("type", "")
@@ -582,14 +599,36 @@ class IndicatorsUpdates:
)
continue
# Keep every current name, including those of feeds that fail to refresh.
protected_names.add(self._ioc_file_name(ioc_url))
# Reproduce the old spelling for files already in the cache.
legacy_name = ioc_url.lstrip("https://").replace("/", "_")
ioc_local_path = self.download_remote_ioc(ioc_url)
if not ioc_local_path:
protected_names.add(legacy_name)
continue
legacy_names.add(legacy_name)
log.info(
'Downloaded indicators "%s" to %s', ioc.get("name"), ioc_local_path
)
obsolete_names = legacy_names - protected_names
if obsolete_names:
cache = Path(MVT_INDICATORS_FOLDER)
# Different spellings can refer to the same file on this filesystem.
protected_ids = {
self._cached_file_id(cache / name)
for name in protected_names
if Path(name).name == name
}
for cached_file in cache.iterdir():
if cached_file.name not in obsolete_names:
continue
file_id = self._cached_file_id(cached_file)
if file_id is not None and file_id not in protected_ids:
cached_file.unlink(missing_ok=True)
self.set_latest_update()
def _get_remote_file_latest_commit(
+60
View File
@@ -0,0 +1,60 @@
# Mobile Verification Toolkit (MVT)
# Copyright (c) 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 zipfile
import pytest
from mvt.android.modules.androidqf.base import AndroidQFModule
@pytest.mark.parametrize("prefix", ["", "./", "acquisition/", "outer/acquisition/"])
@pytest.mark.parametrize(
"pattern, filename",
[
("*/packages.json", "packages.json"),
("*/getprop.txt", "getprop.txt"),
("*/ps.txt", "ps.txt"),
("*/settings_*.txt", "settings_global.txt"),
("*/files.json", "files.json"),
("*/logs/*", "logs/logcat.txt"),
("*/mounts.json", "mounts.json"),
("*/root_binaries.json", "root_binaries.json"),
],
)
def test_artifact_lookup_preserves_archive_names(tmp_path, prefix, pattern, filename):
member = prefix + filename
with zipfile.ZipFile(tmp_path / "acquisition.zip", "w") as archive:
archive.writestr(member, b"artifact")
archive.writestr(prefix + "unrelated.txt", b"unrelated")
module = AndroidQFModule()
module.from_zip(archive, archive.namelist())
assert module._get_files_by_pattern(pattern) == [member]
assert module._get_file_content(member) == b"artifact"
def test_artifact_lookup_preserves_windows_paths():
module = AndroidQFModule()
module.from_dir("parent", [r"acquisition\logs\logcat.txt"])
assert module._get_files_by_pattern("*/logs/*") == [r"acquisition\logs\logcat.txt"]
def test_artifact_lookup_preserves_order_without_duplicates():
module = AndroidQFModule()
module.files = [
"acquisition/settings_global.txt",
"settings_secure.txt",
"./settings_system.txt",
"not_settings_global.txt",
"settings_global.txt.bak",
]
assert module._get_files_by_pattern("*/settings_*.txt") == module.files[:3]
assert module._get_files_by_pattern("settings_secure.txt") == [
"settings_secure.txt"
]
assert module._get_files_by_pattern("*/missing.txt") == []
+77 -22
View File
@@ -115,6 +115,43 @@ class TestAndroidqfPackages:
== "31037a27af59d4914906c01ad14a318eee2f3e31d48da8954dca62a99174e3fa"
)
@pytest.mark.parametrize(
"collection, invalid_hash",
[
("files_md5", "a" * 32),
("files_sha1", "a" * 40),
("files_sha256", "g" * 64),
],
)
def test_invalid_apk_sha256_preserves_other_matches(
self, indicators_factory, collection, invalid_hash
):
cert_hash = "b" * 64
valid_hash = "abcd" * 16
module = AQFPackages(
results=[
{
"name": "com.example.app",
"installer": "com.android.vending",
"files": [
{"sha256": invalid_hash, "certificate": {"Sha256": cert_hash}},
{"sha256": valid_hash.upper()},
],
}
]
)
module.indicators = indicators_factory(
files_sha256=[valid_hash], app_cert_hashes=[cert_hash]
)
module.indicators.ioc_collections[0][collection].append(invalid_hash)
module.check_indicators()
assert [a.matched_indicator.value for a in module.alertstore.alerts] == [
cert_hash,
valid_hash,
]
def test_packages_certificate_hash_ioc(self, module, indicators_factory):
module.indicators = indicators_factory(
app_cert_hashes=[
@@ -139,10 +176,12 @@ class TestAndroidqfPackages:
def test_virustotal_delays_after_missing_result(self, monkeypatch):
lookups = []
sleeps = []
missing_hash = "a" * 64
found_hash = "b" * 64
def fake_virustotal_lookup(file_hash):
lookups.append(file_hash)
if file_hash == "missing_hash":
if file_hash == missing_hash:
return None
return {
"attributes": {
@@ -165,8 +204,9 @@ class TestAndroidqfPackages:
"disabled": False,
"system": False,
"files": [
{"path": "/data/app/missing.apk", "sha256": "missing_hash"},
{"path": "/data/app/found.apk", "sha256": "found_hash"},
{"path": "/data/app/missing.apk", "sha256": missing_hash},
{"path": "/data/app/found.apk", "sha256": found_hash},
{"path": "/data/app/invalid.apk", "sha256": "c" * 32},
],
}
],
@@ -174,7 +214,7 @@ class TestAndroidqfPackages:
module.check_indicators()
assert lookups == ["missing_hash", "found_hash"]
assert lookups == [missing_hash, found_hash]
assert sleeps == [16]
assert module.results[0]["files"][1]["virustotal"] == "1/1"
assert len(module.alertstore.alerts) == 1
@@ -233,10 +273,16 @@ def test_root_package_heuristic_preserves_exact_ioc_checks(
def test_root_package_keeps_existing_heuristic_short_circuit(
indicators_factory, with_indicators
):
module = AQFPackages(results=[{
"name": "com.topjohnwu.magisk", "installer": "null", "system": False,
"files": [],
}])
module = AQFPackages(
results=[
{
"name": "com.topjohnwu.magisk",
"installer": "null",
"system": False,
"files": [],
}
]
)
if with_indicators:
module.indicators = indicators_factory(app_ids=["example.unrelated"])
module.check_indicators()
@@ -260,18 +306,22 @@ def test_root_package_incomplete_metadata_preserves_later_matches(
indicators_factory, files, caplog
):
root_name = "com.topjohnwu.magisk"
module = AQFPackages(results=[
{"name": root_name, "files": files},
{
"name": "example.later",
"installer": "com.android.vending",
"system": False,
"files": [{
"sha256": "a" * 64,
"certificate": {"Sha256": "b" * 64},
}],
},
])
module = AQFPackages(
results=[
{"name": root_name, "files": files},
{
"name": "example.later",
"installer": "com.android.vending",
"system": False,
"files": [
{
"sha256": "a" * 64,
"certificate": {"Sha256": "b" * 64},
}
],
},
]
)
module.indicators = indicators_factory(
app_ids=[root_name, "example.later"],
files_sha256=["a" * 64],
@@ -282,9 +332,14 @@ def test_root_package_incomplete_metadata_preserves_later_matches(
matches = [alert for alert in module.alertstore.alerts if alert.matched_indicator]
assert {alert.matched_indicator.value for alert in matches} == {
root_name, "example.later", "a" * 64, "b" * 64,
root_name,
"example.later",
"a" * 64,
"b" * 64,
}
assert any("rooting/jailbreaking" in alert.message for alert in module.alertstore.alerts)
assert any(
"rooting/jailbreaking" in alert.message for alert in module.alertstore.alerts
)
assert "metadata" in caplog.text
if isinstance(files, list) and any(
isinstance(item, dict)
+144
View File
@@ -0,0 +1,144 @@
import json
from types import SimpleNamespace
import pytest
from mvt.common import indicators, updates
@pytest.fixture
def updater_and_cache(tmp_path, monkeypatch):
cache = tmp_path / "indicators"
cache.mkdir()
monkeypatch.setattr(updates, "MVT_DATA_FOLDER", str(tmp_path))
monkeypatch.setattr(updates, "MVT_INDICATORS_FOLDER", str(cache))
monkeypatch.setattr(indicators, "MVT_INDICATORS_FOLDER", str(cache))
monkeypatch.setattr(indicators.settings, "STIX2", None)
return updates.IndicatorsUpdates(), cache
def _mock_downloads(monkeypatch, updater, responses):
monkeypatch.setattr(
updater,
"get_remote_index",
lambda: {"indicators": [{"download_url": url} for url in responses]},
)
monkeypatch.setattr(updates.requests, "get", lambda url, *, timeout: responses[url])
def _bundle(domain):
return json.dumps(
{
"objects": [
{
"type": "indicator",
"id": "indicator--test",
"pattern": f"[domain-name:value = '{domain}']",
}
]
}
)
@pytest.mark.parametrize("scheme", ["http", "https"])
def test_refresh_retires_legacy_download(scheme, updater_and_cache, monkeypatch):
updater, cache = updater_and_cache
legacy = cache / "ools.example_iocs.stix2"
legacy.write_text(_bundle("retired.example"), encoding="utf-8")
unrelated = cache / "other.stix2"
unrelated.write_text(_bundle("other.example"), encoding="utf-8")
_mock_downloads(
monkeypatch,
updater,
{
f"{scheme}://tools.example/iocs.stix2": SimpleNamespace(
status_code=200, text=_bundle("current.example")
)
},
)
updater.update()
updater.update()
assert not legacy.exists()
assert (cache / "tools.example_iocs.stix2").is_file()
loaded = indicators.Indicators()
loaded.load_indicators_files([])
assert {ioc.value for ioc in loaded.get_iocs("domains")} == {
"current.example",
"other.example",
}
@pytest.mark.parametrize(
("other_host", "status_code", "expected_legacy"),
[
("ools.example", 200, "other feed"),
("ools.example", 503, "cached feed"),
("stools.example", 503, "cached feed"),
("stools.example", 200, None),
],
)
def test_refresh_handles_legacy_filename_collisions(
other_host, status_code, expected_legacy, updater_and_cache, monkeypatch
):
updater, cache = updater_and_cache
legacy = cache / "ools.example_iocs.stix2"
legacy.write_text("cached feed", encoding="utf-8")
_mock_downloads(
monkeypatch,
updater,
{
"https://tools.example/iocs.stix2": SimpleNamespace(
status_code=200, text="refreshed feed"
),
f"https://{other_host}/iocs.stix2": SimpleNamespace(
status_code=status_code, text="other feed"
),
},
)
updater.update()
assert (cache / "tools.example_iocs.stix2").read_text(encoding="utf-8") == (
"refreshed feed"
)
if expected_legacy is None:
assert not legacy.exists()
else:
assert legacy.read_text(encoding="utf-8") == expected_legacy
@pytest.mark.parametrize("other_status", [200, 503])
def test_refresh_uses_filesystem_case_rules(
updater_and_cache, monkeypatch, other_status
):
updater, cache = updater_and_cache
# These are the two paths the previous version wrote, in index order.
legacy = cache / "ools.example_IOCs.stix2"
other = cache / "ools.example_iocs.stix2"
legacy.write_text(_bundle("retired.example"), encoding="utf-8")
other.write_text(_bundle("cached-other.example"), encoding="utf-8")
shared_file = legacy.samefile(other)
_mock_downloads(
monkeypatch,
updater,
{
"https://tools.example/IOCs.stix2": SimpleNamespace(
status_code=200, text=_bundle("current.example")
),
"https://ools.example/iocs.stix2": SimpleNamespace(
status_code=other_status, text=_bundle("updated-other.example")
),
},
)
updater.update()
assert legacy.exists() == shared_file
loaded = indicators.Indicators()
loaded.load_indicators_files([])
assert {ioc.value for ioc in loaded.get_iocs("domains")} == {
"current.example",
"updated-other.example" if other_status == 200 else "cached-other.example",
}
+65
View File
@@ -10,6 +10,7 @@ import shutil
import tempfile
import zipfile
import pytest
from click.testing import CliRunner
from mvt.android.cli import check_androidqf
@@ -23,7 +24,71 @@ from .utils import get_artifact_folder
TEST_BACKUP_PASSWORD = "123456"
@pytest.mark.parametrize(
"layout", ["directory", "", "./", "acquisition/", "outer/acquisition/"]
)
def test_androidqf_property_detection_across_layouts(
tmp_path, indicators_factory, monkeypatch, layout
):
monkeypatch.setattr(settings, "NETWORK_ACCESS_ALLOWED", False)
content = (
"[persist.sys.timezone]: [Europe/Berlin]\n"
"[test.suspicious.property]: [enabled]\n"
)
if layout == "directory":
target = tmp_path / "acquisition"
target.mkdir()
(target / "getprop.txt").write_text(content)
else:
target = tmp_path / "acquisition.zip"
with zipfile.ZipFile(target, "w") as archive:
archive.writestr(layout + "getprop.txt", content)
command = CmdAndroidCheckAndroidQF(
target_path=str(target),
module_name="AQFGetProp",
iocs=indicators_factory(android_property_names=["test.suspicious.property"]),
)
command.run()
assert len(command.executed) == 1
module = command.executed[0]
assert module.results == [
{"name": "persist.sys.timezone", "value": "Europe/Berlin"},
{"name": "test.suspicious.property", "value": "enabled"},
]
assert module._get_device_timezone() == "Europe/Berlin"
assert len(command.alertstore.alerts) == 1
assert command.alertstore.alerts[0].event == module.results[1]
class TestCheckAndroidqfCommand:
@pytest.mark.parametrize("use_zip", [False, True], ids=["folder", "zip"])
def test_androidqf_process_list_and_log_files(self, tmp_path, use_zip):
archive_path = tmp_path / "acquisition.zip"
with zipfile.ZipFile(archive_path, "w") as archive:
archive.writestr("processes.txt", "USER PID NAME\nroot 1 init\n")
archive.writestr("logs/proc/kmsg", "")
archive.writestr("logs/data/anr/", "")
target = archive_path if use_zip else tmp_path / "acquisition"
if not use_zip:
archive.extractall(target)
command = CmdAndroidCheckAndroidQF(
target_path=str(target),
disable_version_check=True,
disable_indicator_check=True,
)
command.run()
records = {type(module).__name__: module.results for module in command.executed}
assert records["AQFProcesses"] == [
{"user": "root", "pid": 1, "command": "init"}
]
timestamps = records["AQFLogTimestamps"]
assert len(timestamps) == 1
assert timestamps[0]["path"].replace("\\", "/").endswith("logs/proc/kmsg")
def test_log_timestamps_module_is_registered(self):
assert AQFLogTimestamps in ANDROIDQF_MODULES