mirror of
https://github.com/mvt-project/mvt.git
synced 2024-06-17 18:14:07 +00:00
Using static methods
This commit is contained in:
parent
fb8a7ca104
commit
06cd640c5e
|
@ -27,7 +27,10 @@ class DumpsysAccessibility(AndroidExtraction):
|
||||||
self.detected.append(result)
|
self.detected.append(result)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
def process_accessibility(self, output):
|
@staticmethod
|
||||||
|
def parse_accessibility(output):
|
||||||
|
results = []
|
||||||
|
|
||||||
in_services = False
|
in_services = False
|
||||||
for line in output.split("\n"):
|
for line in output.split("\n"):
|
||||||
if line.strip().startswith("installed services:"):
|
if line.strip().startswith("installed services:"):
|
||||||
|
@ -43,17 +46,19 @@ class DumpsysAccessibility(AndroidExtraction):
|
||||||
service = line.split(":")[1].strip()
|
service = line.split(":")[1].strip()
|
||||||
log.info("Found installed accessibility service \"%s\"", service)
|
log.info("Found installed accessibility service \"%s\"", service)
|
||||||
|
|
||||||
self.results.append({
|
results.append({
|
||||||
"package": service.split("/")[0],
|
"package": service.split("/")[0],
|
||||||
"service": service,
|
"service": service,
|
||||||
})
|
})
|
||||||
|
|
||||||
log.info("Identified a total of %d accessibility services", len(self.results))
|
return results
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self._adb_connect()
|
self._adb_connect()
|
||||||
|
|
||||||
output = self._adb_command("dumpsys accessibility")
|
output = self._adb_command("dumpsys accessibility")
|
||||||
self.process_accessibility(output)
|
self.results = self.parse_accessibility(output)
|
||||||
|
|
||||||
|
self.log.info("Identified a total of %d accessibility services", len(self.results))
|
||||||
|
|
||||||
self._adb_disconnect()
|
self._adb_disconnect()
|
||||||
|
|
|
@ -30,7 +30,10 @@ class DumpsysActivities(AndroidExtraction):
|
||||||
self.detected.append({intent: activity})
|
self.detected.append({intent: activity})
|
||||||
continue
|
continue
|
||||||
|
|
||||||
def parse_activity_resolver_table(self, output):
|
@staticmethod
|
||||||
|
def parse_activity_resolver_table(output):
|
||||||
|
results = {}
|
||||||
|
|
||||||
in_activity_resolver_table = False
|
in_activity_resolver_table = False
|
||||||
in_non_data_actions = False
|
in_non_data_actions = False
|
||||||
intent = None
|
intent = None
|
||||||
|
@ -57,7 +60,7 @@ class DumpsysActivities(AndroidExtraction):
|
||||||
# We detect the action name.
|
# We detect the action name.
|
||||||
if line.startswith(" " * 6) and not line.startswith(" " * 8) and ":" in line:
|
if line.startswith(" " * 6) and not line.startswith(" " * 8) and ":" in line:
|
||||||
intent = line.strip().replace(":", "")
|
intent = line.strip().replace(":", "")
|
||||||
self.results[intent] = []
|
results[intent] = []
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# If we are not in an intent block yet, skip.
|
# If we are not in an intent block yet, skip.
|
||||||
|
@ -76,15 +79,17 @@ class DumpsysActivities(AndroidExtraction):
|
||||||
activity = line.strip().split(" ")[1]
|
activity = line.strip().split(" ")[1]
|
||||||
package = activity.split("/")[0]
|
package = activity.split("/")[0]
|
||||||
|
|
||||||
self.results[intent].append({
|
results[intent].append({
|
||||||
"package": package,
|
"package": package,
|
||||||
"activity": activity,
|
"activity": activity,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
return results
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self._adb_connect()
|
self._adb_connect()
|
||||||
|
|
||||||
output = self._adb_command("dumpsys package")
|
output = self._adb_command("dumpsys package")
|
||||||
self.parse_activity_resolver_table(output)
|
self.results = self.parse_activity_resolver_table(output)
|
||||||
|
|
||||||
self._adb_disconnect()
|
self._adb_disconnect()
|
||||||
|
|
|
@ -35,7 +35,9 @@ class DumpsysBatteryDaily(AndroidExtraction):
|
||||||
self.detected.append(result)
|
self.detected.append(result)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
def process_battery_history(self, output):
|
@staticmethod
|
||||||
|
def parse_battery_history(output):
|
||||||
|
results = []
|
||||||
daily = None
|
daily = None
|
||||||
daily_updates = []
|
daily_updates = []
|
||||||
for line in output.split("\n")[1:]:
|
for line in output.split("\n")[1:]:
|
||||||
|
@ -48,7 +50,7 @@ class DumpsysBatteryDaily(AndroidExtraction):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if line.strip() == "":
|
if line.strip() == "":
|
||||||
self.results.extend(daily_updates)
|
results.extend(daily_updates)
|
||||||
daily = None
|
daily = None
|
||||||
daily_updates = []
|
daily_updates = []
|
||||||
continue
|
continue
|
||||||
|
@ -75,12 +77,14 @@ class DumpsysBatteryDaily(AndroidExtraction):
|
||||||
"vers": vers_nr,
|
"vers": vers_nr,
|
||||||
})
|
})
|
||||||
|
|
||||||
self.log.info("Extracted %d records from battery daily stats", len(self.results))
|
return results
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self._adb_connect()
|
self._adb_connect()
|
||||||
|
|
||||||
output = self._adb_command("dumpsys batterystats --daily")
|
output = self._adb_command("dumpsys batterystats --daily")
|
||||||
self.process_battery_history(output)
|
self.results = self.parse_battery_history(output)
|
||||||
|
|
||||||
|
self.log.info("Extracted %d records from battery daily stats", len(self.results))
|
||||||
|
|
||||||
self._adb_disconnect()
|
self._adb_disconnect()
|
||||||
|
|
|
@ -27,7 +27,10 @@ class DumpsysBatteryHistory(AndroidExtraction):
|
||||||
self.detected.append(result)
|
self.detected.append(result)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
def process_battery_history(self, output):
|
@staticmethod
|
||||||
|
def parse_battery_history(output):
|
||||||
|
results = []
|
||||||
|
|
||||||
for line in output.split("\n")[1:]:
|
for line in output.split("\n")[1:]:
|
||||||
if line.strip() == "":
|
if line.strip() == "":
|
||||||
break
|
break
|
||||||
|
@ -64,7 +67,7 @@ class DumpsysBatteryHistory(AndroidExtraction):
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
self.results.append({
|
results.append({
|
||||||
"time_elapsed": time_elapsed,
|
"time_elapsed": time_elapsed,
|
||||||
"event": event,
|
"event": event,
|
||||||
"uid": uid,
|
"uid": uid,
|
||||||
|
@ -72,12 +75,14 @@ class DumpsysBatteryHistory(AndroidExtraction):
|
||||||
"service": service,
|
"service": service,
|
||||||
})
|
})
|
||||||
|
|
||||||
self.log.info("Extracted %d records from battery history", len(self.results))
|
return results
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self._adb_connect()
|
self._adb_connect()
|
||||||
|
|
||||||
output = self._adb_command("dumpsys batterystats --history")
|
output = self._adb_command("dumpsys batterystats --history")
|
||||||
self.process_battery_history(output)
|
self.results = self.parse_battery_history(output)
|
||||||
|
|
||||||
|
self.log.info("Extracted %d records from battery history", len(self.results))
|
||||||
|
|
||||||
self._adb_disconnect()
|
self._adb_disconnect()
|
||||||
|
|
|
@ -32,7 +32,10 @@ class DumpsysDBInfo(AndroidExtraction):
|
||||||
self.detected.append(result)
|
self.detected.append(result)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
def process_dbinfo(self, output):
|
@staticmethod
|
||||||
|
def parse_dbinfo(output):
|
||||||
|
results = []
|
||||||
|
|
||||||
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
|
||||||
|
@ -53,7 +56,7 @@ class DumpsysDBInfo(AndroidExtraction):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
match = matches[0]
|
match = matches[0]
|
||||||
self.results.append({
|
results.append({
|
||||||
"isodate": match[0],
|
"isodate": match[0],
|
||||||
"pid": match[1],
|
"pid": match[1],
|
||||||
"action": match[2],
|
"action": match[2],
|
||||||
|
@ -61,11 +64,13 @@ class DumpsysDBInfo(AndroidExtraction):
|
||||||
"path": match[4],
|
"path": match[4],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
return results
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self._adb_connect()
|
self._adb_connect()
|
||||||
|
|
||||||
output = self._adb_command("dumpsys dbinfo")
|
output = self._adb_command("dumpsys dbinfo")
|
||||||
self.process_dbinfo(output)
|
self.results = self.parse_dbinfo(output)
|
||||||
|
|
||||||
self.log.info("Extracted a total of %d records from database information",
|
self.log.info("Extracted a total of %d records from database information",
|
||||||
len(self.results))
|
len(self.results))
|
||||||
|
|
|
@ -52,7 +52,10 @@ class DumpsysReceivers(AndroidExtraction):
|
||||||
self.detected.append({intent: receiver})
|
self.detected.append({intent: receiver})
|
||||||
continue
|
continue
|
||||||
|
|
||||||
def parse_receiver_resolver_table(self, output):
|
@staticmethod
|
||||||
|
def parse_receiver_resolver_table(output):
|
||||||
|
results = {}
|
||||||
|
|
||||||
in_receiver_resolver_table = False
|
in_receiver_resolver_table = False
|
||||||
in_non_data_actions = False
|
in_non_data_actions = False
|
||||||
intent = None
|
intent = None
|
||||||
|
@ -79,7 +82,7 @@ class DumpsysReceivers(AndroidExtraction):
|
||||||
# We detect the action name.
|
# We detect the action name.
|
||||||
if line.startswith(" " * 6) and not line.startswith(" " * 8) and ":" in line:
|
if line.startswith(" " * 6) and not line.startswith(" " * 8) and ":" in line:
|
||||||
intent = line.strip().replace(":", "")
|
intent = line.strip().replace(":", "")
|
||||||
self.results[intent] = []
|
results[intent] = []
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# If we are not in an intent block yet, skip.
|
# If we are not in an intent block yet, skip.
|
||||||
|
@ -98,15 +101,17 @@ class DumpsysReceivers(AndroidExtraction):
|
||||||
receiver = line.strip().split(" ")[1]
|
receiver = line.strip().split(" ")[1]
|
||||||
package = receiver.split("/")[0]
|
package = receiver.split("/")[0]
|
||||||
|
|
||||||
self.results[intent].append({
|
results[intent].append({
|
||||||
"package": package,
|
"package": package,
|
||||||
"receiver": receiver,
|
"receiver": receiver,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
return results
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self._adb_connect()
|
self._adb_connect()
|
||||||
|
|
||||||
output = self._adb_command("dumpsys package")
|
output = self._adb_command("dumpsys package")
|
||||||
self.parse_receiver_resolver_table(output)
|
self.results = self.parse_receiver_resolver_table(output)
|
||||||
|
|
||||||
self._adb_disconnect()
|
self._adb_disconnect()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user