mirror of
https://github.com/mvt-project/mvt
synced 2025-10-21 22:42:15 +02:00
Compare commits
20 Commits
fix_tests
...
feature/de
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
67863d8f8d | ||
|
|
779842567d | ||
|
|
5bf71e2268 | ||
|
|
caaffc8988 | ||
|
|
d3cc8cf590 | ||
|
|
b8a42eaf8f | ||
|
|
62b880fbff | ||
|
|
0778d448df | ||
|
|
f020655a1a | ||
|
|
91c34e6664 | ||
|
|
b4a8dd226a | ||
|
|
88213e12c9 | ||
|
|
f75b8e186a | ||
|
|
5babc1fcf3 | ||
|
|
b723ebf28e | ||
|
|
616e870212 | ||
|
|
847b0e087b | ||
|
|
4c1cdf5129 | ||
|
|
a08c24b02a | ||
|
|
5d696350dc |
2
Makefile
2
Makefile
@@ -23,7 +23,7 @@ install:
|
|||||||
python3 -m pip install --upgrade -e .
|
python3 -m pip install --upgrade -e .
|
||||||
|
|
||||||
test-requirements:
|
test-requirements:
|
||||||
python3 -m pip install --upgrade -r test-requirements.txt
|
python3 -m pip install --upgrade --group dev
|
||||||
|
|
||||||
generate-proto-parsers:
|
generate-proto-parsers:
|
||||||
# Generate python parsers for protobuf files
|
# Generate python parsers for protobuf files
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
mkdocs==1.6.1
|
mkdocs==1.6.1
|
||||||
mkdocs-autorefs==1.4.2
|
mkdocs-autorefs==1.4.3
|
||||||
mkdocs-material==9.6.16
|
mkdocs-material==9.6.20
|
||||||
mkdocs-material-extensions==1.3.1
|
mkdocs-material-extensions==1.3.1
|
||||||
mkdocstrings==0.30.0
|
mkdocstrings==0.30.1
|
||||||
@@ -1,13 +1,11 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "mvt"
|
name = "mvt"
|
||||||
dynamic = ["version"]
|
dynamic = ["version"]
|
||||||
authors = [
|
authors = [{ name = "Claudio Guarnieri", email = "nex@nex.sx" }]
|
||||||
{name = "Claudio Guarnieri", email = "nex@nex.sx"}
|
|
||||||
]
|
|
||||||
maintainers = [
|
maintainers = [
|
||||||
{name = "Etienne Maynier", email = "tek@randhome.io"},
|
{ name = "Etienne Maynier", email = "tek@randhome.io" },
|
||||||
{name = "Donncha Ó Cearbhaill", email = "donncha.ocearbhaill@amnesty.org"},
|
{ name = "Donncha Ó Cearbhaill", email = "donncha.ocearbhaill@amnesty.org" },
|
||||||
{name = "Rory Flynn", email = "rory.flynn@amnesty.org"}
|
{ name = "Rory Flynn", email = "rory.flynn@amnesty.org" },
|
||||||
]
|
]
|
||||||
description = "Mobile Verification Toolkit"
|
description = "Mobile Verification Toolkit"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
@@ -16,7 +14,7 @@ classifiers = [
|
|||||||
"Development Status :: 5 - Production/Stable",
|
"Development Status :: 5 - Production/Stable",
|
||||||
"Intended Audience :: Information Technology",
|
"Intended Audience :: Information Technology",
|
||||||
"Operating System :: OS Independent",
|
"Operating System :: OS Independent",
|
||||||
"Programming Language :: Python"
|
"Programming Language :: Python",
|
||||||
]
|
]
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"click==8.2.1",
|
"click==8.2.1",
|
||||||
@@ -37,6 +35,7 @@ dependencies = [
|
|||||||
"pydantic-settings==2.10.1",
|
"pydantic-settings==2.10.1",
|
||||||
"NSKeyedUnArchiver==1.5.2",
|
"NSKeyedUnArchiver==1.5.2",
|
||||||
"python-dateutil==2.9.0.post0",
|
"python-dateutil==2.9.0.post0",
|
||||||
|
"tzdata==2025.2",
|
||||||
]
|
]
|
||||||
requires-python = ">= 3.10"
|
requires-python = ">= 3.10"
|
||||||
|
|
||||||
@@ -45,20 +44,31 @@ homepage = "https://docs.mvt.re/en/latest/"
|
|||||||
repository = "https://github.com/mvt-project/mvt"
|
repository = "https://github.com/mvt-project/mvt"
|
||||||
|
|
||||||
[project.scripts]
|
[project.scripts]
|
||||||
mvt-ios = "mvt.ios:cli"
|
mvt-ios = "mvt.ios:cli"
|
||||||
mvt-android = "mvt.android:cli"
|
mvt-android = "mvt.android:cli"
|
||||||
|
|
||||||
|
[dependency-groups]
|
||||||
|
dev = [
|
||||||
|
"requests>=2.31.0",
|
||||||
|
"pytest>=7.4.3",
|
||||||
|
"pytest-cov>=4.1.0",
|
||||||
|
"pytest-github-actions-annotate-failures>=0.2.0",
|
||||||
|
"pytest-mock>=3.14.0",
|
||||||
|
"stix2>=3.0.1",
|
||||||
|
"ruff>=0.1.6",
|
||||||
|
"mypy>=1.7.1",
|
||||||
|
"betterproto[compiler]",
|
||||||
|
]
|
||||||
|
|
||||||
[build-system]
|
[build-system]
|
||||||
requires = ["setuptools>=61.0"]
|
requires = ["setuptools>=61.0"]
|
||||||
build-backend = "setuptools.build_meta"
|
build-backend = "setuptools.build_meta"
|
||||||
|
|
||||||
[tool.coverage.run]
|
[tool.coverage.run]
|
||||||
omit = [
|
omit = ["tests/*"]
|
||||||
"tests/*",
|
|
||||||
]
|
|
||||||
|
|
||||||
[tool.coverage.html]
|
[tool.coverage.html]
|
||||||
directory= "htmlcov"
|
directory = "htmlcov"
|
||||||
|
|
||||||
[tool.mypy]
|
[tool.mypy]
|
||||||
install_types = true
|
install_types = true
|
||||||
@@ -68,15 +78,13 @@ packages = "src"
|
|||||||
|
|
||||||
[tool.pytest.ini_options]
|
[tool.pytest.ini_options]
|
||||||
addopts = "-ra -q --cov=mvt --cov-report html --junitxml=pytest.xml --cov-report=term-missing:skip-covered"
|
addopts = "-ra -q --cov=mvt --cov-report html --junitxml=pytest.xml --cov-report=term-missing:skip-covered"
|
||||||
testpaths = [
|
testpaths = ["tests"]
|
||||||
"tests"
|
|
||||||
]
|
|
||||||
|
|
||||||
[tool.ruff.lint]
|
[tool.ruff.lint]
|
||||||
select = ["C90", "E", "F", "W"] # flake8 default set
|
select = ["C90", "E", "F", "W"] # flake8 default set
|
||||||
ignore = [
|
ignore = [
|
||||||
"E501", # don't enforce line length violations
|
"E501", # don't enforce line length violations
|
||||||
"C901", # complex-structure
|
"C901", # complex-structure
|
||||||
|
|
||||||
# These were previously ignored but don't seem to be required:
|
# These were previously ignored but don't seem to be required:
|
||||||
# "E265", # no-space-after-block-comment
|
# "E265", # no-space-after-block-comment
|
||||||
@@ -88,14 +96,14 @@ ignore = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[tool.ruff.lint.per-file-ignores]
|
[tool.ruff.lint.per-file-ignores]
|
||||||
"__init__.py" = ["F401"] # unused-import
|
"__init__.py" = ["F401"] # unused-import
|
||||||
|
|
||||||
[tool.ruff.lint.mccabe]
|
[tool.ruff.lint.mccabe]
|
||||||
max-complexity = 10
|
max-complexity = 10
|
||||||
|
|
||||||
[tool.setuptools]
|
[tool.setuptools]
|
||||||
include-package-data = true
|
include-package-data = true
|
||||||
package-dir = {"" = "src"}
|
package-dir = { "" = "src" }
|
||||||
|
|
||||||
[tool.setuptools.packages.find]
|
[tool.setuptools.packages.find]
|
||||||
where = ["src"]
|
where = ["src"]
|
||||||
@@ -104,4 +112,4 @@ where = ["src"]
|
|||||||
mvt = ["ios/data/*.json"]
|
mvt = ["ios/data/*.json"]
|
||||||
|
|
||||||
[tool.setuptools.dynamic]
|
[tool.setuptools.dynamic]
|
||||||
version = {attr = "mvt.common.version.MVT_VERSION"}
|
version = { attr = "mvt.common.version.MVT_VERSION" }
|
||||||
|
|||||||
@@ -21,22 +21,12 @@ class DumpsysADBArtifact(AndroidArtifact):
|
|||||||
stack = [res]
|
stack = [res]
|
||||||
cur_indent = 0
|
cur_indent = 0
|
||||||
in_multiline = False
|
in_multiline = False
|
||||||
# Normalize line endings to handle both Unix (\n) and Windows (\r\n)
|
for line in dump_data.strip(b"\n").split(b"\n"):
|
||||||
normalized_data = dump_data.replace(b"\r\n", b"\n").replace(b"\r", b"\n")
|
|
||||||
for line in normalized_data.strip(b"\n").split(b"\n"):
|
|
||||||
# Skip completely empty lines
|
|
||||||
if not line.strip():
|
|
||||||
continue
|
|
||||||
|
|
||||||
# Track the level of indentation
|
# Track the level of indentation
|
||||||
indent = len(line) - len(line.lstrip())
|
indent = len(line) - len(line.lstrip())
|
||||||
if indent < cur_indent:
|
if indent < cur_indent:
|
||||||
# If the current line is less indented than the previous one, back out
|
# If the current line is less indented than the previous one, back out
|
||||||
while len(stack) > 1 and indent < cur_indent:
|
stack.pop()
|
||||||
stack.pop()
|
|
||||||
# Check if we were in multiline mode and need to exit it
|
|
||||||
if in_multiline and not isinstance(stack[-1], list):
|
|
||||||
in_multiline = False
|
|
||||||
cur_indent = indent
|
cur_indent = indent
|
||||||
else:
|
else:
|
||||||
cur_indent = indent
|
cur_indent = indent
|
||||||
@@ -48,30 +38,12 @@ class DumpsysADBArtifact(AndroidArtifact):
|
|||||||
|
|
||||||
# Annoyingly, some values are multiline and don't have a key on each line
|
# Annoyingly, some values are multiline and don't have a key on each line
|
||||||
if in_multiline:
|
if in_multiline:
|
||||||
if key == "" and len(vals) < 2:
|
if key == "":
|
||||||
# If the line is empty, it's the terminator for the multiline value
|
# If the line is empty, it's the terminator for the multiline value
|
||||||
in_multiline = False
|
in_multiline = False
|
||||||
stack.pop()
|
stack.pop()
|
||||||
current_dict = stack[-1]
|
|
||||||
elif len(vals) >= 2 and (key in self.multiline_fields or key == "}" or vals[1] == b"{"):
|
|
||||||
# If we encounter a new field while in multiline mode, exit multiline mode
|
|
||||||
# and process this line as a new field
|
|
||||||
in_multiline = False
|
|
||||||
stack.pop()
|
|
||||||
current_dict = stack[-1]
|
|
||||||
# Don't continue here - let the line be processed as a new field
|
|
||||||
else:
|
else:
|
||||||
# When in multiline mode, the top of stack should be a list
|
current_dict.append(line.lstrip())
|
||||||
if isinstance(stack[-1], list):
|
|
||||||
stack[-1].append(line.lstrip())
|
|
||||||
else:
|
|
||||||
# Something went wrong with the stack, exit multiline mode
|
|
||||||
in_multiline = False
|
|
||||||
current_dict = stack[-1]
|
|
||||||
continue
|
|
||||||
|
|
||||||
# Skip lines that don't have a value after '='
|
|
||||||
if len(vals) < 2:
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if key == "}":
|
if key == "}":
|
||||||
@@ -161,16 +133,7 @@ class DumpsysADBArtifact(AndroidArtifact):
|
|||||||
|
|
||||||
# TODO: Parse AdbDebuggingManager line in output.
|
# TODO: Parse AdbDebuggingManager line in output.
|
||||||
start_of_json = content.find(b"\n{") + 2
|
start_of_json = content.find(b"\n{") + 2
|
||||||
|
end_of_json = content.rfind(b"}\n") - 2
|
||||||
# Handle both Unix (\n) and Windows (\r\n) line endings
|
|
||||||
end_of_json = content.rfind(b"}\n")
|
|
||||||
if end_of_json == -1:
|
|
||||||
end_of_json = content.rfind(b"}\r\n")
|
|
||||||
if end_of_json == -1:
|
|
||||||
self.log.error("Unable to find end of JSON block in dumpsys output")
|
|
||||||
return
|
|
||||||
|
|
||||||
end_of_json -= 2
|
|
||||||
json_content = content[start_of_json:end_of_json].rstrip()
|
json_content = content[start_of_json:end_of_json].rstrip()
|
||||||
|
|
||||||
parsed = self.indented_dump_parser(json_content)
|
parsed = self.indented_dump_parser(json_content)
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class TombstoneCrashResult(pydantic.BaseModel):
|
|||||||
file_name: str
|
file_name: str
|
||||||
file_timestamp: str # We store the timestamp as a string to avoid timezone issues
|
file_timestamp: str # We store the timestamp as a string to avoid timezone issues
|
||||||
build_fingerprint: str
|
build_fingerprint: str
|
||||||
revision: int
|
revision: str
|
||||||
arch: Optional[str] = None
|
arch: Optional[str] = None
|
||||||
timestamp: str # We store the timestamp as a string to avoid timezone issues
|
timestamp: str # We store the timestamp as a string to avoid timezone issues
|
||||||
process_uptime: Optional[int] = None
|
process_uptime: Optional[int] = None
|
||||||
@@ -187,7 +187,7 @@ class TombstoneCrashArtifact(AndroidArtifact):
|
|||||||
raise ValueError(f"Expected key {key}, got {line_key}")
|
raise ValueError(f"Expected key {key}, got {line_key}")
|
||||||
|
|
||||||
value_clean = value.strip().strip("'")
|
value_clean = value.strip().strip("'")
|
||||||
if destination_key in ["uid", "revision"]:
|
if destination_key == "uid":
|
||||||
tombstone[destination_key] = int(value_clean)
|
tombstone[destination_key] = int(value_clean)
|
||||||
elif destination_key == "process_uptime":
|
elif destination_key == "process_uptime":
|
||||||
# eg. "Process uptime: 40s"
|
# eg. "Process uptime: 40s"
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import logging
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from mvt.common.command import Command
|
from mvt.common.command import Command
|
||||||
|
from mvt.common.indicators import Indicators
|
||||||
|
|
||||||
from .modules.adb import ADB_MODULES
|
from .modules.adb import ADB_MODULES
|
||||||
|
|
||||||
@@ -19,17 +20,23 @@ class CmdAndroidCheckADB(Command):
|
|||||||
target_path: Optional[str] = None,
|
target_path: Optional[str] = None,
|
||||||
results_path: Optional[str] = None,
|
results_path: Optional[str] = None,
|
||||||
ioc_files: Optional[list] = None,
|
ioc_files: Optional[list] = None,
|
||||||
|
iocs: Optional[Indicators] = None,
|
||||||
module_name: Optional[str] = None,
|
module_name: Optional[str] = None,
|
||||||
serial: Optional[str] = None,
|
serial: Optional[str] = None,
|
||||||
module_options: Optional[dict] = None,
|
module_options: Optional[dict] = None,
|
||||||
|
hashes: Optional[bool] = False,
|
||||||
|
sub_command: Optional[bool] = False,
|
||||||
) -> None:
|
) -> None:
|
||||||
super().__init__(
|
super().__init__(
|
||||||
target_path=target_path,
|
target_path=target_path,
|
||||||
results_path=results_path,
|
results_path=results_path,
|
||||||
ioc_files=ioc_files,
|
ioc_files=ioc_files,
|
||||||
|
iocs=iocs,
|
||||||
module_name=module_name,
|
module_name=module_name,
|
||||||
serial=serial,
|
serial=serial,
|
||||||
module_options=module_options,
|
module_options=module_options,
|
||||||
|
hashes=hashes,
|
||||||
|
sub_command=sub_command,
|
||||||
log=log,
|
log=log,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -10,58 +10,182 @@ from pathlib import Path
|
|||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
from mvt.common.command import Command
|
from mvt.common.command import Command
|
||||||
|
from mvt.common.indicators import Indicators
|
||||||
|
|
||||||
|
from mvt.android.cmd_check_bugreport import CmdAndroidCheckBugreport
|
||||||
|
from mvt.android.cmd_check_backup import CmdAndroidCheckBackup
|
||||||
|
|
||||||
from .modules.androidqf import ANDROIDQF_MODULES
|
from .modules.androidqf import ANDROIDQF_MODULES
|
||||||
|
from .modules.androidqf.base import AndroidQFModule
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class NoAndroidQFTargetPath(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class NoAndroidQFBugReport(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class NoAndroidQFBackup(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class CmdAndroidCheckAndroidQF(Command):
|
class CmdAndroidCheckAndroidQF(Command):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
target_path: Optional[str] = None,
|
target_path: Optional[str] = None,
|
||||||
results_path: Optional[str] = None,
|
results_path: Optional[str] = None,
|
||||||
ioc_files: Optional[list] = None,
|
ioc_files: Optional[list] = None,
|
||||||
|
iocs: Optional[Indicators] = None,
|
||||||
module_name: Optional[str] = None,
|
module_name: Optional[str] = None,
|
||||||
serial: Optional[str] = None,
|
serial: Optional[str] = None,
|
||||||
module_options: Optional[dict] = None,
|
module_options: Optional[dict] = None,
|
||||||
hashes: bool = False,
|
hashes: Optional[bool] = False,
|
||||||
|
sub_command: Optional[bool] = False,
|
||||||
) -> None:
|
) -> None:
|
||||||
super().__init__(
|
super().__init__(
|
||||||
target_path=target_path,
|
target_path=target_path,
|
||||||
results_path=results_path,
|
results_path=results_path,
|
||||||
ioc_files=ioc_files,
|
ioc_files=ioc_files,
|
||||||
|
iocs=iocs,
|
||||||
module_name=module_name,
|
module_name=module_name,
|
||||||
serial=serial,
|
serial=serial,
|
||||||
module_options=module_options,
|
module_options=module_options,
|
||||||
hashes=hashes,
|
hashes=hashes,
|
||||||
|
sub_command=sub_command,
|
||||||
log=log,
|
log=log,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.name = "check-androidqf"
|
self.name = "check-androidqf"
|
||||||
self.modules = ANDROIDQF_MODULES
|
self.modules = ANDROIDQF_MODULES
|
||||||
|
|
||||||
self.format: Optional[str] = None
|
self.__format: Optional[str] = None
|
||||||
self.archive: Optional[zipfile.ZipFile] = None
|
self.__zip: Optional[zipfile.ZipFile] = None
|
||||||
self.files: List[str] = []
|
self.__files: List[str] = []
|
||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
if os.path.isdir(self.target_path):
|
if os.path.isdir(self.target_path):
|
||||||
self.format = "dir"
|
self.__format = "dir"
|
||||||
parent_path = Path(self.target_path).absolute().parent.as_posix()
|
parent_path = Path(self.target_path).absolute().parent.as_posix()
|
||||||
target_abs_path = os.path.abspath(self.target_path)
|
target_abs_path = os.path.abspath(self.target_path)
|
||||||
for root, subdirs, subfiles in os.walk(target_abs_path):
|
for root, subdirs, subfiles in os.walk(target_abs_path):
|
||||||
for fname in subfiles:
|
for fname in subfiles:
|
||||||
file_path = os.path.relpath(os.path.join(root, fname), parent_path)
|
file_path = os.path.relpath(os.path.join(root, fname), parent_path)
|
||||||
self.files.append(file_path)
|
self.__files.append(file_path)
|
||||||
elif os.path.isfile(self.target_path):
|
elif os.path.isfile(self.target_path):
|
||||||
self.format = "zip"
|
self.__format = "zip"
|
||||||
self.archive = zipfile.ZipFile(self.target_path)
|
self.__zip = zipfile.ZipFile(self.target_path)
|
||||||
self.files = self.archive.namelist()
|
self.__files = self.__zip.namelist()
|
||||||
|
|
||||||
def module_init(self, module):
|
def module_init(self, module: AndroidQFModule) -> None: # type: ignore[override]
|
||||||
if self.format == "zip":
|
if self.__format == "zip" and self.__zip:
|
||||||
module.from_zip_file(self.archive, self.files)
|
module.from_zip(self.__zip, self.__files)
|
||||||
|
return
|
||||||
|
|
||||||
|
if not self.target_path:
|
||||||
|
raise NoAndroidQFTargetPath
|
||||||
|
|
||||||
|
parent_path = Path(self.target_path).absolute().parent.as_posix()
|
||||||
|
module.from_dir(parent_path, self.__files)
|
||||||
|
|
||||||
|
def load_bugreport(self) -> zipfile.ZipFile:
|
||||||
|
bugreport_zip_path = None
|
||||||
|
for file_name in self.__files:
|
||||||
|
if file_name.endswith("bugreport.zip"):
|
||||||
|
bugreport_zip_path = file_name
|
||||||
|
break
|
||||||
else:
|
else:
|
||||||
|
raise NoAndroidQFBugReport
|
||||||
|
|
||||||
|
if self.__format == "zip" and self.__zip:
|
||||||
|
handle = self.__zip.open(bugreport_zip_path)
|
||||||
|
return zipfile.ZipFile(handle)
|
||||||
|
|
||||||
|
if self.__format == "dir" and self.target_path:
|
||||||
parent_path = Path(self.target_path).absolute().parent.as_posix()
|
parent_path = Path(self.target_path).absolute().parent.as_posix()
|
||||||
module.from_folder(parent_path, self.files)
|
bug_report_path = os.path.join(parent_path, bugreport_zip_path)
|
||||||
|
return zipfile.ZipFile(bug_report_path)
|
||||||
|
|
||||||
|
raise NoAndroidQFBugReport
|
||||||
|
|
||||||
|
def load_backup(self) -> bytes:
|
||||||
|
backup_ab_path = None
|
||||||
|
for file_name in self.__files:
|
||||||
|
if file_name.endswith("backup.ab"):
|
||||||
|
backup_ab_path = file_name
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
raise NoAndroidQFBackup
|
||||||
|
|
||||||
|
if self.__format == "zip" and self.__zip:
|
||||||
|
backup_file_handle = self.__zip.open(backup_ab_path)
|
||||||
|
return backup_file_handle.read()
|
||||||
|
|
||||||
|
if self.__format == "dir" and self.target_path:
|
||||||
|
parent_path = Path(self.target_path).absolute().parent.as_posix()
|
||||||
|
backup_path = os.path.join(parent_path, backup_ab_path)
|
||||||
|
with open(backup_path, "rb") as backup_file:
|
||||||
|
backup_ab_data = backup_file.read()
|
||||||
|
return backup_ab_data
|
||||||
|
|
||||||
|
raise NoAndroidQFBackup
|
||||||
|
|
||||||
|
def run_bugreport_cmd(self) -> bool:
|
||||||
|
try:
|
||||||
|
bugreport = self.load_bugreport()
|
||||||
|
except NoAndroidQFBugReport:
|
||||||
|
self.log.warning(
|
||||||
|
"Skipping bugreport modules as no bugreport.zip found in AndroidQF data."
|
||||||
|
)
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
cmd = CmdAndroidCheckBugreport(
|
||||||
|
target_path=None,
|
||||||
|
results_path=self.results_path,
|
||||||
|
ioc_files=self.ioc_files,
|
||||||
|
iocs=self.iocs,
|
||||||
|
module_options=self.module_options,
|
||||||
|
hashes=self.hashes,
|
||||||
|
sub_command=True,
|
||||||
|
)
|
||||||
|
cmd.from_zip(bugreport)
|
||||||
|
cmd.run()
|
||||||
|
|
||||||
|
self.detected_count += cmd.detected_count
|
||||||
|
self.timeline.extend(cmd.timeline)
|
||||||
|
self.timeline_detected.extend(cmd.timeline_detected)
|
||||||
|
|
||||||
|
def run_backup_cmd(self) -> bool:
|
||||||
|
try:
|
||||||
|
backup = self.load_backup()
|
||||||
|
except NoAndroidQFBackup:
|
||||||
|
self.log.warning(
|
||||||
|
"Skipping backup modules as no backup.ab found in AndroidQF data."
|
||||||
|
)
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
cmd = CmdAndroidCheckBackup(
|
||||||
|
target_path=None,
|
||||||
|
results_path=self.results_path,
|
||||||
|
ioc_files=self.ioc_files,
|
||||||
|
iocs=self.iocs,
|
||||||
|
module_options=self.module_options,
|
||||||
|
hashes=self.hashes,
|
||||||
|
sub_command=True,
|
||||||
|
)
|
||||||
|
cmd.from_ab(backup)
|
||||||
|
cmd.run()
|
||||||
|
|
||||||
|
self.detected_count += cmd.detected_count
|
||||||
|
self.timeline.extend(cmd.timeline)
|
||||||
|
self.timeline_detected.extend(cmd.timeline_detected)
|
||||||
|
|
||||||
|
def finish(self) -> None:
|
||||||
|
"""
|
||||||
|
Run the bugreport and backup modules if the respective files are found in the AndroidQF data.
|
||||||
|
"""
|
||||||
|
self.run_bugreport_cmd()
|
||||||
|
self.run_backup_cmd()
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ from mvt.android.parsers.backup import (
|
|||||||
parse_backup_file,
|
parse_backup_file,
|
||||||
)
|
)
|
||||||
from mvt.common.command import Command
|
from mvt.common.command import Command
|
||||||
|
from mvt.common.indicators import Indicators
|
||||||
|
|
||||||
from .modules.backup import BACKUP_MODULES
|
from .modules.backup import BACKUP_MODULES
|
||||||
|
|
||||||
@@ -32,19 +33,23 @@ class CmdAndroidCheckBackup(Command):
|
|||||||
target_path: Optional[str] = None,
|
target_path: Optional[str] = None,
|
||||||
results_path: Optional[str] = None,
|
results_path: Optional[str] = None,
|
||||||
ioc_files: Optional[list] = None,
|
ioc_files: Optional[list] = None,
|
||||||
|
iocs: Optional[Indicators] = None,
|
||||||
module_name: Optional[str] = None,
|
module_name: Optional[str] = None,
|
||||||
serial: Optional[str] = None,
|
serial: Optional[str] = None,
|
||||||
module_options: Optional[dict] = None,
|
module_options: Optional[dict] = None,
|
||||||
hashes: bool = False,
|
hashes: Optional[bool] = False,
|
||||||
|
sub_command: Optional[bool] = False,
|
||||||
) -> None:
|
) -> None:
|
||||||
super().__init__(
|
super().__init__(
|
||||||
target_path=target_path,
|
target_path=target_path,
|
||||||
results_path=results_path,
|
results_path=results_path,
|
||||||
ioc_files=ioc_files,
|
ioc_files=ioc_files,
|
||||||
|
iocs=iocs,
|
||||||
module_name=module_name,
|
module_name=module_name,
|
||||||
serial=serial,
|
serial=serial,
|
||||||
module_options=module_options,
|
module_options=module_options,
|
||||||
hashes=hashes,
|
hashes=hashes,
|
||||||
|
sub_command=sub_command,
|
||||||
log=log,
|
log=log,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -55,6 +60,34 @@ class CmdAndroidCheckBackup(Command):
|
|||||||
self.backup_archive: Optional[tarfile.TarFile] = None
|
self.backup_archive: Optional[tarfile.TarFile] = None
|
||||||
self.backup_files: List[str] = []
|
self.backup_files: List[str] = []
|
||||||
|
|
||||||
|
def from_ab(self, ab_file_bytes: bytes) -> None:
|
||||||
|
self.backup_type = "ab"
|
||||||
|
header = parse_ab_header(ab_file_bytes)
|
||||||
|
if not header["backup"]:
|
||||||
|
log.critical("Invalid backup format, file should be in .ab format")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
password = None
|
||||||
|
if header["encryption"] != "none":
|
||||||
|
password = prompt_or_load_android_backup_password(log, self.module_options)
|
||||||
|
if not password:
|
||||||
|
log.critical("No backup password provided.")
|
||||||
|
sys.exit(1)
|
||||||
|
try:
|
||||||
|
tardata = parse_backup_file(ab_file_bytes, password=password)
|
||||||
|
except InvalidBackupPassword:
|
||||||
|
log.critical("Invalid backup password")
|
||||||
|
sys.exit(1)
|
||||||
|
except AndroidBackupParsingError as exc:
|
||||||
|
log.critical("Impossible to parse this backup file: %s", exc)
|
||||||
|
log.critical("Please use Android Backup Extractor (ABE) instead")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
dbytes = io.BytesIO(tardata)
|
||||||
|
self.backup_archive = tarfile.open(fileobj=dbytes)
|
||||||
|
for member in self.backup_archive:
|
||||||
|
self.backup_files.append(member.name)
|
||||||
|
|
||||||
def init(self) -> None:
|
def init(self) -> None:
|
||||||
if not self.target_path:
|
if not self.target_path:
|
||||||
return
|
return
|
||||||
@@ -62,35 +95,8 @@ class CmdAndroidCheckBackup(Command):
|
|||||||
if os.path.isfile(self.target_path):
|
if os.path.isfile(self.target_path):
|
||||||
self.backup_type = "ab"
|
self.backup_type = "ab"
|
||||||
with open(self.target_path, "rb") as handle:
|
with open(self.target_path, "rb") as handle:
|
||||||
data = handle.read()
|
ab_file_bytes = handle.read()
|
||||||
|
self.from_ab(ab_file_bytes)
|
||||||
header = parse_ab_header(data)
|
|
||||||
if not header["backup"]:
|
|
||||||
log.critical("Invalid backup format, file should be in .ab format")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
password = None
|
|
||||||
if header["encryption"] != "none":
|
|
||||||
password = prompt_or_load_android_backup_password(
|
|
||||||
log, self.module_options
|
|
||||||
)
|
|
||||||
if not password:
|
|
||||||
log.critical("No backup password provided.")
|
|
||||||
sys.exit(1)
|
|
||||||
try:
|
|
||||||
tardata = parse_backup_file(data, password=password)
|
|
||||||
except InvalidBackupPassword:
|
|
||||||
log.critical("Invalid backup password")
|
|
||||||
sys.exit(1)
|
|
||||||
except AndroidBackupParsingError as exc:
|
|
||||||
log.critical("Impossible to parse this backup file: %s", exc)
|
|
||||||
log.critical("Please use Android Backup Extractor (ABE) instead")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
dbytes = io.BytesIO(tardata)
|
|
||||||
self.backup_archive = tarfile.open(fileobj=dbytes)
|
|
||||||
for member in self.backup_archive:
|
|
||||||
self.backup_files.append(member.name)
|
|
||||||
|
|
||||||
elif os.path.isdir(self.target_path):
|
elif os.path.isdir(self.target_path):
|
||||||
self.backup_type = "folder"
|
self.backup_type = "folder"
|
||||||
@@ -109,6 +115,6 @@ class CmdAndroidCheckBackup(Command):
|
|||||||
|
|
||||||
def module_init(self, module: BackupExtraction) -> None: # type: ignore[override]
|
def module_init(self, module: BackupExtraction) -> None: # type: ignore[override]
|
||||||
if self.backup_type == "folder":
|
if self.backup_type == "folder":
|
||||||
module.from_folder(self.target_path, self.backup_files)
|
module.from_dir(self.target_path, self.backup_files)
|
||||||
else:
|
else:
|
||||||
module.from_ab(self.target_path, self.backup_archive, self.backup_files)
|
module.from_ab(self.target_path, self.backup_archive, self.backup_files)
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ from zipfile import ZipFile
|
|||||||
|
|
||||||
from mvt.android.modules.bugreport.base import BugReportModule
|
from mvt.android.modules.bugreport.base import BugReportModule
|
||||||
from mvt.common.command import Command
|
from mvt.common.command import Command
|
||||||
|
from mvt.common.indicators import Indicators
|
||||||
|
|
||||||
from .modules.bugreport import BUGREPORT_MODULES
|
from .modules.bugreport import BUGREPORT_MODULES
|
||||||
|
|
||||||
@@ -23,54 +24,76 @@ class CmdAndroidCheckBugreport(Command):
|
|||||||
target_path: Optional[str] = None,
|
target_path: Optional[str] = None,
|
||||||
results_path: Optional[str] = None,
|
results_path: Optional[str] = None,
|
||||||
ioc_files: Optional[list] = None,
|
ioc_files: Optional[list] = None,
|
||||||
|
iocs: Optional[Indicators] = None,
|
||||||
module_name: Optional[str] = None,
|
module_name: Optional[str] = None,
|
||||||
serial: Optional[str] = None,
|
serial: Optional[str] = None,
|
||||||
module_options: Optional[dict] = None,
|
module_options: Optional[dict] = None,
|
||||||
hashes: bool = False,
|
hashes: Optional[bool] = False,
|
||||||
|
sub_command: Optional[bool] = False,
|
||||||
) -> None:
|
) -> None:
|
||||||
super().__init__(
|
super().__init__(
|
||||||
target_path=target_path,
|
target_path=target_path,
|
||||||
results_path=results_path,
|
results_path=results_path,
|
||||||
ioc_files=ioc_files,
|
ioc_files=ioc_files,
|
||||||
|
iocs=iocs,
|
||||||
module_name=module_name,
|
module_name=module_name,
|
||||||
serial=serial,
|
serial=serial,
|
||||||
module_options=module_options,
|
module_options=module_options,
|
||||||
hashes=hashes,
|
hashes=hashes,
|
||||||
|
sub_command=sub_command,
|
||||||
log=log,
|
log=log,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.name = "check-bugreport"
|
self.name = "check-bugreport"
|
||||||
self.modules = BUGREPORT_MODULES
|
self.modules = BUGREPORT_MODULES
|
||||||
|
|
||||||
self.bugreport_format: str = ""
|
self.__format: str = ""
|
||||||
self.bugreport_archive: Optional[ZipFile] = None
|
self.__zip: Optional[ZipFile] = None
|
||||||
self.bugreport_files: List[str] = []
|
self.__files: List[str] = []
|
||||||
|
|
||||||
|
def from_dir(self, dir_path: str) -> None:
|
||||||
|
"""This method is used to initialize the bug report analysis from an
|
||||||
|
uncompressed directory.
|
||||||
|
"""
|
||||||
|
self.__format = "dir"
|
||||||
|
self.target_path = dir_path
|
||||||
|
parent_path = Path(dir_path).absolute().as_posix()
|
||||||
|
for root, _, subfiles in os.walk(os.path.abspath(dir_path)):
|
||||||
|
for file_name in subfiles:
|
||||||
|
file_path = os.path.relpath(os.path.join(root, file_name), parent_path)
|
||||||
|
self.__files.append(file_path)
|
||||||
|
|
||||||
|
def from_zip(self, bugreport_zip: ZipFile) -> None:
|
||||||
|
"""This method is used to initialize the bug report analysis from a
|
||||||
|
compressed archive.
|
||||||
|
"""
|
||||||
|
# NOTE: This will be invoked either by the CLI directly,or by the
|
||||||
|
# check-androidqf command. We need this because we want to support
|
||||||
|
# check-androidqf to analyse compressed archives itself too.
|
||||||
|
# So, we'll need to extract bugreport.zip from a 'androidqf.zip', and
|
||||||
|
# since nothing is written on disk, we need to be able to pass this
|
||||||
|
# command a ZipFile instance in memory.
|
||||||
|
|
||||||
|
self.__format = "zip"
|
||||||
|
self.__zip = bugreport_zip
|
||||||
|
for file_name in self.__zip.namelist():
|
||||||
|
self.__files.append(file_name)
|
||||||
|
|
||||||
def init(self) -> None:
|
def init(self) -> None:
|
||||||
if not self.target_path:
|
if not self.target_path:
|
||||||
return
|
return
|
||||||
|
|
||||||
if os.path.isfile(self.target_path):
|
if os.path.isfile(self.target_path):
|
||||||
self.bugreport_format = "zip"
|
self.from_zip(ZipFile(self.target_path))
|
||||||
self.bugreport_archive = ZipFile(self.target_path)
|
|
||||||
for file_name in self.bugreport_archive.namelist():
|
|
||||||
self.bugreport_files.append(file_name)
|
|
||||||
elif os.path.isdir(self.target_path):
|
elif os.path.isdir(self.target_path):
|
||||||
self.bugreport_format = "dir"
|
self.from_dir(self.target_path)
|
||||||
parent_path = Path(self.target_path).absolute().as_posix()
|
|
||||||
for root, _, subfiles in os.walk(os.path.abspath(self.target_path)):
|
|
||||||
for file_name in subfiles:
|
|
||||||
file_path = os.path.relpath(
|
|
||||||
os.path.join(root, file_name), parent_path
|
|
||||||
)
|
|
||||||
self.bugreport_files.append(file_path)
|
|
||||||
|
|
||||||
def module_init(self, module: BugReportModule) -> None: # type: ignore[override]
|
def module_init(self, module: BugReportModule) -> None: # type: ignore[override]
|
||||||
if self.bugreport_format == "zip":
|
if self.__format == "zip":
|
||||||
module.from_zip(self.bugreport_archive, self.bugreport_files)
|
module.from_zip(self.__zip, self.__files)
|
||||||
else:
|
else:
|
||||||
module.from_folder(self.target_path, self.bugreport_files)
|
module.from_dir(self.target_path, self.__files)
|
||||||
|
|
||||||
def finish(self) -> None:
|
def finish(self) -> None:
|
||||||
if self.bugreport_archive:
|
if self.__zip:
|
||||||
self.bugreport_archive.close()
|
self.__zip.close()
|
||||||
|
|||||||
@@ -4,15 +4,7 @@
|
|||||||
# https://license.mvt.re/1.1/
|
# https://license.mvt.re/1.1/
|
||||||
|
|
||||||
from .chrome_history import ChromeHistory
|
from .chrome_history import ChromeHistory
|
||||||
from .dumpsys_accessibility import DumpsysAccessibility
|
|
||||||
from .dumpsys_activities import DumpsysActivities
|
|
||||||
from .dumpsys_appops import DumpsysAppOps
|
|
||||||
from .dumpsys_battery_daily import DumpsysBatteryDaily
|
|
||||||
from .dumpsys_battery_history import DumpsysBatteryHistory
|
|
||||||
from .dumpsys_dbinfo import DumpsysDBInfo
|
|
||||||
from .dumpsys_adbstate import DumpsysADBState
|
|
||||||
from .dumpsys_full import DumpsysFull
|
from .dumpsys_full import DumpsysFull
|
||||||
from .dumpsys_receivers import DumpsysReceivers
|
|
||||||
from .files import Files
|
from .files import Files
|
||||||
from .getprop import Getprop
|
from .getprop import Getprop
|
||||||
from .logcat import Logcat
|
from .logcat import Logcat
|
||||||
@@ -32,15 +24,7 @@ ADB_MODULES = [
|
|||||||
Getprop,
|
Getprop,
|
||||||
Settings,
|
Settings,
|
||||||
SELinuxStatus,
|
SELinuxStatus,
|
||||||
DumpsysBatteryHistory,
|
|
||||||
DumpsysBatteryDaily,
|
|
||||||
DumpsysReceivers,
|
|
||||||
DumpsysActivities,
|
|
||||||
DumpsysAccessibility,
|
|
||||||
DumpsysDBInfo,
|
|
||||||
DumpsysADBState,
|
|
||||||
DumpsysFull,
|
DumpsysFull,
|
||||||
DumpsysAppOps,
|
|
||||||
Packages,
|
Packages,
|
||||||
Logcat,
|
Logcat,
|
||||||
RootBinaries,
|
RootBinaries,
|
||||||
|
|||||||
@@ -1,49 +0,0 @@
|
|||||||
# Mobile Verification Toolkit (MVT)
|
|
||||||
# Copyright (c) 2021-2023 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 logging
|
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
from mvt.android.artifacts.dumpsys_accessibility import DumpsysAccessibilityArtifact
|
|
||||||
|
|
||||||
from .base import AndroidExtraction
|
|
||||||
|
|
||||||
|
|
||||||
class DumpsysAccessibility(DumpsysAccessibilityArtifact, AndroidExtraction):
|
|
||||||
"""This module extracts stats on accessibility."""
|
|
||||||
|
|
||||||
def __init__(
|
|
||||||
self,
|
|
||||||
file_path: Optional[str] = None,
|
|
||||||
target_path: Optional[str] = None,
|
|
||||||
results_path: Optional[str] = None,
|
|
||||||
module_options: Optional[dict] = None,
|
|
||||||
log: logging.Logger = logging.getLogger(__name__),
|
|
||||||
results: Optional[list] = None,
|
|
||||||
) -> None:
|
|
||||||
super().__init__(
|
|
||||||
file_path=file_path,
|
|
||||||
target_path=target_path,
|
|
||||||
results_path=results_path,
|
|
||||||
module_options=module_options,
|
|
||||||
log=log,
|
|
||||||
results=results,
|
|
||||||
)
|
|
||||||
|
|
||||||
def run(self) -> None:
|
|
||||||
self._adb_connect()
|
|
||||||
output = self._adb_command("dumpsys accessibility")
|
|
||||||
self._adb_disconnect()
|
|
||||||
|
|
||||||
self.parse(output)
|
|
||||||
|
|
||||||
for result in self.results:
|
|
||||||
self.log.info(
|
|
||||||
'Found installed accessibility service "%s"', result.get("service")
|
|
||||||
)
|
|
||||||
|
|
||||||
self.log.info(
|
|
||||||
"Identified a total of %d accessibility services", len(self.results)
|
|
||||||
)
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
# Mobile Verification Toolkit (MVT)
|
|
||||||
# Copyright (c) 2021-2023 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 logging
|
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
from mvt.android.artifacts.dumpsys_package_activities import (
|
|
||||||
DumpsysPackageActivitiesArtifact,
|
|
||||||
)
|
|
||||||
|
|
||||||
from .base import AndroidExtraction
|
|
||||||
|
|
||||||
|
|
||||||
class DumpsysActivities(DumpsysPackageActivitiesArtifact, AndroidExtraction):
|
|
||||||
"""This module extracts details on receivers for risky activities."""
|
|
||||||
|
|
||||||
def __init__(
|
|
||||||
self,
|
|
||||||
file_path: Optional[str] = None,
|
|
||||||
target_path: Optional[str] = None,
|
|
||||||
results_path: Optional[str] = None,
|
|
||||||
module_options: Optional[dict] = None,
|
|
||||||
log: logging.Logger = logging.getLogger(__name__),
|
|
||||||
results: Optional[list] = None,
|
|
||||||
) -> None:
|
|
||||||
super().__init__(
|
|
||||||
file_path=file_path,
|
|
||||||
target_path=target_path,
|
|
||||||
results_path=results_path,
|
|
||||||
module_options=module_options,
|
|
||||||
log=log,
|
|
||||||
results=results,
|
|
||||||
)
|
|
||||||
|
|
||||||
self.results = results if results else []
|
|
||||||
|
|
||||||
def run(self) -> None:
|
|
||||||
self._adb_connect()
|
|
||||||
output = self._adb_command("dumpsys package")
|
|
||||||
self._adb_disconnect()
|
|
||||||
self.parse(output)
|
|
||||||
|
|
||||||
self.log.info("Extracted %d package activities", len(self.results))
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
# Mobile Verification Toolkit (MVT)
|
|
||||||
# Copyright (c) 2021-2023 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 logging
|
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
from mvt.android.artifacts.dumpsys_adb import DumpsysADBArtifact
|
|
||||||
|
|
||||||
from .base import AndroidExtraction
|
|
||||||
|
|
||||||
|
|
||||||
class DumpsysADBState(DumpsysADBArtifact, AndroidExtraction):
|
|
||||||
"""This module extracts ADB keystore state."""
|
|
||||||
|
|
||||||
def __init__(
|
|
||||||
self,
|
|
||||||
file_path: Optional[str] = None,
|
|
||||||
target_path: Optional[str] = None,
|
|
||||||
results_path: Optional[str] = None,
|
|
||||||
module_options: Optional[dict] = None,
|
|
||||||
log: logging.Logger = logging.getLogger(__name__),
|
|
||||||
results: Optional[list] = None,
|
|
||||||
) -> None:
|
|
||||||
super().__init__(
|
|
||||||
file_path=file_path,
|
|
||||||
target_path=target_path,
|
|
||||||
results_path=results_path,
|
|
||||||
module_options=module_options,
|
|
||||||
log=log,
|
|
||||||
results=results,
|
|
||||||
)
|
|
||||||
|
|
||||||
def run(self) -> None:
|
|
||||||
self._adb_connect()
|
|
||||||
output = self._adb_command("dumpsys adb", decode=False)
|
|
||||||
self._adb_disconnect()
|
|
||||||
|
|
||||||
self.parse(output)
|
|
||||||
if self.results:
|
|
||||||
self.log.info(
|
|
||||||
"Identified a total of %d trusted ADB keys",
|
|
||||||
len(self.results[0].get("user_keys", [])),
|
|
||||||
)
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
# Mobile Verification Toolkit (MVT)
|
|
||||||
# Copyright (c) 2021-2023 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 logging
|
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
from mvt.android.artifacts.dumpsys_appops import DumpsysAppopsArtifact
|
|
||||||
|
|
||||||
from .base import AndroidExtraction
|
|
||||||
|
|
||||||
|
|
||||||
class DumpsysAppOps(DumpsysAppopsArtifact, AndroidExtraction):
|
|
||||||
"""This module extracts records from App-op Manager."""
|
|
||||||
|
|
||||||
slug = "dumpsys_appops"
|
|
||||||
|
|
||||||
def __init__(
|
|
||||||
self,
|
|
||||||
file_path: Optional[str] = None,
|
|
||||||
target_path: Optional[str] = None,
|
|
||||||
results_path: Optional[str] = None,
|
|
||||||
module_options: Optional[dict] = None,
|
|
||||||
log: logging.Logger = logging.getLogger(__name__),
|
|
||||||
results: Optional[list] = None,
|
|
||||||
) -> None:
|
|
||||||
super().__init__(
|
|
||||||
file_path=file_path,
|
|
||||||
target_path=target_path,
|
|
||||||
results_path=results_path,
|
|
||||||
module_options=module_options,
|
|
||||||
log=log,
|
|
||||||
results=results,
|
|
||||||
)
|
|
||||||
|
|
||||||
def run(self) -> None:
|
|
||||||
self._adb_connect()
|
|
||||||
output = self._adb_command("dumpsys appops")
|
|
||||||
self._adb_disconnect()
|
|
||||||
|
|
||||||
self.parse(output)
|
|
||||||
|
|
||||||
self.log.info(
|
|
||||||
"Extracted a total of %d records from app-ops manager", len(self.results)
|
|
||||||
)
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
# Mobile Verification Toolkit (MVT)
|
|
||||||
# Copyright (c) 2021-2023 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 logging
|
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
from mvt.android.artifacts.dumpsys_battery_daily import DumpsysBatteryDailyArtifact
|
|
||||||
|
|
||||||
from .base import AndroidExtraction
|
|
||||||
|
|
||||||
|
|
||||||
class DumpsysBatteryDaily(DumpsysBatteryDailyArtifact, AndroidExtraction):
|
|
||||||
"""This module extracts records from battery daily updates."""
|
|
||||||
|
|
||||||
def __init__(
|
|
||||||
self,
|
|
||||||
file_path: Optional[str] = None,
|
|
||||||
target_path: Optional[str] = None,
|
|
||||||
results_path: Optional[str] = None,
|
|
||||||
module_options: Optional[dict] = None,
|
|
||||||
log: logging.Logger = logging.getLogger(__name__),
|
|
||||||
results: Optional[list] = None,
|
|
||||||
) -> None:
|
|
||||||
super().__init__(
|
|
||||||
file_path=file_path,
|
|
||||||
target_path=target_path,
|
|
||||||
results_path=results_path,
|
|
||||||
module_options=module_options,
|
|
||||||
log=log,
|
|
||||||
results=results,
|
|
||||||
)
|
|
||||||
|
|
||||||
def run(self) -> None:
|
|
||||||
self._adb_connect()
|
|
||||||
output = self._adb_command("dumpsys batterystats --daily")
|
|
||||||
self._adb_disconnect()
|
|
||||||
|
|
||||||
self.parse(output)
|
|
||||||
|
|
||||||
self.log.info(
|
|
||||||
"Extracted %d records from battery daily stats", len(self.results)
|
|
||||||
)
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
# Mobile Verification Toolkit (MVT)
|
|
||||||
# Copyright (c) 2021-2023 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 logging
|
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
from mvt.android.artifacts.dumpsys_battery_history import DumpsysBatteryHistoryArtifact
|
|
||||||
|
|
||||||
from .base import AndroidExtraction
|
|
||||||
|
|
||||||
|
|
||||||
class DumpsysBatteryHistory(DumpsysBatteryHistoryArtifact, AndroidExtraction):
|
|
||||||
"""This module extracts records from battery history events."""
|
|
||||||
|
|
||||||
def __init__(
|
|
||||||
self,
|
|
||||||
file_path: Optional[str] = None,
|
|
||||||
target_path: Optional[str] = None,
|
|
||||||
results_path: Optional[str] = None,
|
|
||||||
module_options: Optional[dict] = None,
|
|
||||||
log: logging.Logger = logging.getLogger(__name__),
|
|
||||||
results: Optional[list] = None,
|
|
||||||
) -> None:
|
|
||||||
super().__init__(
|
|
||||||
file_path=file_path,
|
|
||||||
target_path=target_path,
|
|
||||||
results_path=results_path,
|
|
||||||
module_options=module_options,
|
|
||||||
log=log,
|
|
||||||
results=results,
|
|
||||||
)
|
|
||||||
|
|
||||||
def run(self) -> None:
|
|
||||||
self._adb_connect()
|
|
||||||
output = self._adb_command("dumpsys batterystats --history")
|
|
||||||
self._adb_disconnect()
|
|
||||||
|
|
||||||
self.parse(output)
|
|
||||||
|
|
||||||
self.log.info("Extracted %d records from battery history", len(self.results))
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
# Mobile Verification Toolkit (MVT)
|
|
||||||
# Copyright (c) 2021-2023 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 logging
|
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
from mvt.android.artifacts.dumpsys_dbinfo import DumpsysDBInfoArtifact
|
|
||||||
|
|
||||||
from .base import AndroidExtraction
|
|
||||||
|
|
||||||
|
|
||||||
class DumpsysDBInfo(DumpsysDBInfoArtifact, AndroidExtraction):
|
|
||||||
"""This module extracts records from battery daily updates."""
|
|
||||||
|
|
||||||
slug = "dumpsys_dbinfo"
|
|
||||||
|
|
||||||
def __init__(
|
|
||||||
self,
|
|
||||||
file_path: Optional[str] = None,
|
|
||||||
target_path: Optional[str] = None,
|
|
||||||
results_path: Optional[str] = None,
|
|
||||||
module_options: Optional[dict] = None,
|
|
||||||
log: logging.Logger = logging.getLogger(__name__),
|
|
||||||
results: Optional[list] = None,
|
|
||||||
) -> None:
|
|
||||||
super().__init__(
|
|
||||||
file_path=file_path,
|
|
||||||
target_path=target_path,
|
|
||||||
results_path=results_path,
|
|
||||||
module_options=module_options,
|
|
||||||
log=log,
|
|
||||||
results=results,
|
|
||||||
)
|
|
||||||
|
|
||||||
def run(self) -> None:
|
|
||||||
self._adb_connect()
|
|
||||||
output = self._adb_command("dumpsys dbinfo")
|
|
||||||
self._adb_disconnect()
|
|
||||||
|
|
||||||
self.parse(output)
|
|
||||||
|
|
||||||
self.log.info(
|
|
||||||
"Extracted a total of %d records from database information",
|
|
||||||
len(self.results),
|
|
||||||
)
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
# Mobile Verification Toolkit (MVT)
|
|
||||||
# Copyright (c) 2021-2023 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 logging
|
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
from mvt.android.artifacts.dumpsys_receivers import DumpsysReceiversArtifact
|
|
||||||
|
|
||||||
from .base import AndroidExtraction
|
|
||||||
|
|
||||||
|
|
||||||
class DumpsysReceivers(DumpsysReceiversArtifact, AndroidExtraction):
|
|
||||||
"""This module extracts details on receivers for risky activities."""
|
|
||||||
|
|
||||||
def __init__(
|
|
||||||
self,
|
|
||||||
file_path: Optional[str] = None,
|
|
||||||
target_path: Optional[str] = None,
|
|
||||||
results_path: Optional[str] = None,
|
|
||||||
module_options: Optional[dict] = None,
|
|
||||||
log: logging.Logger = logging.getLogger(__name__),
|
|
||||||
results: Optional[list] = None,
|
|
||||||
) -> None:
|
|
||||||
super().__init__(
|
|
||||||
file_path=file_path,
|
|
||||||
target_path=target_path,
|
|
||||||
results_path=results_path,
|
|
||||||
module_options=module_options,
|
|
||||||
log=log,
|
|
||||||
results=results,
|
|
||||||
)
|
|
||||||
|
|
||||||
self.results = results if results else {}
|
|
||||||
|
|
||||||
def run(self) -> None:
|
|
||||||
self._adb_connect()
|
|
||||||
|
|
||||||
output = self._adb_command("dumpsys package")
|
|
||||||
self.parse(output)
|
|
||||||
|
|
||||||
self._adb_disconnect()
|
|
||||||
self.log.info("Extracted receivers for %d intents", len(self.results))
|
|
||||||
@@ -107,8 +107,7 @@ class Packages(AndroidExtraction):
|
|||||||
result["matched_indicator"] = ioc
|
result["matched_indicator"] = ioc
|
||||||
self.detected.append(result)
|
self.detected.append(result)
|
||||||
|
|
||||||
@staticmethod
|
def check_virustotal(self, packages: list) -> None:
|
||||||
def check_virustotal(packages: list) -> None:
|
|
||||||
hashes = []
|
hashes = []
|
||||||
for package in packages:
|
for package in packages:
|
||||||
for file in package.get("files", []):
|
for file in package.get("files", []):
|
||||||
@@ -143,8 +142,15 @@ class Packages(AndroidExtraction):
|
|||||||
|
|
||||||
for package in packages:
|
for package in packages:
|
||||||
for file in package.get("files", []):
|
for file in package.get("files", []):
|
||||||
row = [package["package_name"], file["path"]]
|
if "package_name" in package:
|
||||||
|
row = [package["package_name"], file["path"]]
|
||||||
|
elif "name" in package:
|
||||||
|
row = [package["name"], file["path"]]
|
||||||
|
else:
|
||||||
|
self.log.error(
|
||||||
|
f"Package {package} has no name or package_name. packages.json or apks.json is malformed"
|
||||||
|
)
|
||||||
|
continue
|
||||||
if file["sha256"] in detections:
|
if file["sha256"] in detections:
|
||||||
detection = detections[file["sha256"]]
|
detection = detections[file["sha256"]]
|
||||||
positives = detection.split("/")[0]
|
positives = detection.split("/")[0]
|
||||||
|
|||||||
@@ -3,38 +3,18 @@
|
|||||||
# Use of this software is governed by the MVT License 1.1 that can be found at
|
# Use of this software is governed by the MVT License 1.1 that can be found at
|
||||||
# https://license.mvt.re/1.1/
|
# https://license.mvt.re/1.1/
|
||||||
|
|
||||||
from .dumpsys_accessibility import DumpsysAccessibility
|
from .aqf_getprop import AQFGetProp
|
||||||
from .dumpsys_activities import DumpsysActivities
|
from .aqf_packages import AQFPackages
|
||||||
from .dumpsys_appops import DumpsysAppops
|
from .aqf_processes import AQFProcesses
|
||||||
from .dumpsys_battery_daily import DumpsysBatteryDaily
|
from .aqf_settings import AQFSettings
|
||||||
from .dumpsys_battery_history import DumpsysBatteryHistory
|
from .aqf_files import AQFFiles
|
||||||
from .dumpsys_dbinfo import DumpsysDBInfo
|
|
||||||
from .dumpsys_packages import DumpsysPackages
|
|
||||||
from .dumpsys_receivers import DumpsysReceivers
|
|
||||||
from .dumpsys_adb import DumpsysADBState
|
|
||||||
from .getprop import Getprop
|
|
||||||
from .packages import Packages
|
|
||||||
from .dumpsys_platform_compat import DumpsysPlatformCompat
|
|
||||||
from .processes import Processes
|
|
||||||
from .settings import Settings
|
|
||||||
from .sms import SMS
|
from .sms import SMS
|
||||||
from .files import Files
|
|
||||||
|
|
||||||
ANDROIDQF_MODULES = [
|
ANDROIDQF_MODULES = [
|
||||||
DumpsysActivities,
|
AQFPackages,
|
||||||
DumpsysReceivers,
|
AQFProcesses,
|
||||||
DumpsysAccessibility,
|
AQFGetProp,
|
||||||
DumpsysAppops,
|
AQFSettings,
|
||||||
DumpsysDBInfo,
|
AQFFiles,
|
||||||
DumpsysBatteryDaily,
|
|
||||||
DumpsysBatteryHistory,
|
|
||||||
DumpsysADBState,
|
|
||||||
Packages,
|
|
||||||
DumpsysPlatformCompat,
|
|
||||||
Processes,
|
|
||||||
Getprop,
|
|
||||||
Settings,
|
|
||||||
SMS,
|
SMS,
|
||||||
DumpsysPackages,
|
|
||||||
Files,
|
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -21,8 +21,13 @@ SUSPICIOUS_PATHS = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class Files(AndroidQFModule):
|
class AQFFiles(AndroidQFModule):
|
||||||
"""This module analyse list of files"""
|
"""
|
||||||
|
This module analyzes the files.json dump generated by AndroidQF.
|
||||||
|
|
||||||
|
The format needs to be kept in sync with the AndroidQF module code.
|
||||||
|
https://github.com/mvt-project/androidqf/blob/main/android-collector/cmd/find.go#L28
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@@ -112,18 +117,10 @@ class Files(AndroidQFModule):
|
|||||||
|
|
||||||
def run(self) -> None:
|
def run(self) -> None:
|
||||||
if timezone := self._get_device_timezone():
|
if timezone := self._get_device_timezone():
|
||||||
try:
|
device_timezone = zoneinfo.ZoneInfo(timezone)
|
||||||
device_timezone = zoneinfo.ZoneInfo(timezone)
|
|
||||||
except zoneinfo.ZoneInfoNotFoundError:
|
|
||||||
self.log.warning("Device timezone '%s' not found, using UTC", timezone)
|
|
||||||
device_timezone = datetime.timezone.utc
|
|
||||||
else:
|
else:
|
||||||
self.log.warning("Unable to determine device timezone, using UTC")
|
self.log.warning("Unable to determine device timezone, using UTC")
|
||||||
try:
|
device_timezone = zoneinfo.ZoneInfo("UTC")
|
||||||
device_timezone = zoneinfo.ZoneInfo("UTC")
|
|
||||||
except zoneinfo.ZoneInfoNotFoundError:
|
|
||||||
# Fallback for Windows systems where zoneinfo might not have UTC
|
|
||||||
device_timezone = datetime.timezone.utc
|
|
||||||
|
|
||||||
for file in self._get_files_by_pattern("*/files.json"):
|
for file in self._get_files_by_pattern("*/files.json"):
|
||||||
rawdata = self._get_file_content(file).decode("utf-8", errors="ignore")
|
rawdata = self._get_file_content(file).decode("utf-8", errors="ignore")
|
||||||
@@ -11,7 +11,7 @@ from mvt.android.artifacts.getprop import GetProp as GetPropArtifact
|
|||||||
from .base import AndroidQFModule
|
from .base import AndroidQFModule
|
||||||
|
|
||||||
|
|
||||||
class Getprop(GetPropArtifact, AndroidQFModule):
|
class AQFGetProp(GetPropArtifact, AndroidQFModule):
|
||||||
"""This module extracts data from get properties."""
|
"""This module extracts data from get properties."""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
@@ -13,10 +13,10 @@ from .base import AndroidQFModule
|
|||||||
from mvt.android.artifacts.file_timestamps import FileTimestampsArtifact
|
from mvt.android.artifacts.file_timestamps import FileTimestampsArtifact
|
||||||
|
|
||||||
|
|
||||||
class LogsFileTimestamps(FileTimestampsArtifact, AndroidQFModule):
|
class AQFLogTimestamps(FileTimestampsArtifact, AndroidQFModule):
|
||||||
"""This module extracts records from battery daily updates."""
|
"""This module creates timeline for log files extracted by AQF."""
|
||||||
|
|
||||||
slug = "logfile_timestamps"
|
slug = "aqf_log_timestamps"
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@@ -19,7 +19,7 @@ from mvt.android.utils import (
|
|||||||
from .base import AndroidQFModule
|
from .base import AndroidQFModule
|
||||||
|
|
||||||
|
|
||||||
class Packages(AndroidQFModule):
|
class AQFPackages(AndroidQFModule):
|
||||||
"""This module examines the installed packages in packages.json"""
|
"""This module examines the installed packages in packages.json"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
@@ -11,7 +11,7 @@ from mvt.android.artifacts.processes import Processes as ProcessesArtifact
|
|||||||
from .base import AndroidQFModule
|
from .base import AndroidQFModule
|
||||||
|
|
||||||
|
|
||||||
class Processes(ProcessesArtifact, AndroidQFModule):
|
class AQFProcesses(ProcessesArtifact, AndroidQFModule):
|
||||||
"""This module analyse running processes"""
|
"""This module analyse running processes"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
@@ -11,7 +11,7 @@ from mvt.android.artifacts.settings import Settings as SettingsArtifact
|
|||||||
from .base import AndroidQFModule
|
from .base import AndroidQFModule
|
||||||
|
|
||||||
|
|
||||||
class Settings(SettingsArtifact, AndroidQFModule):
|
class AQFSettings(SettingsArtifact, AndroidQFModule):
|
||||||
"""This module analyse setting files"""
|
"""This module analyse setting files"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
@@ -37,11 +37,11 @@ class AndroidQFModule(MVTModule):
|
|||||||
self.files: List[str] = []
|
self.files: List[str] = []
|
||||||
self.archive: Optional[zipfile.ZipFile] = None
|
self.archive: Optional[zipfile.ZipFile] = None
|
||||||
|
|
||||||
def from_folder(self, parent_path: str, files: List[str]):
|
def from_dir(self, parent_path: str, files: List[str]) -> None:
|
||||||
self.parent_path = parent_path
|
self.parent_path = parent_path
|
||||||
self.files = files
|
self.files = files
|
||||||
|
|
||||||
def from_zip_file(self, archive: zipfile.ZipFile, files: List[str]):
|
def from_zip(self, archive: zipfile.ZipFile, files: List[str]) -> None:
|
||||||
self.archive = archive
|
self.archive = archive
|
||||||
self.files = files
|
self.files = files
|
||||||
|
|
||||||
|
|||||||
@@ -1,51 +0,0 @@
|
|||||||
# Mobile Verification Toolkit (MVT)
|
|
||||||
# Copyright (c) 2021-2023 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 logging
|
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
from mvt.android.artifacts.dumpsys_accessibility import DumpsysAccessibilityArtifact
|
|
||||||
|
|
||||||
from .base import AndroidQFModule
|
|
||||||
|
|
||||||
|
|
||||||
class DumpsysAccessibility(DumpsysAccessibilityArtifact, AndroidQFModule):
|
|
||||||
"""This module analyses dumpsys accessibility"""
|
|
||||||
|
|
||||||
def __init__(
|
|
||||||
self,
|
|
||||||
file_path: Optional[str] = None,
|
|
||||||
target_path: Optional[str] = None,
|
|
||||||
results_path: Optional[str] = None,
|
|
||||||
module_options: Optional[dict] = None,
|
|
||||||
log: logging.Logger = logging.getLogger(__name__),
|
|
||||||
results: Optional[list] = None,
|
|
||||||
) -> None:
|
|
||||||
super().__init__(
|
|
||||||
file_path=file_path,
|
|
||||||
target_path=target_path,
|
|
||||||
results_path=results_path,
|
|
||||||
module_options=module_options,
|
|
||||||
log=log,
|
|
||||||
results=results,
|
|
||||||
)
|
|
||||||
|
|
||||||
def run(self) -> None:
|
|
||||||
dumpsys_file = self._get_files_by_pattern("*/dumpsys.txt")
|
|
||||||
if not dumpsys_file:
|
|
||||||
return
|
|
||||||
|
|
||||||
data = self._get_file_content(dumpsys_file[0]).decode("utf-8", errors="replace")
|
|
||||||
content = self.extract_dumpsys_section(data, "DUMP OF SERVICE accessibility:")
|
|
||||||
self.parse(content)
|
|
||||||
|
|
||||||
for result in self.results:
|
|
||||||
self.log.info(
|
|
||||||
'Found installed accessibility service "%s"', result.get("service")
|
|
||||||
)
|
|
||||||
|
|
||||||
self.log.info(
|
|
||||||
"Identified a total of %d accessibility services", len(self.results)
|
|
||||||
)
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
# Mobile Verification Toolkit (MVT)
|
|
||||||
# Copyright (c) 2021-2023 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 logging
|
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
from mvt.android.artifacts.dumpsys_package_activities import (
|
|
||||||
DumpsysPackageActivitiesArtifact,
|
|
||||||
)
|
|
||||||
|
|
||||||
from .base import AndroidQFModule
|
|
||||||
|
|
||||||
|
|
||||||
class DumpsysActivities(DumpsysPackageActivitiesArtifact, AndroidQFModule):
|
|
||||||
"""This module extracts details on receivers for risky activities."""
|
|
||||||
|
|
||||||
def __init__(
|
|
||||||
self,
|
|
||||||
file_path: Optional[str] = None,
|
|
||||||
target_path: Optional[str] = None,
|
|
||||||
results_path: Optional[str] = None,
|
|
||||||
module_options: Optional[dict] = None,
|
|
||||||
log: logging.Logger = logging.getLogger(__name__),
|
|
||||||
results: Optional[list] = None,
|
|
||||||
) -> None:
|
|
||||||
super().__init__(
|
|
||||||
file_path=file_path,
|
|
||||||
target_path=target_path,
|
|
||||||
results_path=results_path,
|
|
||||||
module_options=module_options,
|
|
||||||
log=log,
|
|
||||||
results=results,
|
|
||||||
)
|
|
||||||
|
|
||||||
self.results = results if results else []
|
|
||||||
|
|
||||||
def run(self) -> None:
|
|
||||||
dumpsys_file = self._get_files_by_pattern("*/dumpsys.txt")
|
|
||||||
if not dumpsys_file:
|
|
||||||
return
|
|
||||||
|
|
||||||
# Get data and extract the dumpsys section
|
|
||||||
data = self._get_file_content(dumpsys_file[0]).decode("utf-8", errors="replace")
|
|
||||||
content = self.extract_dumpsys_section(data, "DUMP OF SERVICE package:")
|
|
||||||
# Parse it
|
|
||||||
self.parse(content)
|
|
||||||
|
|
||||||
self.log.info("Extracted %d package activities", len(self.results))
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
# Mobile Verification Toolkit (MVT)
|
|
||||||
# Copyright (c) 2021-2023 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 logging
|
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
from mvt.android.artifacts.dumpsys_adb import DumpsysADBArtifact
|
|
||||||
|
|
||||||
from .base import AndroidQFModule
|
|
||||||
|
|
||||||
|
|
||||||
class DumpsysADBState(DumpsysADBArtifact, AndroidQFModule):
|
|
||||||
"""This module extracts ADB keystore state."""
|
|
||||||
|
|
||||||
def __init__(
|
|
||||||
self,
|
|
||||||
file_path: Optional[str] = None,
|
|
||||||
target_path: Optional[str] = None,
|
|
||||||
results_path: Optional[str] = None,
|
|
||||||
module_options: Optional[dict] = None,
|
|
||||||
log: logging.Logger = logging.getLogger(__name__),
|
|
||||||
results: Optional[list] = None,
|
|
||||||
) -> None:
|
|
||||||
super().__init__(
|
|
||||||
file_path=file_path,
|
|
||||||
target_path=target_path,
|
|
||||||
results_path=results_path,
|
|
||||||
module_options=module_options,
|
|
||||||
log=log,
|
|
||||||
results=results,
|
|
||||||
)
|
|
||||||
|
|
||||||
def run(self) -> None:
|
|
||||||
dumpsys_file = self._get_files_by_pattern("*/dumpsys.txt")
|
|
||||||
if not dumpsys_file:
|
|
||||||
return
|
|
||||||
|
|
||||||
full_dumpsys = self._get_file_content(dumpsys_file[0])
|
|
||||||
content = self.extract_dumpsys_section(
|
|
||||||
full_dumpsys,
|
|
||||||
b"DUMP OF SERVICE adb:",
|
|
||||||
binary=True,
|
|
||||||
)
|
|
||||||
self.parse(content)
|
|
||||||
if self.results:
|
|
||||||
self.log.info(
|
|
||||||
"Identified a total of %d trusted ADB keys",
|
|
||||||
len(self.results[0].get("user_keys", [])),
|
|
||||||
)
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
# Mobile Verification Toolkit (MVT)
|
|
||||||
# Copyright (c) 2021-2023 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 logging
|
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
from mvt.android.artifacts.dumpsys_appops import DumpsysAppopsArtifact
|
|
||||||
|
|
||||||
from .base import AndroidQFModule
|
|
||||||
|
|
||||||
|
|
||||||
class DumpsysAppops(DumpsysAppopsArtifact, AndroidQFModule):
|
|
||||||
def __init__(
|
|
||||||
self,
|
|
||||||
file_path: Optional[str] = None,
|
|
||||||
target_path: Optional[str] = None,
|
|
||||||
results_path: Optional[str] = None,
|
|
||||||
module_options: Optional[dict] = None,
|
|
||||||
log: logging.Logger = logging.getLogger(__name__),
|
|
||||||
results: Optional[list] = None,
|
|
||||||
) -> None:
|
|
||||||
super().__init__(
|
|
||||||
file_path=file_path,
|
|
||||||
target_path=target_path,
|
|
||||||
results_path=results_path,
|
|
||||||
module_options=module_options,
|
|
||||||
log=log,
|
|
||||||
results=results,
|
|
||||||
)
|
|
||||||
|
|
||||||
def run(self) -> None:
|
|
||||||
dumpsys_file = self._get_files_by_pattern("*/dumpsys.txt")
|
|
||||||
if not dumpsys_file:
|
|
||||||
return
|
|
||||||
|
|
||||||
# Extract section
|
|
||||||
data = self._get_file_content(dumpsys_file[0])
|
|
||||||
section = self.extract_dumpsys_section(
|
|
||||||
data.decode("utf-8", errors="replace"), "DUMP OF SERVICE appops:"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Parse it
|
|
||||||
self.parse(section)
|
|
||||||
self.log.info("Identified %d applications in AppOps Manager", len(self.results))
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
# Mobile Verification Toolkit (MVT)
|
|
||||||
# Copyright (c) 2021-2023 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 logging
|
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
from mvt.android.artifacts.dumpsys_battery_daily import DumpsysBatteryDailyArtifact
|
|
||||||
|
|
||||||
from .base import AndroidQFModule
|
|
||||||
|
|
||||||
|
|
||||||
class DumpsysBatteryDaily(DumpsysBatteryDailyArtifact, AndroidQFModule):
|
|
||||||
def __init__(
|
|
||||||
self,
|
|
||||||
file_path: Optional[str] = None,
|
|
||||||
target_path: Optional[str] = None,
|
|
||||||
results_path: Optional[str] = None,
|
|
||||||
module_options: Optional[dict] = None,
|
|
||||||
log: logging.Logger = logging.getLogger(__name__),
|
|
||||||
results: Optional[list] = None,
|
|
||||||
) -> None:
|
|
||||||
super().__init__(
|
|
||||||
file_path=file_path,
|
|
||||||
target_path=target_path,
|
|
||||||
results_path=results_path,
|
|
||||||
module_options=module_options,
|
|
||||||
log=log,
|
|
||||||
results=results,
|
|
||||||
)
|
|
||||||
|
|
||||||
def run(self) -> None:
|
|
||||||
dumpsys_file = self._get_files_by_pattern("*/dumpsys.txt")
|
|
||||||
if not dumpsys_file:
|
|
||||||
return
|
|
||||||
|
|
||||||
# Extract section
|
|
||||||
data = self._get_file_content(dumpsys_file[0])
|
|
||||||
section = self.extract_dumpsys_section(
|
|
||||||
data.decode("utf-8", errors="replace"), "DUMP OF SERVICE batterystats:"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Parse it
|
|
||||||
self.parse(section)
|
|
||||||
self.log.info("Extracted a total of %d battery daily stats", len(self.results))
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user