2022-01-30 02:34:16 +00:00
|
|
|
# Mobile Verification Toolkit (MVT)
|
2022-05-08 12:53:50 +00:00
|
|
|
# Copyright (c) 2021-2022 Claudio Guarnieri.
|
2022-01-30 02:34:16 +00:00
|
|
|
# Use of this software is governed by the MVT License 1.1 that can be found at
|
|
|
|
# https://license.mvt.re/1.1/
|
|
|
|
|
|
|
|
import logging
|
|
|
|
|
2022-02-02 20:58:11 +00:00
|
|
|
from mvt.android.parsers import parse_dumpsys_battery_history
|
2022-01-30 02:34:16 +00:00
|
|
|
|
2022-02-02 21:00:48 +00:00
|
|
|
from .base import AndroidExtraction
|
|
|
|
|
2022-01-30 02:34:16 +00:00
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
class DumpsysBatteryHistory(AndroidExtraction):
|
2022-01-30 15:02:24 +00:00
|
|
|
"""This module extracts records from battery history events."""
|
2022-01-30 02:34:16 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
def check_indicators(self):
|
2022-02-01 16:48:19 +00:00
|
|
|
if not self.indicators:
|
|
|
|
return
|
|
|
|
|
2022-01-30 02:34:16 +00:00
|
|
|
for result in self.results:
|
2022-02-01 13:27:00 +00:00
|
|
|
ioc = self.indicators.check_app_id(result["package_name"])
|
2022-01-30 02:34:16 +00:00
|
|
|
if ioc:
|
2022-01-30 19:29:09 +00:00
|
|
|
result["matched_indicator"] = ioc
|
2022-01-30 02:34:16 +00:00
|
|
|
self.detected.append(result)
|
|
|
|
continue
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
self._adb_connect()
|
|
|
|
output = self._adb_command("dumpsys batterystats --history")
|
2022-02-03 19:19:07 +00:00
|
|
|
self._adb_disconnect()
|
|
|
|
|
2022-02-02 20:58:11 +00:00
|
|
|
self.results = parse_dumpsys_battery_history(output)
|
2022-01-31 11:58:33 +00:00
|
|
|
|
|
|
|
self.log.info("Extracted %d records from battery history", len(self.results))
|