-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathtest_decrypt_fvek.py
More file actions
138 lines (126 loc) · 1.96 KB
/
Copy pathtest_decrypt_fvek.py
File metadata and controls
138 lines (126 loc) · 1.96 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
# /usr/bin/env python
# Author Dario Clavijo 2020
# GPlv3
# bitlocker fvek decryptor
# based on https://pulsesecurity.co.nz/articles/TPM-sniffing
from Cryptodome.Cipher import AES
import binascii
encrypted_fvek = [
0xFB,
0xD6,
0x5F,
0x50,
0xE3,
0x82,
0x92,
0x60,
0x71,
0x16,
0x5C,
0x7A,
0x4B,
0xD3,
0xA9,
0x92,
0xA3,
0x94,
0xFF,
0x09,
0xED,
0xBC,
0x6B,
0xFB,
0x16,
0xCC,
0x2E,
0x08,
0xEE,
0x25,
0x57,
0x95,
0xE9,
0x7B,
0x83,
0x8B,
0x8D,
0x6F,
0xCD,
0x0E,
0x06,
0xE9,
0x5C,
0x54,
]
mac = [
0xDC,
0x5F,
0x42,
0x12,
0x9A,
0x4C,
0x5F,
0xD5,
0x12,
0x97,
0xE3,
0x15,
0x9B,
0x83,
0x10,
0x56,
]
nonce = [0xB0, 0xB2, 0xFB, 0x7C, 0xB4, 0xC6, 0xD4, 0x01, 0x0F, 0x00, 0x00, 0x00]
vmk = [
0x9A,
0x12,
0x61,
0x46,
0xB5,
0xB2,
0x85,
0xC9,
0x3F,
0x7C,
0x4B,
0xCD,
0x37,
0x2F,
0x91,
0xD0,
0x18,
0x1F,
0xE7,
0xED,
0xDC,
0x44,
0xE5,
0x88,
0x45,
0x9E,
0xBD,
0xB2,
0x44,
0xD9,
0x7B,
0xAA,
]
def arr_to_bin(array_alpha):
return binascii.unhexlify("".join("{:02x}".format(x) for x in array_alpha))
key = arr_to_bin(vmk)
ciphertext = arr_to_bin(encrypted_fvek)
nonce = arr_to_bin(nonce)
mac = arr_to_bin(mac)
print(("vmk:", binascii.hexlify(key)))
print(("encrypted_fvek:", binascii.hexlify(ciphertext)))
print(("nonce:", binascii.hexlify(nonce)))
print(("mac:", binascii.hexlify(mac)))
cipher = AES.new(key, AES.MODE_CCM, nonce)
# cipher.update(hdr)
plaintext = cipher.decrypt(ciphertext)
try:
cipher.verify(mac)
# print ("The message is authentic: hdr=%s, pt=%s" % (hdr, plaintext))
print("Description OK")
print(("plaintext fvek:", binascii.hexlify(plaintext)))
except ValueError:
print("Key incorrect or message corrupted")