mirror of
https://github.com/mvt-project/mvt.git
synced 2024-06-17 18:14:07 +00:00
Added getprop bugreport module
This commit is contained in:
parent
189b1d7fc6
commit
a833dda581
|
@ -35,7 +35,7 @@ class DumpsysAccessibility(AndroidExtraction):
|
||||||
results = []
|
results = []
|
||||||
|
|
||||||
in_services = False
|
in_services = False
|
||||||
for line in output.split("\n"):
|
for line in output.splitlines():
|
||||||
if line.strip().startswith("installed services:"):
|
if line.strip().startswith("installed services:"):
|
||||||
in_services = True
|
in_services = True
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -40,7 +40,7 @@ class DumpsysActivities(AndroidExtraction):
|
||||||
in_activity_resolver_table = False
|
in_activity_resolver_table = False
|
||||||
in_non_data_actions = False
|
in_non_data_actions = False
|
||||||
intent = None
|
intent = None
|
||||||
for line in output.split("\n"):
|
for line in output.splitlines():
|
||||||
if line.startswith("Activity Resolver Table:"):
|
if line.startswith("Activity Resolver Table:"):
|
||||||
in_activity_resolver_table = True
|
in_activity_resolver_table = True
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -43,7 +43,7 @@ class DumpsysBatteryDaily(AndroidExtraction):
|
||||||
results = []
|
results = []
|
||||||
daily = None
|
daily = None
|
||||||
daily_updates = []
|
daily_updates = []
|
||||||
for line in output.split("\n")[1:]:
|
for line in output.splitlines()[1:]:
|
||||||
if line.startswith(" Daily from "):
|
if line.startswith(" Daily from "):
|
||||||
if len(daily_updates) > 0:
|
if len(daily_updates) > 0:
|
||||||
results.extend(daily_updates)
|
results.extend(daily_updates)
|
||||||
|
|
|
@ -34,7 +34,7 @@ class DumpsysBatteryHistory(AndroidExtraction):
|
||||||
def parse_battery_history(output):
|
def parse_battery_history(output):
|
||||||
results = []
|
results = []
|
||||||
|
|
||||||
for line in output.split("\n")[1:]:
|
for line in output.splitlines()[1:]:
|
||||||
if line.strip() == "":
|
if line.strip() == "":
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ class DumpsysDBInfo(AndroidExtraction):
|
||||||
rxp = re.compile(r'.*\[([0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3})\].*\[Pid:\((\d+)\)\](\w+).*sql\=\"(.+?)\".*path\=(.*?$)')
|
rxp = re.compile(r'.*\[([0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3})\].*\[Pid:\((\d+)\)\](\w+).*sql\=\"(.+?)\".*path\=(.*?$)')
|
||||||
|
|
||||||
in_operations = False
|
in_operations = False
|
||||||
for line in output.split("\n"):
|
for line in output.splitlines():
|
||||||
if line.strip() == "Most recently executed operations:":
|
if line.strip() == "Most recently executed operations:":
|
||||||
in_operations = True
|
in_operations = True
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -62,7 +62,7 @@ class DumpsysReceivers(AndroidExtraction):
|
||||||
in_receiver_resolver_table = False
|
in_receiver_resolver_table = False
|
||||||
in_non_data_actions = False
|
in_non_data_actions = False
|
||||||
intent = None
|
intent = None
|
||||||
for line in output.split("\n"):
|
for line in output.splitlines():
|
||||||
if line.startswith("Receiver Resolver Table:"):
|
if line.startswith("Receiver Resolver Table:"):
|
||||||
in_receiver_resolver_table = True
|
in_receiver_resolver_table = True
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -22,12 +22,12 @@ class Getprop(AndroidExtraction):
|
||||||
|
|
||||||
self.results = {} if not results else results
|
self.results = {} if not results else results
|
||||||
|
|
||||||
def run(self):
|
@staticmethod
|
||||||
self._adb_connect()
|
def parse_getprop(output):
|
||||||
|
results = {}
|
||||||
rxp = re.compile(r"\[(.+?)\]: \[(.+?)\]")
|
rxp = re.compile(r"\[(.+?)\]: \[(.+?)\]")
|
||||||
out = self._adb_command("getprop")
|
|
||||||
for line in out.splitlines():
|
for line in output.splitlines():
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
if line == "":
|
if line == "":
|
||||||
continue
|
continue
|
||||||
|
@ -38,8 +38,15 @@ class Getprop(AndroidExtraction):
|
||||||
|
|
||||||
key = matches[0][0]
|
key = matches[0][0]
|
||||||
value = matches[0][1]
|
value = matches[0][1]
|
||||||
self.results[key] = value
|
results[key] = value
|
||||||
|
|
||||||
|
return results
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
self._adb_connect()
|
||||||
|
output = self._adb_command("getprop")
|
||||||
self._adb_disconnect()
|
self._adb_disconnect()
|
||||||
|
|
||||||
|
self.results = self.parse_getprop(output)
|
||||||
|
|
||||||
self.log.info("Extracted %d Android system properties", len(self.results))
|
self.log.info("Extracted %d Android system properties", len(self.results))
|
||||||
|
|
|
@ -71,7 +71,7 @@ class Packages(AndroidExtraction):
|
||||||
def check_indicators(self):
|
def check_indicators(self):
|
||||||
root_packages_path = os.path.join("..", "..", "data", "root_packages.txt")
|
root_packages_path = os.path.join("..", "..", "data", "root_packages.txt")
|
||||||
root_packages_string = pkg_resources.resource_string(__name__, root_packages_path)
|
root_packages_string = pkg_resources.resource_string(__name__, root_packages_path)
|
||||||
root_packages = root_packages_string.decode("utf-8").split("\n")
|
root_packages = root_packages_string.decode("utf-8").splitlines()
|
||||||
root_packages = [rp.strip() for rp in root_packages]
|
root_packages = [rp.strip() for rp in root_packages]
|
||||||
|
|
||||||
for result in self.results:
|
for result in self.results:
|
||||||
|
@ -109,7 +109,7 @@ class Packages(AndroidExtraction):
|
||||||
}
|
}
|
||||||
|
|
||||||
in_permissions = False
|
in_permissions = False
|
||||||
for line in output.split("\n"):
|
for line in output.splitlines():
|
||||||
if in_permissions:
|
if in_permissions:
|
||||||
if line.startswith(" " * 4) and not line.startswith(" " * 6):
|
if line.startswith(" " * 4) and not line.startswith(" " * 6):
|
||||||
in_permissions = False
|
in_permissions = False
|
||||||
|
@ -143,7 +143,7 @@ class Packages(AndroidExtraction):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
package_files = []
|
package_files = []
|
||||||
for file_path in output.split("\n"):
|
for file_path in output.splitlines():
|
||||||
file_path = file_path.strip()
|
file_path = file_path.strip()
|
||||||
|
|
||||||
md5 = self._adb_command(f"md5sum {file_path}").split(" ")[0]
|
md5 = self._adb_command(f"md5sum {file_path}").split(" ")[0]
|
||||||
|
@ -166,7 +166,7 @@ class Packages(AndroidExtraction):
|
||||||
|
|
||||||
packages = self._adb_command("pm list packages -u -i -f")
|
packages = self._adb_command("pm list packages -u -i -f")
|
||||||
|
|
||||||
for line in packages.split("\n"):
|
for line in packages.splitlines():
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
if not line.startswith("package:"):
|
if not line.startswith("package:"):
|
||||||
continue
|
continue
|
||||||
|
@ -206,7 +206,7 @@ class Packages(AndroidExtraction):
|
||||||
]
|
]
|
||||||
for cmd in cmds:
|
for cmd in cmds:
|
||||||
output = self._adb_command(f"pm list packages {cmd['arg']}")
|
output = self._adb_command(f"pm list packages {cmd['arg']}")
|
||||||
for line in output.split("\n"):
|
for line in output.splitlines():
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
if not line.startswith("package:"):
|
if not line.startswith("package:"):
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -24,7 +24,7 @@ class Processes(AndroidExtraction):
|
||||||
|
|
||||||
output = self._adb_command("ps -e")
|
output = self._adb_command("ps -e")
|
||||||
|
|
||||||
for line in output.split("\n")[1:]:
|
for line in output.splitlines()[1:]:
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
if line == "":
|
if line == "":
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -25,7 +25,7 @@ class RootBinaries(AndroidExtraction):
|
||||||
def run(self):
|
def run(self):
|
||||||
root_binaries_path = os.path.join("..", "..", "data", "root_binaries.txt")
|
root_binaries_path = os.path.join("..", "..", "data", "root_binaries.txt")
|
||||||
root_binaries_string = pkg_resources.resource_string(__name__, root_binaries_path)
|
root_binaries_string = pkg_resources.resource_string(__name__, root_binaries_path)
|
||||||
root_binaries = root_binaries_string.decode("utf-8").split("\n")
|
root_binaries = root_binaries_string.decode("utf-8").splitlines()
|
||||||
|
|
||||||
self._adb_connect()
|
self._adb_connect()
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,9 @@ from .activities import Activities
|
||||||
from .battery_daily import BatteryDaily
|
from .battery_daily import BatteryDaily
|
||||||
from .battery_history import BatteryHistory
|
from .battery_history import BatteryHistory
|
||||||
from .dbinfo import DBInfo
|
from .dbinfo import DBInfo
|
||||||
|
from .getprop import Getprop
|
||||||
from .packages import Packages
|
from .packages import Packages
|
||||||
from .receivers import Receivers
|
from .receivers import Receivers
|
||||||
|
|
||||||
BUGREPORT_MODULES = [Accessibility, Activities, BatteryDaily, BatteryHistory,
|
BUGREPORT_MODULES = [Accessibility, Activities, BatteryDaily, BatteryHistory,
|
||||||
DBInfo, Packages, Receivers]
|
DBInfo, Getprop, Packages, Receivers]
|
||||||
|
|
|
@ -43,7 +43,7 @@ class Accessibility(BugReportModule):
|
||||||
|
|
||||||
lines = []
|
lines = []
|
||||||
in_accessibility = False
|
in_accessibility = False
|
||||||
for line in content.decode().split("\n"):
|
for line in content.decode().splitlines():
|
||||||
if line.strip() == "DUMP OF SERVICE accessibility:":
|
if line.strip() == "DUMP OF SERVICE accessibility:":
|
||||||
in_accessibility = True
|
in_accessibility = True
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -46,7 +46,7 @@ class Activities(BugReportModule):
|
||||||
|
|
||||||
lines = []
|
lines = []
|
||||||
in_package = False
|
in_package = False
|
||||||
for line in content.decode().split("\n"):
|
for line in content.decode().splitlines():
|
||||||
if line.strip() == "DUMP OF SERVICE package:":
|
if line.strip() == "DUMP OF SERVICE package:":
|
||||||
in_package = True
|
in_package = True
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -52,7 +52,7 @@ class BatteryDaily(BugReportModule):
|
||||||
lines = []
|
lines = []
|
||||||
in_batterystats = False
|
in_batterystats = False
|
||||||
in_daily = False
|
in_daily = False
|
||||||
for line in content.decode().split("\n"):
|
for line in content.decode().splitlines():
|
||||||
if line.strip() == "DUMP OF SERVICE batterystats:":
|
if line.strip() == "DUMP OF SERVICE batterystats:":
|
||||||
in_batterystats = True
|
in_batterystats = True
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -45,7 +45,7 @@ class BatteryHistory(BugReportModule):
|
||||||
lines = []
|
lines = []
|
||||||
in_batterystats = False
|
in_batterystats = False
|
||||||
in_history = False
|
in_history = False
|
||||||
for line in content.decode().split("\n"):
|
for line in content.decode().splitlines():
|
||||||
if line.strip() == "********** Print latest newbatterystats **********":
|
if line.strip() == "********** Print latest newbatterystats **********":
|
||||||
in_batterystats = True
|
in_batterystats = True
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -47,7 +47,7 @@ class DBInfo(BugReportModule):
|
||||||
|
|
||||||
in_dbinfo = False
|
in_dbinfo = False
|
||||||
lines = []
|
lines = []
|
||||||
for line in content.decode().split("\n"):
|
for line in content.decode().splitlines():
|
||||||
if line.strip() == "DUMP OF SERVICE dbinfo:":
|
if line.strip() == "DUMP OF SERVICE dbinfo:":
|
||||||
in_dbinfo = True
|
in_dbinfo = True
|
||||||
continue
|
continue
|
||||||
|
|
53
mvt/android/modules/bugreport/getprop.py
Normal file
53
mvt/android/modules/bugreport/getprop.py
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
# Mobile Verification Toolkit (MVT)
|
||||||
|
# Copyright (c) 2021-2022 The MVT Project 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
|
||||||
|
import re
|
||||||
|
|
||||||
|
from .base import BugReportModule
|
||||||
|
from mvt.android.modules.adb.getprop import Getprop as GP
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class Getprop(BugReportModule):
|
||||||
|
"""This module extracts device properties from getprop command."""
|
||||||
|
|
||||||
|
def __init__(self, file_path=None, base_folder=None, output_folder=None,
|
||||||
|
serial=None, fast_mode=False, log=None, results=[]):
|
||||||
|
super().__init__(file_path=file_path, base_folder=base_folder,
|
||||||
|
output_folder=output_folder, fast_mode=fast_mode,
|
||||||
|
log=log, results=results)
|
||||||
|
|
||||||
|
self.results = {} if not results else results
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
dumpstate_files = self._get_files_by_pattern("dumpstate-*")
|
||||||
|
if not dumpstate_files:
|
||||||
|
return
|
||||||
|
|
||||||
|
content = self._get_file_content(dumpstate_files[0])
|
||||||
|
if not content:
|
||||||
|
return
|
||||||
|
|
||||||
|
lines = []
|
||||||
|
in_getprop = False
|
||||||
|
for line in content.decode().splitlines():
|
||||||
|
if line.strip() == "------ SYSTEM PROPERTIES (getprop) ------":
|
||||||
|
in_getprop = True
|
||||||
|
continue
|
||||||
|
|
||||||
|
if not in_getprop:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if line.strip() == "------":
|
||||||
|
break
|
||||||
|
|
||||||
|
lines.append(line)
|
||||||
|
|
||||||
|
self.results = GP.parse_getprop("\n".join(lines))
|
||||||
|
|
||||||
|
self.log.info("Extracted %d Android system properties", len(self.results))
|
||||||
|
|
|
@ -60,7 +60,7 @@ class Packages(BugReportModule):
|
||||||
package_name = None
|
package_name = None
|
||||||
package = {}
|
package = {}
|
||||||
lines = []
|
lines = []
|
||||||
for line in output.split("\n"):
|
for line in output.splitlines():
|
||||||
if line.startswith(" Package ["):
|
if line.startswith(" Package ["):
|
||||||
if len(lines) > 0:
|
if len(lines) > 0:
|
||||||
details = PCK.parse_package_for_details("\n".join(lines))
|
details = PCK.parse_package_for_details("\n".join(lines))
|
||||||
|
@ -95,7 +95,7 @@ class Packages(BugReportModule):
|
||||||
in_package = False
|
in_package = False
|
||||||
in_packages_list = False
|
in_packages_list = False
|
||||||
lines = []
|
lines = []
|
||||||
for line in content.decode().split("\n"):
|
for line in content.decode().splitlines():
|
||||||
if line.strip() == "DUMP OF SERVICE package:":
|
if line.strip() == "DUMP OF SERVICE package:":
|
||||||
in_package = True
|
in_package = True
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -68,7 +68,7 @@ class Receivers(BugReportModule):
|
||||||
|
|
||||||
in_receivers = False
|
in_receivers = False
|
||||||
lines = []
|
lines = []
|
||||||
for line in content.decode().split("\n"):
|
for line in content.decode().splitlines():
|
||||||
if line.strip() == "DUMP OF SERVICE package:":
|
if line.strip() == "DUMP OF SERVICE package:":
|
||||||
in_receivers = True
|
in_receivers = True
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in New Issue
Block a user