-
Notifications
You must be signed in to change notification settings - Fork 123
/
Copy pathruntimePerms.py
executable file
·69 lines (55 loc) · 2.48 KB
/
runtimePerms.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import xml.etree.ElementTree as ET
from scripts.artifact_report import ArtifactHtmlReport
from scripts.ilapfuncs import logfunc, tsv, is_platform_windows
def get_runtimePerms(files_found, report_folder, seeker, wrap_text, time_offset):
run = 0
slash = '\\' if is_platform_windows() else '/'
for file_found in files_found:
file_found = str(file_found)
data_list = []
run = run + 1
err = 0
parts = file_found.split(slash)
if 'mirror' in parts:
user = 'mirror'
elif 'system' in parts:
user = parts[-2]
elif 'misc_de' in parts:
user = parts[-4]
if user == 'mirror':
continue
else:
try:
ET.parse(file_found)
except ET.ParseError:
logfunc('Parse error - Non XML file.')
err = 1
if err == 0:
tree = ET.parse(file_found)
root = tree.getroot()
for elem in root:
#print(elem.tag)
usagetype = elem.tag
name = elem.attrib['name']
#print("Usage type: "+usagetype)
#print('name')
for subelem in elem:
permission = subelem.attrib['name']
granted = subelem.attrib['granted']
flags = subelem.attrib['flags']
data_list.append((usagetype, name, permission, granted, flags))
if len(data_list) > 0:
report = ArtifactHtmlReport('Runtime Permissions')
report.start_artifact_report(report_folder, f'Runtime Permissions_{user}')
report.add_script()
data_headers = ('Type', 'Name', 'Permission', 'Granted?','Flag')
report.write_artifact_data_table(data_headers, data_list, file_found)
report.end_artifact_report()
tsvname = f'Runtime Permissions_{user}'
tsv(report_folder, data_headers, data_list, tsvname)
__artifacts__ = {
"runtimePerms": (
"Permissions",
('*/system/users/*/runtime-permissions.xml','*/misc_de/*/apexdata/com.android.permission/runtime-permissions.xml'),
get_runtimePerms)
}