-
Notifications
You must be signed in to change notification settings - Fork 9
/
Entitlements_Check.py
199 lines (183 loc) · 17.2 KB
/
Entitlements_Check.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
#!/usr/bin/env python3
import sys
import os
import subprocess
d = os.listdir("/Applications/")
print("=======================================/Applications Directory Check============================================")
for each in d:
if each.endswith('.app'):
apath = "/Applications/%s/Contents/MacOS" % each
try:
p = os.listdir(apath)
for item in p:
apath2 = apath + "/" + item
x = subprocess.getstatusoutput('codesign -d --entitlements :- "%s"' % apath2)
if 'com.apple.security.cs.allow-dyld-environment-variables</key><true/>' in x[1]:
print("\033[33m[-] POTENTIALLY INJECTABLE APP (has com.apple.security.cs-allow-dyld-environment-variables entitlement): %s\033[0m" % apath2)
if 'com.apple.security.cs.disable-library-validation</key><true/>' in x[1]:
print("\033[33m[-] Binary can load arbitrary unsigned plugins/frameworks (has com.apple.security.cs.disable-library-validation entitlement): %s\033[0m" % apath2)
if 'com.apple.security.get-task-allow</key><true/>' in x[1]:
print("\033[33m[-] Binary allows other non sandboxed processes to attach (has com.apple.security.get-task-allow entitlement): %s\033[0m" % apath2)
if 'com.apple.security.cs.allow-unsigned-executable-memory</key><true/>' in x[1]:
print("\033[33m[-] Binary allows c code patching, NSCreateObjectFileImageFromMemory, or dvdplayback framework (has com.apple.security.cs.allow-unsigned-executable-memory entitlement): %s\033[0m" % apath2)
if ('com.apple.security.files.downloads.read-only</key><true/>' in x[1]) or ('com.apple.security.files.downloads.read-write</key></true>' in x[1]):
print("\033[33m[-] Binary may have access to the Downloads folder (has com.apple.security.files.downloads.read-only or com.apple.security.files.downloads.read-write entitlement): %s\033[0m" % apath2)
if 'com.apple.security.files.all</key><true/>' in x[1]:
print("\033[33m[-] Binary may have access to all files (has deprecated com.apple.security.files.all entitlement): %s\033[0m" % apath2)
if ('com.apple.security.files.user-selected.read-only</key><true/>' in x[1]) or ('com.apple.security.files.user-selected.read-write</key><true/>' in x[1]):
print("\033[33m[-] Binary may have access to files the user has selected in an open or save dialog (has com.apple.security.files.user-selected.read-only or com.apple.security.files.user-selected.read-write entitlement): %s\033[0m" % apath2)
if 'com.apple.private.security.clear-library-validation</key><true/>' in x[1]:
print("\033[33m[-] Binary can load third party plugins signed by non Apple developers (has com.apple.private.security.clear-library-validation entitlement): %s\033[0m" % apath2)
if 'com.apple.private.tcc.allow</key>' in x[1]:
print("\033[33m[-] Binary may have TCC access to some protected portions of the OS (has com.apple.private.tcc.allow entitlement): %s\033[0m" % apath2)
if 'kTCCServiceSystemPolicyDocumentsFolder' in x[1]:
print("\033[33m[-] Binary may have TCC access to ~/Documents (has kTCCServiceSystemPolicyDocumentsFolder access): %s\033[0m" % apath2)
if 'kTCCServiceSystemPolicyDownloadsFolder' in x[1]:
print("\033[33m[-] Binary may have TCC access to ~/Downloads (has kTCCServiceSystemPolicyDownloadsFolder access): %s\033[0m" % apath2)
if 'kTCCServiceSystemPolicyDesktopFolder' in x[1]:
print("\033[33m[-] Binary may have TCC access to ~/Desktop (has kTCCServiceSystemPolicyDesktopFolder access): %s\033[0m" % apath2)
if 'kTCCServiceSystemPolicyAllFiles' in x[1]:
print("\033[33m[-] Binary may have FDA access (has kTCCServiceSystemPolicyAllFiles access): %s\033[0m" % apath2)
except:
pass
s = os.listdir("/System/Applications/Utilities/")
print("=======================================/Application Utilities Directory Check============================================")
for app in s:
if app.endswith('.app'):
app_path = "/System/Applications/Utilities/%s/Contents/MacOS" % app
try:
u = os.listdir(app_path)
for appfile in u:
app_path2 = app_path + "/" + appfile
xy = subprocess.getstatusoutput('codesign -d --entitlements :- "%s"' % app_path2)
if 'com.apple.security.cs.allow-dyld-environment-variables</key><true/>' in xy[1]:
print("\033[33m[-] POTENTIALLY INJECTABLE APP (has com.apple.security.cs-allow-dyld-environment-variables entitlement): %s\033[0m" % app_path2)
if 'com.apple.security.cs.disable-library-validation</key><true/>' in xy[1]:
print("\033[33m[-] Binary can load arbitrary unsigned plugins/frameworks (has com.apple.security.cs.disable-library-validation entitlement): %s\033[0m" % app_path2)
if 'com.apple.security.get-task-allow</key><true/>' in xy[1]:
print("\033[33m[-] Binary allows other non sandboxed processes to attach (has com.apple.security.get-task-allow entitlement): %s\033[0m" % app_path2)
if 'com.apple.security.cs.allow-unsigned-executable-memory</key><true/>' in xy[1]:
print("\033[33m[-] Binary allows c code patching, NSCreateObjectFileImageFromMemory, or dvdplayback framework (has com.apple.security.cs.allow-unsigned-executable-memory entitlement): %s\033[0m" % app_path2)
if ('com.apple.security.files.downloads.read-only</key><true/>' in xy[1]) or ('com.apple.security.files.downloads.read-write</key></true>' in xy[1]):
print("\033[33m[-] Binary may have access to the Downloads folder (has com.apple.security.files.downloads.read-only or com.apple.security.files.downloads.read-write entitlement): %s\033[0m" % app_path2)
if 'com.apple.security.files.all</key><true/>' in xy[1]:
print("\033[33m[-] Binary may have access to all files (has deprecated com.apple.security.files.all entitlement): %s\033[0m" % app_path2)
if ('com.apple.security.files.user-selected.read-only</key><true/>' in xy[1]) or ('com.apple.security.files.user-selected.read-write</key><true/>' in xy[1]):
print("\033[33m[-] Binary may have access to files the user has selected in an open or save dialog (has com.apple.security.files.user-selected.read-only or com.apple.security.files.user-selected.read-write entitlement): %s\033[0m" % app_path2)
if 'com.apple.private.security.clear-library-validation</key><true/>' in xy[1]:
print("\033[33m[-] Binary can load third party plugins signed by non Apple developers (has com.apple.private.security.clear-library-validation entitlement): %s\033[0m" % app_path2)
if 'com.apple.private.tcc.allow</key>' in xy[1]:
print("\033[33m[-] Binary may have TCC access to some protected portions of the OS (has com.apple.private.tcc.allow entitlement): %s\033[0m" % app_path2)
if 'kTCCServiceSystemPolicyDocumentsFolder' in xy[1]:
print("\033[33m[-] Binary may have TCC access to ~/Documents (has kTCCServiceSystemPolicyDocumentsFolder access): %s\033[0m" % app_path2)
if 'kTCCServiceSystemPolicyDownloadsFolder' in xy[1]:
print("\033[33m[-] Binary may have TCC access to ~/Downloads (has kTCCServiceSystemPolicyDownloadsFolder access): %s\033[0m" % app_path2)
if 'kTCCServiceSystemPolicyDesktopFolder' in xy[1]:
print("\033[33m[-] Binary may have TCC access to ~/Desktop (has kTCCServiceSystemPolicyDesktopFolder access): %s\033[0m" % app_path2)
if 'kTCCServiceSystemPolicyAllFiles' in xy[1]:
print("\033[33m[-] Binary may have FDA access (has kTCCServiceSystemPolicyAllFiles access): %s\033[0m" % app_path2)
except:
pass
print("=======================================/usr/local/bin Directory Check============================================")
c = os.listdir("/usr/local/bin")
for binary in c:
bpath = "/usr/local/bin/" + binary
try:
y = subprocess.getstatusoutput('codesign -d --entitlements :- "%s"' % bpath)
if 'com.apple.security.cs.allow-dyld-environment-variables</key><true/>' in y[1]:
print("\033[91m[-] POTENTIALLY INJECTABLE APP (has com.apple.security.cs-allow-dyld-environment-variables entitlement): %s\033[0m" % bpath)
if 'com.apple.security.cs.disable-library-validation</key><true/>' in y[1]:
print("\033[33m[-] Binary can load arbitrary unsigned plugins/frameworks (has com.apple.security.cs.disable-library-validation entitlement): %s\033[0m" % bpath)
if 'com.apple.security.get-task-allow</key><true/>' in y[1]:
print("\033[33m[-] Binary allows other non sandboxed processes to attach (has com.apple.security.get-task-allow entitlement): %s\033[0m" % bpath)
if 'com.apple.security.cs.allow-unsigned-executable-memory</key><true/>' in y[1]:
print("\033[33m[-] Binary allows c code patching, NSCreateObjectFileImageFromMemory, or dvdplayback framework (has com.apple.security.cs.allow-unsigned-executable-memory entitlement): %s\033[0m" % bpath)
if ('com.apple.security.files.downloads.read-only</key><true/>' in y[1]) or ('com.apple.security.files.downloads.read-write</key></true>' in y[1]):
print("\033[33m[-] Binary may have access to the Downloads folder (has com.apple.security.files.downloads.read-only or com.apple.security.files.downloads.read-write entitlement): %s\033[0m" % bpath)
if 'com.apple.security.files.all</key><true/>' in y[1]:
print("\033[33m[-] Binary may have access to all files (has deprecated com.apple.security.files.all entitlement): %s\033[0m" % bpath)
if ('com.apple.security.files.user-selected.read-only</key><true/>' in y[1]) or ('com.apple.security.files.user-selected.read-write</key><true/>' in y[1]):
print("\033[33m[-] Binary may have access to files the user has selected in an open or save dialog (has com.apple.security.files.user-selected.read-only or com.apple.security.files.user-selected.read-write entitlement): %s\033[0m" % bpath)
if 'com.apple.private.security.clear-library-validation</key><true/>' in y[1]:
print("\033[33m[-] Binary can load third party plugins signed by non Apple developers (has com.apple.private.security.clear-library-validation entitlement): %s\033[0m" % bpath)
if 'com.apple.private.tcc.allow</key>' in y[1]:
print("\033[33m[-] Binary may have TCC access to some protected portions of the OS (has com.apple.private.tcc.allow entitlement): %s\033[0m" % bpath)
if 'kTCCServiceSystemPolicyDocumentsFolder' in y[1]:
print("\033[33m[-] Binary may have TCC access to ~/Documents (has kTCCServiceSystemPolicyDocumentsFolder access): %s\033[0m" % bpath)
if 'kTCCServiceSystemPolicyDownloadsFolder' in y[1]:
print("\033[33m[-] Binary may have TCC access to ~/Downloads (has kTCCServiceSystemPolicyDownloadsFolder access): %s\033[0m" % bpath)
if 'kTCCServiceSystemPolicyDesktopFolder' in y[1]:
print("\033[33m[-] Binary may have TCC access to ~/Desktop (has kTCCServiceSystemPolicyDesktopFolder access): %s\033[0m" % bpath)
if 'kTCCServiceSystemPolicyAllFiles' in y[1]:
print("\033[33m[-] Binary may have FDA access (has kTCCServiceSystemPolicyAllFiles access): %s\033[0m" % bpath)
except:
pass
print("=======================================/usr/sbin Directory Check============================================")
b = os.listdir("/usr/sbin")
for bin in b:
spath = "/usr/sbin/%s" % bin
try:
w = subprocess.getstatusoutput('codesign -d --entitlements :- "%s"' % spath)
if 'com.apple.security.cs.allow-dyld-environment-variables</key><true/>' in w[1]:
print("\033[91m[-] POTENTIALLY INJECTABLE APP (has com.apple.security.cs-allow-dyld-environment-variables entitlement): %s\033[0m" % spath)
if 'com.apple.security.cs.disable-library-validation</key><true/>' in w[1]:
print("\033[33m[-] Binary can load arbitrary unsigned plugins/frameworks (has com.apple.security.cs.disable-library-validation entitlement): %s\033[0m" % spath)
if 'com.apple.security.get-task-allow</key><true/>' in w[1]:
print("\033[33m[-] Binary allows other non sandboxed processes to attach (has com.apple.security.get-task-allow entitlement): %s\033[0m" % spath)
if 'com.apple.security.cs.allow-unsigned-executable-memory</key><true/>' in w[1]:
print("\033[33m[-] Binary allows c code patching, NSCreateObjectFileImageFromMemory, or dvdplayback framework (has com.apple.security.cs.allow-unsigned-executable-memory entitlement): %s\033[0m" % spath)
if ('com.apple.security.files.downloads.read-only</key><true/>' in w[1]) or ('com.apple.security.files.downloads.read-write</key></true>' in w[1]):
print("\033[33m[-] Binary may have access to the Downloads folder (has com.apple.security.files.downloads.read-only or com.apple.security.files.downloads.read-write entitlement): %s\033[0m" % spath)
if 'com.apple.security.files.all</key><true/>' in w[1]:
print("\033[33m[-] Binary may have access to all files (has deprecated com.apple.security.files.all entitlement): %s\033[0m" % spath)
if ('com.apple.security.files.user-selected.read-only</key><true/>' in w[1]) or ('com.apple.security.files.user-selected.read-write</key><true/>' in w[1]):
print("\033[33m[-] Binary may have access to files the user has selected in an open or save dialog (has com.apple.security.files.user-selected.read-only or com.apple.security.files.user-selected.read-write entitlement): %s\033[0m" % spath)
if 'com.apple.private.security.clear-library-validation</key><true/>' in w[1]:
print("\033[33m[-] Binary can load third party plugins signed by non Apple developers (has com.apple.private.security.clear-library-validation entitlement): %s\033[0m" % spath)
if 'com.apple.private.tcc.allow</key>' in w[1]:
print("\033[33m[-] Binary may have TCC access to some protected portions of the OS (has com.apple.private.tcc.allow entitlement): %s\033[0m" % spath)
if 'kTCCServiceSystemPolicyDocumentsFolder' in w[1]:
print("\033[33m[-] Binary may have TCC access to ~/Documents (has kTCCServiceSystemPolicyDocumentsFolder access): %s\033[0m" % spath)
if 'kTCCServiceSystemPolicyDownloadsFolder' in w[1]:
print("\033[33m[-] Binary may have TCC access to ~/Downloads (has kTCCServiceSystemPolicyDownloadsFolder access): %s\033[0m" % spath)
if 'kTCCServiceSystemPolicyDesktopFolder' in w[1]:
print("\033[33m[-] Binary may have TCC access to ~/Desktop (has kTCCServiceSystemPolicyDesktopFolder access): %s\033[0m" % spath)
if 'kTCCServiceSystemPolicyAllFiles' in w[1]:
print("\033[33m[-] Binary may have FDA access (has kTCCServiceSystemPolicyAllFiles access): %s\033[0m" % spath)
except:
pass
print("=======================================/usr/bin Directory Check============================================")
a = os.listdir("/usr/bin")
for f in a:
pth = "/usr/bin/%s" % f
try:
j = subprocess.getstatusoutput('codesign -d --entitlements :- "%s"' % pth)
if 'com.apple.security.cs.allow-dyld-environment-variables</key><true/>' in j[1]:
print("\033[91m[-] POTENTIALLY INJECTABLE APP (has com.apple.security.cs-allow-dyld-environment-variables entitlement): %s\033[0m" % pth)
if 'com.apple.security.cs.disable-library-validation</key><true/>' in j[1]:
print("\033[33m[-] Binary can load arbitrary unsigned plugins/frameworks (has com.apple.security.cs.disable-library-validation entitlement): %s\033[0m" % pth)
if 'com.apple.security.get-task-allow</key><true/>' in j[1]:
print("\033[33m[-] Binary allows other non sandboxed processes to attach (has com.apple.security.get-task-allow entitlement): %s\033[0m" % pth)
if 'com.apple.security.cs.allow-unsigned-executable-memory</key><true/>' in j[1]:
print("\033[33m[-] Binary allows c code patching, NSCreateObjectFileImageFromMemory, or dvdplayback framework (has com.apple.security.cs.allow-unsigned-executable-memory entitlement): %s\033[0m" % pth)
if ('com.apple.security.files.downloads.read-only</key><true/>' in j[1]) or ('com.apple.security.files.downloads.read-write</key></true>' in j[1]):
print("\033[33m[-] Binary may have access to the Downloads folder (has com.apple.security.files.downloads.read-only or com.apple.security.files.downloads.read-write entitlement): %s\033[0m" % pth)
if 'com.apple.security.files.all</key><true/>' in j[1]:
print("\033[33m[-] Binary may have access to all files (has deprecated com.apple.security.files.all entitlement): %s\033[0m" % pth)
if ('com.apple.security.files.user-selected.read-only</key><true/>' in j[1]) or ('com.apple.security.files.user-selected.read-write</key><true/>' in j[1]):
print("\033[33m[-] Binary may have access to files the user has selected in an open or save dialog (has com.apple.security.files.user-selected.read-only or com.apple.security.files.user-selected.read-write entitlement): %s\033[0m" % pth)
if 'com.apple.private.security.clear-library-validation</key><true/>' in j[1]:
print("\033[33m[-] Binary can load third party plugins signed by non Apple developers (has com.apple.private.security.clear-library-validation entitlement): %s\033[0m" % pth)
if 'com.apple.private.tcc.allow</key>' in j[1]:
print("\033[33m[-] Binary may have TCC access to some protected portions of the OS (has com.apple.private.tcc.allow entitlement): %s\033[0m" % pth)
if 'kTCCServiceSystemPolicyDocumentsFolder' in j[1]:
print("\033[33m[-] Binary may have TCC access to ~/Documents (has kTCCServiceSystemPolicyDocumentsFolder access): %s\033[0m" % pth)
if 'kTCCServiceSystemPolicyDownloadsFolder' in j[1]:
print("\033[33m[-] Binary may have TCC access to ~/Downloads (has kTCCServiceSystemPolicyDownloadsFolder access): %s\033[0m" % pth)
if 'kTCCServiceSystemPolicyDesktopFolder' in j[1]:
print("\033[33m[-] Binary may have TCC access to ~/Desktop (has kTCCServiceSystemPolicyDesktopFolder access): %s\033[0m" % pth)
if 'kTCCServiceSystemPolicyAllFiles' in j[1]:
print("\033[33m[-] Binary may have FDA access (has kTCCServiceSystemPolicyAllFiles access): %s\033[0m" % pth)
except:
pass
print("[+] DONE!")