2021-08-26 13:23:54 +00:00
|
|
|
# Mobile Verification Toolkit (MVT)
|
2022-05-08 12:53:50 +00:00
|
|
|
# Copyright (c) 2021-2022 Claudio Guarnieri.
|
2021-08-26 13:23:54 +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
|
|
|
|
import os
|
|
|
|
|
|
|
|
from .base import AndroidExtraction
|
|
|
|
|
|
|
|
|
|
|
|
class Logcat(AndroidExtraction):
|
|
|
|
"""This module extracts details on installed packages."""
|
|
|
|
|
2022-06-17 20:30:46 +00:00
|
|
|
def __init__(self, file_path: str = None, target_path: str = None,
|
|
|
|
results_path: str = None, fast_mode: bool = False,
|
2022-08-11 14:42:04 +00:00
|
|
|
log: logging.Logger = logging.getLogger(__name__),
|
|
|
|
results: list = []) -> None:
|
2022-06-15 15:41:19 +00:00
|
|
|
super().__init__(file_path=file_path, target_path=target_path,
|
|
|
|
results_path=results_path, fast_mode=fast_mode,
|
2021-08-26 13:23:54 +00:00
|
|
|
log=log, results=results)
|
|
|
|
|
2022-06-17 20:30:46 +00:00
|
|
|
def run(self) -> None:
|
2021-08-26 13:23:54 +00:00
|
|
|
self._adb_connect()
|
|
|
|
|
|
|
|
# Get the current logcat.
|
|
|
|
output = self._adb_command("logcat -d")
|
|
|
|
# Get the locat prior to last reboot.
|
|
|
|
last_output = self._adb_command("logcat -L")
|
|
|
|
|
2022-06-15 15:41:19 +00:00
|
|
|
if self.results_path:
|
|
|
|
logcat_path = os.path.join(self.results_path,
|
2021-08-26 13:23:54 +00:00
|
|
|
"logcat.txt")
|
2022-01-29 11:18:18 +00:00
|
|
|
with open(logcat_path, "w", encoding="utf-8") as handle:
|
2021-08-26 13:23:54 +00:00
|
|
|
handle.write(output)
|
|
|
|
|
2022-08-11 14:42:04 +00:00
|
|
|
self.log.info("Current logcat logs stored at %s",
|
|
|
|
logcat_path)
|
2021-08-26 13:23:54 +00:00
|
|
|
|
2022-06-15 15:41:19 +00:00
|
|
|
logcat_last_path = os.path.join(self.results_path,
|
2021-08-26 13:23:54 +00:00
|
|
|
"logcat_last.txt")
|
2022-01-29 11:18:18 +00:00
|
|
|
with open(logcat_last_path, "w", encoding="utf-8") as handle:
|
2021-08-26 13:23:54 +00:00
|
|
|
handle.write(last_output)
|
|
|
|
|
2022-08-11 14:42:04 +00:00
|
|
|
self.log.info("Logcat logs prior to last reboot stored at %s",
|
|
|
|
logcat_last_path)
|
2021-08-26 13:23:54 +00:00
|
|
|
|
|
|
|
self._adb_disconnect()
|