-
Notifications
You must be signed in to change notification settings - Fork 3
/
report_Filevault_v2.1.sh
336 lines (250 loc) · 9.24 KB
/
report_Filevault_v2.1.sh
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
#!/bin/bash
# by Travelling Tech Guy
# 28th of August 2020
# travellingtechguy.blog
# This script will grab all useful information on a macOS system to throubleshoot FileVault
# Output will be written to a .txt file on the Desktop of the logged-in user
###### WARNING #####
# THIS SCRIPT WILL DISCLOSE CONFIDENTIAL INFORMATION LIKE:
# Usernames
# FileVault Recovery Keys
# SecureToken-enabled accounts
# !!! REMOVE THE INFORMATION YOU DO NOT WANT TO SHARE
# !!! DELETE THE FILE FROM THE DESKTOP WHEN DONE
# variables
currentDate=$(date "+%d%m%Y_%H%M")
#echo $currentDate
currentFullDate=$(date)
#echo $currentFullDate
loggedInUser=$(/usr/bin/python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "\n");')
#echo $loggedInUser
serial=$(system_profiler SPHardwareDataType | awk '/Serial/ {print $4}')
#echo $serial
computerName=$(scutil --get ComputerName)
#echo $computerName
osVer=$(sw_vers -productVersion)
#echo $osVer
build=$(sw_vers -buildVersion)
#echo $build
fdeSetupStatus=`/usr/bin/fdesetup status`
#echo "$fdeSetupStatus"
diskUtil=`/usr/sbin/diskutil apfs listusers /`
#echo "$diskUtil"
fdeSetup=`/usr/bin/fdesetup list -extended`
#echo "$fdeSetup"
bootStrap=`/usr/bin/profiles status -type bootstraptoken`
#echo "$bootStrap"
#echo "Deferral Info:"
deferralInfo=`/usr/bin/fdesetup showdeferralinfo`
#echo "$deferralInfo"
outputPath=""
outputPathContent=""
prkFound=""
prkCheck=`fdesetup haspersonalrecoverykey`
#echo "$prkCheck"
irkCheck=`fdesetup hasinstitutionalrecoverykey`
#echo "$irkCheck"
PRKValidation=""
mobileAccounts=`dscl . list /Users OriginalNodeName | awk '{print $1}' 2>/dev/null`
#echo "$mobileAccounts"
isMobile=`dscl . read /Users/$loggedInUser OriginalNodeName 2>/dev/null`
#echo "$isMobile"
isAdmin=`/usr/sbin/dseditgroup -o checkmember -m $loggedInUser admin / 2>&1`
#echo "$isAdmin"
setupUserFile="/var/db/ConfigurationProfiles/Settings/.setupUser"
localAccounts=`dscl . list /Users UniqueID | awk '$2 > 500 && $2 < 1000 { print $1 }'`
recoveryPartition=`/usr/sbin/diskutil list | grep "Recovery"`
# Create dated file
rm -rf /Users/$loggedInUser/Desktop/reportFV-$serial-$currentDate.txt
touch /Users/$loggedInUser/Desktop/reportFV-$serial-$currentDate.txt
reportFile="/Users/$loggedInUser/Desktop/reportFV-$serial-$currentDate.txt"
echo " "
echo " Creating timestamped report file on Desktop"
echo " --> deleting previous file with same timestamp"
##### PRINT INFO TO FILE #####
echo "################" >> $reportFile
echo "FileVault Report" >> $reportFile
echo "################" >> $reportFile
echo >> $reportFile
echo "########################################################" >> $reportFile
echo "WARNING: this file may contain CONFIDENTIAL INFORMATION!" >> $reportFile
echo "DELETE unwanted information before sharing!" >> $reportFile
echo "DELETE file from Mac when not needed anymore!" >> $reportFile
echo "########################################################" >> $reportFile
echo >> $reportFile
echo "Date: "$currentFullDate >> $reportFile
echo "---------------------------------------------" >> $reportFile
echo "Serial Number: "$serial >> $reportFile
echo "Computer Name: "$computerName >> $reportFile
echo "macOS Version: "$osVer >> $reportFile
echo "macOS Build: "$build >> $reportFile
echo "---------------------------------------------" >> $reportFile
echo >> $reportFile
echo "---------------" >> $reportFile
echo "Logged In User: "$loggedInUser >> $reportFile
echo "---------------" >> $reportFile
echo >> $reportFile
if [ "$isMobile" == "" ]; then
echo "Is mobile account: NO" >> $reportFile
echo >> $reportFile
else
echo "Is mobile account: YES" >> $reportFile
echo >> $reportFile
fi
if [[ "$isAdmin" =~ "yes" ]]; then
echo "Is admin account: YES" >> $reportFile
echo >> $reportFile
else
echo "Is admin account: NO" >> $reportFile
echo >> $reportFile
fi
echo "---------------" >> $reportFile
echo "Mobile Accounts" >> $reportFile
echo "---------------" >> $reportFile
echo >> $reportFile
echo "$mobileAccounts" >> $reportFile
echo >> $reportFile
echo "--------------" >> $reportFile
echo "Local Accounts" >> $reportFile
echo "--------------" >> $reportFile
echo >> $reportFile
echo "$localAccounts" >> $reportFile
echo >> $reportFile
echo "--------------" >> $reportFile
echo "Admin Accounts" >> $reportFile
echo "--------------" >> $reportFile
echo >> $reportFile
listAdmins=()
for username in $(dscl . list /Users UniqueID | awk '$2 > 500 { print $1 }'); do
if [[ $(dsmemberutil checkmembership -U "${username}" -G admin) != *not* ]]; then
listAdmins+=("${username}")
fi
done
for word in ${listAdmins[@]}; do
echo "$word" >> $reportFile
done
echo >> $reportFile
echo "------------------" >> $reportFile
echo "Managed Admin Info" >> $reportFile
echo "------------------" >> $reportFile
echo >> $reportFile
if [[ -f "$setupUserFile" ]]; then
echo "$setupUserFile" >> $reportFile
echo >> $reportFile
setupUserContent=$(cat $setupUserFile)
echo "$setupUserContent" >> $reportFile
echo >> $reportFile
fi
echo "----------------" >> $reportFile
echo "FileVault Status" >> $reportFile
echo "----------------" >> $reportFile
echo "(fdesetup status)" >> $reportFile
echo >> $reportFile
echo "$fdeSetupStatus" >> $reportFile
echo >> $reportFile
echo "------------------" >> $reportFile
echo "Recovery Partition" >> $reportFile
echo "------------------" >> $reportFile
echo "(/usr/sbin/diskutil list | grep "Recovery")" >> $reportFile
echo >> $reportFile
echo "$recoveryPartition" >> $reportFile
echo >> $reportFile
echo "-------------------------" >> $reportFile
echo "Secure Tokens - Disk Util" >> $reportFile
echo "-------------------------" >> $reportFile
echo "(disktutil apfs listusers /)" >> $reportFile
echo >> $reportFile
echo "$diskUtil" >> $reportFile
echo >> $reportFile
echo "------------------------" >> $reportFile
echo "Secure Tokens - fdesetup" >> $reportFile
echo "------------------------" >> $reportFile
echo "(sudo fdesetup list -extended)" >> $reportFile
echo >> $reportFile
echo "$fdeSetup" >> $reportFile
echo >> $reportFile
echo "---------" >> $reportFile
echo "BOOTSTRAP" >> $reportFile
echo "---------" >> $reportFile
echo "(sudo profiles status -type bootstraptoken)" >> $reportFile
echo >> $reportFile
echo "$bootStrap" >> $reportFile
echo >> $reportFile
echo "-------------" >> $reportFile
echo "Deferral Info" >> $reportFile
echo "-------------" >> $reportFile
echo "(sudo fdesetup showdeferralinfo)" >> $reportFile
echo >> $reportFile
echo "$deferralInfo" >> $reportFile
echo >> $reportFile
echo "----------------------" >> $reportFile
echo "Content of OutPut Path" >> $reportFile
echo "----------------------" >> $reportFile
if [ "$deferralInfo" != "Not found." ]; then
outputPath=$(echo "$deferralInfo" | sed -e 's/.*OutputPath = \"\(.*\)\";/\1/' | sed -n '3 p')
#echo "$outputPath"
if [[ -f "$outputPath" ]]; then
outputPathContent=$(cat $outputPath)
echo "($outputPath)" >> $reportFile
echo >> $reportFile
echo "$outputPathContent" >> $reportFile
echo >> $reportFile
prkFound=`defaults read /var/db/ConfigurationProfiles/fdesetup.plist RecoveryKey`
#echo "$prkFound"
else
echo >> $reportFile
echo "Output file does not exist yet" >> $reportFile
echo >> $reportFile
fi
else
echo >> $reportFile
echo "No Deferral Info found" >> $reportFile
echo >> $reportFile
fi
echo "----------------------------" >> $reportFile
echo "Personal Recovery Key: "$prkCheck >> $reportFile
echo "----------------------------" >> $reportFile
echo >> $reportFile
if [ "$deferralInfo" != "Not found." ]; then
echo "PRK found in OutPut Path: "$prkFound >> $reportFile
else
echo "No PRK found - No Deferral Info" >> $reportFile
fi
validateRecovery () {
expect << EOF
spawn /usr/bin/fdesetup validaterecovery
expect "Enter the current recovery key:"
send "$prkFound\n"
expect
EOF
}
if [ "$prkCheck" == "true" ] && [ $prkFound != "" ]; then
#echo "Checking PRK"
tempOutput=`validateRecovery | awk {'print $1}'`
#echo "Temp output:"
PRKValidation=`echo $tempOutput | sed 's/spawn//g' | sed 's/Enter//g' | sed 's/ //g' | sed 's/://g'`
#echo $PRKValidation
echo >> $reportFile
echo "PRK Valid: "$PRKValidation >> $reportFile
fi
echo >> $reportFile
echo "----------------------------------" >> $reportFile
echo "Institutional Recovery Key: "$irkCheck >> $reportFile
echo "----------------------------------" >> $reportFile
echo >> $reportFile
echo >> $reportFile
echo >> $reportFile
echo " "
echo "DONE!"
echo " "
echo "################################################################"
echo "WARNING: the output file may contain CONFIDENTIAL INFORMATION!"
echo "DELETE unwanted information before sharing!"
echo "DELETE file from Mac when not needed anymore!"
echo "################################################################"
echo " "
echo "############################################################" >> $reportFile
echo "Report script provided by Travelling Tech Guy" >> $reportFile
echo "Blog: https://travellingtechguy.blog" >> $reportFile
echo "GitHub: https://github.com/TravellingTechGuy/reportFileVault" >> $reportFile
echo "############################################################" >> $reportFile