mirror of
https://github.com/mvt-project/mvt.git
synced 2026-07-06 04:57:52 +02:00
Refactors dumpsys receiver parsing into an artifact
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
# Mobile Verification Toolkit (MVT)
|
||||
# Copyright (c) 2021-2023 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/
|
||||
import logging
|
||||
|
||||
from mvt.android.artifacts.dumpsys_receivers import DumpsysReceiversArtifact
|
||||
from mvt.common.indicators import Indicators
|
||||
|
||||
from ..utils import get_artifact
|
||||
|
||||
|
||||
class TestDumpsysReceiversArtifact:
|
||||
def test_parsing(self):
|
||||
dr = DumpsysReceiversArtifact()
|
||||
file = get_artifact("android_data/dumpsys_packages.txt")
|
||||
with open(file) as f:
|
||||
data = f.read()
|
||||
|
||||
assert len(dr.results) == 0
|
||||
dr.parse(data)
|
||||
assert len(dr.results) == 4
|
||||
assert (
|
||||
list(dr.results.keys())[0]
|
||||
== "com.android.storagemanager.automatic.SHOW_NOTIFICATION"
|
||||
)
|
||||
assert (
|
||||
dr.results["com.android.storagemanager.automatic.SHOW_NOTIFICATION"][0][
|
||||
"package_name"
|
||||
]
|
||||
== "com.android.storagemanager"
|
||||
)
|
||||
|
||||
def test_ioc_check(self, indicator_file):
|
||||
dr = DumpsysReceiversArtifact()
|
||||
file = get_artifact("android_data/dumpsys_packages.txt")
|
||||
with open(file) as f:
|
||||
data = f.read()
|
||||
dr.parse(data)
|
||||
|
||||
ind = Indicators(log=logging.getLogger())
|
||||
ind.parse_stix2(indicator_file)
|
||||
ind.ioc_collections[0]["app_ids"].append("com.android.storagemanager")
|
||||
dr.indicators = ind
|
||||
assert len(dr.detected) == 0
|
||||
dr.check_indicators()
|
||||
assert len(dr.detected) == 1
|
||||
@@ -1,25 +0,0 @@
|
||||
# Mobile Verification Toolkit (MVT)
|
||||
# Copyright (c) 2021-2023 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.android.parsers.dumpsys import parse_dumpsys_packages
|
||||
|
||||
from ..utils import get_artifact
|
||||
|
||||
|
||||
class TestDumpsysParsing:
|
||||
def test_packages_parsing(self):
|
||||
file = get_artifact("android_data/dumpsys_packages.txt")
|
||||
with open(file) as f:
|
||||
data = f.read()
|
||||
|
||||
res = parse_dumpsys_packages(data)
|
||||
|
||||
assert len(res) == 2
|
||||
assert res[0]["package_name"] == "com.samsung.android.provider.filterprovider"
|
||||
assert res[1]["package_name"] == "com.sec.android.app.DataCreate"
|
||||
assert len(res[0]["permissions"]) == 4
|
||||
assert len(res[0]["requested_permissions"]) == 0
|
||||
assert len(res[1]["permissions"]) == 34
|
||||
assert len(res[1]["requested_permissions"]) == 11
|
||||
Reference in New Issue
Block a user