-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathfunction-test.py
More file actions
330 lines (245 loc) · 11.3 KB
/
function-test.py
File metadata and controls
330 lines (245 loc) · 11.3 KB
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
# function test call spitkey with various test files to check they are
# decrypted correctly and make sure I havent broken anything by making changes
import os
def get_line(filename):
file = open(filename)
first_line = file.readline()
return first_line
def get_fvek(filename):
file = open(filename, "rb")
fvek_hex = file.read().hex()
return fvek_hex
def cleanup(filename):
if os.path.isfile(filename):
print("removing " + filename)
os.remove(filename)
result_list = ""
# -----------------------------------------------------------------------------
# Test logic2-TPMandKEY
result = "passed"
fvek_file = os.path.join("testdata", "logic2-TPMandKEY", "DESKTOP-LBLPGHL.fvek")
recovery_file = os.path.join("testdata", "logic2-TPMandKEY", "38F91648-280E-4F3A-9772-640DCB48F4CE.recovery")
cleanup(fvek_file)
cleanup(recovery_file)
log = os.path.join("testdata", "logic2-TPMandKEY", "dislocker-TPMandKEY.log")
key = os.path.join("testdata", "logic2-TPMandKEY", "TPMandKEY.vmk")
bek = os.path.join("testdata", "logic2-TPMandKEY", "E5EFFF28-7AA3-4000-9E70-BB1A3DAD6203.BEK")
print("\n\nTesting logic2-TPMandKEY\n")
command = "python SPITkey.py -l " + log + " -k " + key + " -b " + bek
print(f"Command: {command}")
os.system(command)
recovery_key = "712349-506968-088748-356565-266090-003839-598565-010538"
fvek = "0480c9fa9f7c8457890542b80d80b26abac96503f05d84ddca4fa8af2d9fe993dfd30000000000000000000000000000000000000000000000000000000000000000"
dec_fvek = get_fvek(fvek_file)
if dec_fvek != fvek:
print("TPM only FVEK did not decrypt correctly")
result = "failed"
dec_recovery = get_line(recovery_file)
if dec_recovery != recovery_key:
print("TPM only Recovery key did not decrypt correctly")
result = "failed"
cleanup(fvek_file)
cleanup(recovery_file)
result_list = result_list + "TPMandKEY test " + result + "\n"
# Test logic2-TPM
result = "passed"
fvek_file = os.path.join("testdata", "logic2-TPM", "DESKTOP-LBLPGHL.fvek")
recovery_file = os.path.join("testdata", "logic2-TPM", "38F91648-280E-4F3A-9772-640DCB48F4CE.recovery")
cleanup(fvek_file)
cleanup(recovery_file)
log = os.path.join("testdata", "logic2-TPM", "dislocker-TPM.log")
key = os.path.join("testdata", "logic2-TPM", "TPM-only.vmk")
print("\n\nTesting logic2-TPM\n")
command = "python SPITkey.py -l " + log + " -k " + key
print(f"Command: {command}")
os.system(command)
recovery_key = "712349-506968-088748-356565-266090-003839-598565-010538"
fvek = "0480c9fa9f7c8457890542b80d80b26abac96503f05d84ddca4fa8af2d9fe993dfd30000000000000000000000000000000000000000000000000000000000000000"
dec_fvek = get_fvek(fvek_file)
if dec_fvek != fvek:
print("TPM only FVEK did not decrypt correctly")
result = "failed"
dec_recovery = get_line(recovery_file)
if dec_recovery != recovery_key:
print("TPM only Recovery key did not decrypt correctly")
result = "failed"
cleanup(fvek_file)
cleanup(recovery_file)
result_list = result_list + "TPM only test " + result + "\n"
# -----------------------------------------------------------------------------
# Test logic2-TPMandPIN
result = "passed"
fvek_file = os.path.join("testdata", "logic2-TPMandPIN", "DESKTOP-LBLPGHL.fvek")
recovery_file = os.path.join("testdata", "logic2-TPMandPIN", "38F91648-280E-4F3A-9772-640DCB48F4CE.recovery")
cleanup(fvek_file)
cleanup(recovery_file)
log = os.path.join("testdata", "logic2-TPMandPIN", "dislocker-TPMandPIN.log")
blob = os.path.join("testdata", "logic2-TPMandPIN", "TPMandPIN.blob")
print("\n\nTesting logic2-TPMandPIN\n")
command = "python SPITkey.py -l " + log + " -t " + blob + " -p 87654321"
print(f"Command: {command}")
os.system(command)
recovery_key = "712349-506968-088748-356565-266090-003839-598565-010538"
fvek = "0480c9fa9f7c8457890542b80d80b26abac96503f05d84ddca4fa8af2d9fe993dfd30000000000000000000000000000000000000000000000000000000000000000"
dec_fvek = get_fvek(fvek_file)
if dec_fvek != fvek:
print("TPMandPIN FVEK did not decrypt correctly")
result = "failed"
dec_recovery = get_line(recovery_file)
if dec_recovery != recovery_key:
print("TPMandPIN Recovery key did not decrypt correctly")
result = "failed"
cleanup(fvek_file)
cleanup(recovery_file)
result_list = result_list + "TPMandPIN test " + result + "\n"
# -----------------------------------------------------------------------------
# Test logic2-TPMandPINandKEY
result = "passed"
fvek_file = os.path.join("testdata", "logic2-TPMandPINandKEY", "DESKTOP-LBLPGHL.fvek")
recovery_file = os.path.join("testdata", "logic2-TPMandPINandKEY", "3CBE5E70-96FF-45BC-A609-1D38323006F0.recovery")
cleanup(fvek_file)
cleanup(recovery_file)
log = os.path.join("testdata", "logic2-TPMandPINandKEY", "dislocker-TPMandPINandKEY.log")
blob = os.path.join("testdata", "logic2-TPMandPINandKEY", "TPMandPINandKEY.blob")
bek = os.path.join("testdata", "logic2-TPMandPINandKEY", "CA933F67-F8AA-4FB7-B526-F0D4EE6AB0AB.BEK")
print("\n\nTesting logic2-TPMandPINandKEY\n")
command = "python SPITkey.py -l " + log + " -t " + blob + " -p 87654321 -b " + bek
print(f"Command: {command}")
os.system(command)
recovery_key = "203907-116314-114389-096954-364463-544236-500236-393580"
fvek = "0480c9fa9f7c8457890542b80d80b26abac96503f05d84ddca4fa8af2d9fe993dfd30000000000000000000000000000000000000000000000000000000000000000"
dec_fvek = get_fvek(fvek_file)
if dec_fvek != fvek:
print("TPMandPINandKEY FVEK did not decrypt correctly")
result = "failed"
dec_recovery = get_line(recovery_file)
if dec_recovery != recovery_key:
print("TPMandPINandKEY Recovery key did not decrypt correctly")
result = "failed"
cleanup(fvek_file)
cleanup(recovery_file)
result_list = result_list + "TPMandPINandKEY test " + result + "\n"
# -----------------------------------------------------------------------------
# Test swtpm-TPM
result = "passed"
fvek_file = os.path.join("testdata", "swtpm-TPM", "DESKTOP-GUUFK3H.fvek")
recovery_file = os.path.join("testdata", "swtpm-TPM", "39C2AA90-0CFA-4B77-9622-11A99EDCE513.recovery")
cleanup(fvek_file)
cleanup(recovery_file)
log = os.path.join("testdata", "swtpm-TPM", "dislocker-TPM.log")
vmk = os.path.join("testdata", "swtpm-TPM", "TPM-only.vmk")
print("\n\nTesting swtpm-TPM\n")
command = "python SPITkey.py -l " + log + " -k " + vmk
print(f"Command: {command}")
os.system(command)
recovery_key = "586784-333322-635690-264165-396374-216447-422653-402589"
fvek = "04801c8b7b0a3dd295948742aaf6c61920e25d7cbd7eb97471e54b2fd0819d0a2d010000000000000000000000000000000000000000000000000000000000000000"
dec_fvek = get_fvek(fvek_file)
if dec_fvek != fvek:
print("swtpm-TPM only FVEK did not decrypt correctly")
result = "failed"
dec_recovery = get_line(recovery_file)
if dec_recovery != recovery_key:
print("swtpm-TPM only Recovery key did not decrypt correctly")
result = "failed"
cleanup(fvek_file)
cleanup(recovery_file)
result_list = result_list + "swtpm-TPM only test " + result + "\n"
# -----------------------------------------------------------------------------
# Test swtpm-TPMandPIN
result = "passed"
fvek_file = os.path.join("testdata", "swtpm-TPMandPIN", "DESKTOP-GUUFK3H.fvek")
recovery_file = os.path.join("testdata", "swtpm-TPMandPIN", "39C2AA90-0CFA-4B77-9622-11A99EDCE513.recovery")
cleanup(fvek_file)
cleanup(recovery_file)
log = os.path.join("testdata", "swtpm-TPMandPIN", "dislocker-TPMandPIN.log")
blob = os.path.join("testdata", "swtpm-TPMandPIN", "TPMandPIN.blob")
print("\n\nTesting swtpm-TPMandPIN\n")
command = "python SPITkey.py -l " + log + " -t " + blob + " -p 87654321"
print(f"Command: {command}")
os.system(command)
recovery_key = "586784-333322-635690-264165-396374-216447-422653-402589"
fvek = "04801c8b7b0a3dd295948742aaf6c61920e25d7cbd7eb97471e54b2fd0819d0a2d010000000000000000000000000000000000000000000000000000000000000000"
dec_fvek = get_fvek(fvek_file)
if dec_fvek != fvek:
print("swtpm-TPMandPIN FVEK did not decrypt correctly")
result = "failed"
dec_recovery = get_line(recovery_file)
if dec_recovery != recovery_key:
print("swtpm-TPMandPIN Recovery key did not decrypt correctly")
result = "failed"
cleanup(fvek_file)
cleanup(recovery_file)
result_list = result_list + "swtpm-TPMandPIN test " + result + "\n"
# -----------------------------------------------------------------------------
# Test USB-KEY
result = "passed"
fvek_file = os.path.join("testdata", "USB-KEY", "DESKTOP-LBLPGHL.fvek")
recovery_file = os.path.join("testdata", "USB-KEY", "3CBE5E70-96FF-45BC-A609-1D38323006F0.recovery")
cleanup(fvek_file)
cleanup(recovery_file)
log = os.path.join("testdata", "USB-KEY", "dislocker-key.log")
bek = os.path.join("testdata", "USB-KEY", "108D1C23-D614-4DA1-910D-3D87C488833A.BEK")
print("\n\nTesting USB-KEY\n")
command = "python SPITkey.py -l " + log + " -b " + bek
print(f"Command: {command}")
os.system(command)
recovery_key = "203907-116314-114389-096954-364463-544236-500236-393580"
fvek = "0480c9fa9f7c8457890542b80d80b26abac96503f05d84ddca4fa8af2d9fe993dfd30000000000000000000000000000000000000000000000000000000000000000"
dec_fvek = get_fvek(fvek_file)
if dec_fvek != fvek:
print("USB-KEY FVEK did not decrypt correctly")
result = "failed"
dec_recovery = get_line(recovery_file)
if dec_recovery != recovery_key:
print("USB-KEY Recovery key did not decrypt correctly")
result = "failed"
cleanup(fvek_file)
cleanup(recovery_file)
result_list = result_list + "USB-KEY test " + result + "\n"
# -----------------------------------------------------------------------------
# Test RECOVERY
result = "passed"
fvek_file = os.path.join("testdata", "logic2-TPM", "DESKTOP-LBLPGHL.fvek")
cleanup(fvek_file)
log = os.path.join("testdata", "logic2-TPM", "dislocker-TPM.log")
recovery_key = os.path.join("testdata", "logic2-TPM", "BitLocker_Recovery_Key_38F91648-280E-4F3A-9772-640DCB48F4CE.TXT")
print("\n\nTesting RECOVERY\n")
command = "python SPITkey.py -l " + log + " -r " + recovery_key
print(f"Command: {command}")
os.system(command)
fvek = "0480c9fa9f7c8457890542b80d80b26abac96503f05d84ddca4fa8af2d9fe993dfd30000000000000000000000000000000000000000000000000000000000000000"
dec_fvek = get_fvek(fvek_file)
if dec_fvek != fvek:
print("RECOVERY FVEK did not decrypt correctly")
result = "failed"
cleanup(fvek_file)
result_list = result_list + "RECOVERY test " + result + "\n"
# -----------------------------------------------------------------------------
# Test PASSWORD
result = "passed"
fvek_file = os.path.join("testdata", "password", "en4rab.fvek")
recovery_file = os.path.join("testdata", "password", "92C7E8E2-CE52-4B7F-98A0-F48E218418BD.recovery")
cleanup(fvek_file)
cleanup(recovery_file)
log = os.path.join("testdata", "password", "dislocker-password.log")
password = "password"
print("\n\nTesting PASSWORD\n")
command = "python SPITkey.py -l " + log + " -p " + password
print(f"Command: {command}")
os.system(command)
recovery_key = "007942-637131-674355-218163-546744-283822-132561-640816"
fvek = "0280a8e351093c96c478e6d343ced27d6f95000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
dec_fvek = get_fvek(fvek_file)
if dec_fvek != fvek:
print("PASSWORD FVEK did not decrypt correctly")
result = "failed"
dec_recovery = get_line(recovery_file)
if dec_recovery != recovery_key:
print("USB-KEY Recovery key did not decrypt correctly")
result = "failed"
cleanup(fvek_file)
cleanup(recovery_file)
result_list = result_list + "PASSWORD test " + result + "\n"
print("\n\n")
print(result_list)