forked from n0fate/chainbreaker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.py
495 lines (415 loc) · 17.8 KB
/
schema.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
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
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
from struct import Struct
from datetime import datetime
# http://web.mit.edu/darwin/src/modules/Security/cdsa/cdsa/cssmtype.h
KEY_TYPE = {
0x00 + 0x0F: 'CSSM_KEYCLASS_PUBLIC_KEY',
0x01 + 0x0F: 'CSSM_KEYCLASS_PRIVATE_KEY',
0x02 + 0x0F: 'CSSM_KEYCLASS_SESSION_KEY',
0x03 + 0x0F: 'CSSM_KEYCLASS_SECRET_PART',
0xFFFFFFFF: 'CSSM_KEYCLASS_OTHER'
}
CSSM_ALGORITHMS = {
0: 'CSSM_ALGID_NONE',
1: 'CSSM_ALGID_CUSTOM',
2: 'CSSM_ALGID_DH',
3: 'CSSM_ALGID_PH',
4: 'CSSM_ALGID_KEA',
5: 'CSSM_ALGID_MD2',
6: 'CSSM_ALGID_MD4',
7: 'CSSM_ALGID_MD5',
8: 'CSSM_ALGID_SHA1',
9: 'CSSM_ALGID_NHASH',
10: 'CSSM_ALGID_HAVAL:',
11: 'CSSM_ALGID_RIPEMD',
12: 'CSSM_ALGID_IBCHASH',
13: 'CSSM_ALGID_RIPEMAC',
14: 'CSSM_ALGID_DES',
15: 'CSSM_ALGID_DESX',
16: 'CSSM_ALGID_RDES',
17: 'CSSM_ALGID_3DES_3KEY_EDE',
18: 'CSSM_ALGID_3DES_2KEY_EDE',
19: 'CSSM_ALGID_3DES_1KEY_EEE',
20: 'CSSM_ALGID_3DES_3KEY_EEE',
21: 'CSSM_ALGID_3DES_2KEY_EEE',
22: 'CSSM_ALGID_IDEA',
23: 'CSSM_ALGID_RC2',
24: 'CSSM_ALGID_RC5',
25: 'CSSM_ALGID_RC4',
26: 'CSSM_ALGID_SEAL',
27: 'CSSM_ALGID_CAST',
28: 'CSSM_ALGID_BLOWFISH',
29: 'CSSM_ALGID_SKIPJACK',
30: 'CSSM_ALGID_LUCIFER',
31: 'CSSM_ALGID_MADRYGA',
32: 'CSSM_ALGID_FEAL',
33: 'CSSM_ALGID_REDOC',
34: 'CSSM_ALGID_REDOC3',
35: 'CSSM_ALGID_LOKI',
36: 'CSSM_ALGID_KHUFU',
37: 'CSSM_ALGID_KHAFRE',
38: 'CSSM_ALGID_MMB',
39: 'CSSM_ALGID_GOST',
40: 'CSSM_ALGID_SAFER',
41: 'CSSM_ALGID_CRAB',
42: 'CSSM_ALGID_RSA',
43: 'CSSM_ALGID_DSA',
44: 'CSSM_ALGID_MD5WithRSA',
45: 'CSSM_ALGID_MD2WithRSA',
46: 'CSSM_ALGID_ElGamal',
47: 'CSSM_ALGID_MD2Random',
48: 'CSSM_ALGID_MD5Random',
49: 'CSSM_ALGID_SHARandom',
50: 'CSSM_ALGID_DESRandom',
51: 'CSSM_ALGID_SHA1WithRSA',
52: 'CSSM_ALGID_CDMF',
53: 'CSSM_ALGID_CAST3',
54: 'CSSM_ALGID_CAST5',
55: 'CSSM_ALGID_GenericSecret',
56: 'CSSM_ALGID_ConcatBaseAndKey',
57: 'CSSM_ALGID_ConcatKeyAndBase',
58: 'CSSM_ALGID_ConcatBaseAndData',
59: 'CSSM_ALGID_ConcatDataAndBase',
60: 'CSSM_ALGID_XORBaseAndData',
61: 'CSSM_ALGID_ExtractFromKey',
62: 'CSSM_ALGID_SSL3PreMasterGen',
63: 'CSSM_ALGID_SSL3MasterDerive',
64: 'CSSM_ALGID_SSL3KeyAndMacDerive',
65: 'CSSM_ALGID_SSL3MD5_MAC',
66: 'CSSM_ALGID_SSL3SHA1_MAC',
67: 'CSSM_ALGID_PKCS5_PBKDF1_MD5',
68: 'CSSM_ALGID_PKCS5_PBKDF1_MD2',
69: 'CSSM_ALGID_PKCS5_PBKDF1_SHA1',
70: 'CSSM_ALGID_WrapLynks',
71: 'CSSM_ALGID_WrapSET_OAEP',
72: 'CSSM_ALGID_BATON',
73: 'CSSM_ALGID_ECDSA',
74: 'CSSM_ALGID_MAYFLY',
75: 'CSSM_ALGID_JUNIPER',
76: 'CSSM_ALGID_FASTHASH',
77: 'CSSM_ALGID_3DES',
78: 'CSSM_ALGID_SSL3MD5',
79: 'CSSM_ALGID_SSL3SHA1',
80: 'CSSM_ALGID_FortezzaTimestamp',
81: 'CSSM_ALGID_SHA1WithDSA',
82: 'CSSM_ALGID_SHA1WithECDSA',
83: 'CSSM_ALGID_DSA_BSAFE',
84: 'CSSM_ALGID_ECDH',
85: 'CSSM_ALGID_ECMQV',
86: 'CSSM_ALGID_PKCS12_SHA1_PBE',
87: 'CSSM_ALGID_ECNRA',
88: 'CSSM_ALGID_SHA1WithECNRA',
89: 'CSSM_ALGID_ECES',
90: 'CSSM_ALGID_ECAES',
91: 'CSSM_ALGID_SHA1HMAC',
92: 'CSSM_ALGID_FIPS186Random',
93: 'CSSM_ALGID_ECC',
94: 'CSSM_ALGID_MQV',
95: 'CSSM_ALGID_NRA',
96: 'CSSM_ALGID_IntelPlatformRandom',
97: 'CSSM_ALGID_UTC',
98: 'CSSM_ALGID_HAVAL3',
99: 'CSSM_ALGID_HAVAL4',
100: 'CSSM_ALGID_HAVAL5',
101: 'CSSM_ALGID_TIGER',
102: 'CSSM_ALGID_MD5HMAC',
103: 'CSSM_ALGID_PKCS5_PBKDF2',
104: 'CSSM_ALGID_RUNNING_COUNTER',
0x7FFFFFFF: 'CSSM_ALGID_LAST'
}
# CSSM TYPE
## http://www.opensource.apple.com/source/libsecurity_cssm/libsecurity_cssm-36064/lib/cssmtype.h
########## CSSM_DB_RECORDTYPE #############
# /* Industry At Large Application Name Space Range Definition */
# /* AppleFileDL record types. */
CSSM_DB_RECORDTYPE_APP_DEFINED_START = 0x80000000
CSSM_DL_DB_RECORD_GENERIC_PASSWORD = CSSM_DB_RECORDTYPE_APP_DEFINED_START + 0
CSSM_DL_DB_RECORD_INTERNET_PASSWORD = CSSM_DB_RECORDTYPE_APP_DEFINED_START + 1
CSSM_DL_DB_RECORD_APPLESHARE_PASSWORD = CSSM_DB_RECORDTYPE_APP_DEFINED_START + 2
CSSM_DL_DB_RECORD_USER_TRUST = CSSM_DB_RECORDTYPE_APP_DEFINED_START + 3
CSSM_DL_DB_RECORD_X509_CRL = CSSM_DB_RECORDTYPE_APP_DEFINED_START + 4
CSSM_DL_DB_RECORD_UNLOCK_REFERRAL = CSSM_DB_RECORDTYPE_APP_DEFINED_START + 5
CSSM_DL_DB_RECORD_EXTENDED_ATTRIBUTE = CSSM_DB_RECORDTYPE_APP_DEFINED_START + 6
CSSM_DL_DB_RECORD_X509_CERTIFICATE = CSSM_DB_RECORDTYPE_APP_DEFINED_START + 0x1000
CSSM_DL_DB_RECORD_METADATA = CSSM_DB_RECORDTYPE_APP_DEFINED_START + 0x8000 ## DBBlob
CSSM_DB_RECORDTYPE_APP_DEFINED_END = 0xffffffff
# /* Record Types defined in the Schema Management Name Space */
CSSM_DB_RECORDTYPE_SCHEMA_START = 0x00000000
CSSM_DL_DB_SCHEMA_INFO = CSSM_DB_RECORDTYPE_SCHEMA_START + 0
CSSM_DL_DB_SCHEMA_INDEXES = CSSM_DB_RECORDTYPE_SCHEMA_START + 1
CSSM_DL_DB_SCHEMA_ATTRIBUTES = CSSM_DB_RECORDTYPE_SCHEMA_START + 2
CSSM_DL_DB_SCHEMA_PARSING_MODULE = CSSM_DB_RECORDTYPE_SCHEMA_START + 3
CSSM_DB_RECORDTYPE_SCHEMA_END = CSSM_DB_RECORDTYPE_SCHEMA_START + 4
# /* Record Types defined in the Open Group Application Name Space */
# /* Open Group Application Name Space Range Definition*/
CSSM_DB_RECORDTYPE_OPEN_GROUP_START = 0x0000000A
CSSM_DL_DB_RECORD_ANY = CSSM_DB_RECORDTYPE_OPEN_GROUP_START + 0
CSSM_DL_DB_RECORD_CERT = CSSM_DB_RECORDTYPE_OPEN_GROUP_START + 1
CSSM_DL_DB_RECORD_CRL = CSSM_DB_RECORDTYPE_OPEN_GROUP_START + 2
CSSM_DL_DB_RECORD_POLICY = CSSM_DB_RECORDTYPE_OPEN_GROUP_START + 3
CSSM_DL_DB_RECORD_GENERIC = CSSM_DB_RECORDTYPE_OPEN_GROUP_START + 4
CSSM_DL_DB_RECORD_PUBLIC_KEY = CSSM_DB_RECORDTYPE_OPEN_GROUP_START + 5
CSSM_DL_DB_RECORD_PRIVATE_KEY = CSSM_DB_RECORDTYPE_OPEN_GROUP_START + 6
CSSM_DL_DB_RECORD_SYMMETRIC_KEY = CSSM_DB_RECORDTYPE_OPEN_GROUP_START + 7
CSSM_DL_DB_RECORD_ALL_KEYS = CSSM_DB_RECORDTYPE_OPEN_GROUP_START + 8
CSSM_DB_RECORDTYPE_OPEN_GROUP_END = CSSM_DB_RECORDTYPE_OPEN_GROUP_START + 8
#####################
######## KEYUSE #########
CSSM_KEYUSE_ANY = 0x80000000
CSSM_KEYUSE_ENCRYPT = 0x00000001
CSSM_KEYUSE_DECRYPT = 0x00000002
CSSM_KEYUSE_SIGN = 0x00000004
CSSM_KEYUSE_VERIFY = 0x00000008
CSSM_KEYUSE_SIGN_RECOVER = 0x00000010
CSSM_KEYUSE_VERIFY_RECOVER = 0x00000020
CSSM_KEYUSE_WRAP = 0x00000040
CSSM_KEYUSE_UNWRAP = 0x00000080
CSSM_KEYUSE_DERIVE = 0x00000100
####################
############ CERT TYPE ##############
CERT_TYPE = {
0x00: 'CSSM_CERT_UNKNOWN',
0x01: 'CSSM_CERT_X_509v1',
0x02: 'CSSM_CERT_X_509v2',
0x03: 'CSSM_CERT_X_509v3',
0x04: 'CSSM_CERT_PGP',
0x05: 'CSSM_CERT_SPKI',
0x06: 'CSSM_CERT_SDSIv1',
0x08: 'CSSM_CERT_Intel',
0x09: 'CSSM_CERT_X_509_ATTRIBUTE',
0x0A: 'CSSM_CERT_X9_ATTRIBUTE',
0x0C: 'CSSM_CERT_ACL_ENTRY',
0x7FFE: 'CSSM_CERT_MULTIPLE',
0x7FFF: 'CSSM_CERT_LAST',
0x8000: 'CSSM_CL_CUSTOM_CERT_TYPE'
}
####################################
########### CERT ENCODING #############
CERT_ENCODING = {
0x00: 'CSSM_CERT_ENCODING_UNKNOWN',
0x01: 'CSSM_CERT_ENCODING_CUSTOM',
0x02: 'CSSM_CERT_ENCODING_BER',
0x03: 'CSSM_CERT_ENCODING_DER',
0x04: 'CSSM_CERT_ENCODING_NDR',
0x05: 'CSSM_CERT_ENCODING_SEXPR',
0x06: 'CSSM_CERT_ENCODING_PGP',
0x7FFE: 'CSSM_CERT_ENCODING_MULTIPLE',
0x7FFF: 'CSSM_CERT_ENCODING_LAST'
}
STD_APPLE_ADDIN_MODULE = {
'{87191ca0-0fc9-11d4-849a-000502b52122}': 'CSSM itself',
'{87191ca1-0fc9-11d4-849a-000502b52122}': 'File based DL (aka "Keychain DL")',
'{87191ca2-0fc9-11d4-849a-000502b52122}': 'Core CSP (local space)',
'{87191ca3-0fc9-11d4-849a-000502b52122}': 'Secure CSP/DL (aka "Keychain CSPDL")',
'{87191ca4-0fc9-11d4-849a-000502b52122}': 'X509 Certificate CL',
'{87191ca5-0fc9-11d4-849a-000502b52122}': 'X509 Certificate TP',
'{87191ca6-0fc9-11d4-849a-000502b52122}': 'DLAP/OpenDirectory access DL',
'{87191ca7-0fc9-11d4-849a-000502b52122}': 'TP for ".mac" related policies',
'{87191ca8-0fc9-11d4-849a-000502b52122}': 'Smartcard CSP/DL',
'{87191ca9-0fc9-11d4-849a-000502b52122}': 'DL for ".mac" certificate access'
}
SECURE_STORAGE_GROUP = 'ssgp'
# SecAuthenticationType
AUTH_TYPE = {
'ntlm': 'kSecAuthenticationTypeNTLM',
'msna': 'kSecAuthenticationTypeMSN',
'dpaa': 'kSecAuthenticationTypeDPA',
'rpaa': 'kSecAuthenticationTypeRPA',
'http': 'kSecAuthenticationTypeHTTPBasic',
'httd': 'kSecAuthenticationTypeHTTPDigest',
'form': 'kSecAuthenticationTypeHTMLForm',
'dflt': 'kSecAuthenticationTypeDefault',
'': 'kSecAuthenticationTypeAny',
'\x00\x00\x00\x00': 'kSecAuthenticationTypeAny'
}
# SecProtocolType
PROTOCOL_TYPE = {
'ftp ': 'kSecProtocolTypeFTP',
'ftpa': 'kSecProtocolTypeFTPAccount',
'http': 'kSecProtocolTypeHTTP',
'irc ': 'kSecProtocolTypeIRC',
'nntp': 'kSecProtocolTypeNNTP',
'pop3': 'kSecProtocolTypePOP3',
'smtp': 'kSecProtocolTypeSMTP',
'sox ': 'kSecProtocolTypeSOCKS',
'imap': 'kSecProtocolTypeIMAP',
'ldap': 'kSecProtocolTypeLDAP',
'atlk': 'kSecProtocolTypeAppleTalk',
'afp ': 'kSecProtocolTypeAFP',
'teln': 'kSecProtocolTypeTelnet',
'ssh ': 'kSecProtocolTypeSSH',
'ftps': 'kSecProtocolTypeFTPS',
'htps': 'kSecProtocolTypeHTTPS',
'htpx': 'kSecProtocolTypeHTTPProxy',
'htsx': 'kSecProtocolTypeHTTPSProxy',
'ftpx': 'kSecProtocolTypeFTPProxy',
'cifs': 'kSecProtocolTypeCIFS',
'smb ': 'kSecProtocolTypeSMB',
'rtsp': 'kSecProtocolTypeRTSP',
'rtsx': 'kSecProtocolTypeRTSPProxy',
'daap': 'kSecProtocolTypeDAAP',
'eppc': 'kSecProtocolTypeEPPC',
'ipp ': 'kSecProtocolTypeIPP',
'ntps': 'kSecProtocolTypeNNTPS',
'ldps': 'kSecProtocolTypeLDAPS',
'tels': 'kSecProtocolTypeTelnetS',
'imps': 'kSecProtocolTypeIMAPS',
'ircs': 'kSecProtocolTypeIRCS',
'pops': 'kSecProtocolTypePOP3S',
'cvsp': 'kSecProtocolTypeCVSpserver',
'svn ': 'kSecProtocolTypeCVSpserver',
'AdIM': 'kSecProtocolTypeAdiumMessenger',
'\x00\x00\x00\x00': 'kSecProtocolTypeAny'
}
# This is somewhat gross: we define a bunch of module-level constants based on
# the SecKeychainItem.h defines (FourCharCodes) by passing them through
# struct.unpack and converting them to ctypes.c_long() since we'll never use
# them for non-native APIs
CARBON_DEFINES = {
'cdat': 'kSecCreationDateItemAttr',
'mdat': 'kSecModDateItemAttr',
'desc': 'kSecDescriptionItemAttr',
'icmt': 'kSecCommentItemAttr',
'crtr': 'kSecCreatorItemAttr',
'type': 'kSecTypeItemAttr',
'scrp': 'kSecScriptCodeItemAttr',
'labl': 'kSecLabelItemAttr',
'invi': 'kSecInvisibleItemAttr',
'nega': 'kSecNegativeItemAttr',
'cusi': 'kSecCustomIconItemAttr',
'acct': 'kSecAccountItemAttr',
'svce': 'kSecServiceItemAttr',
'gena': 'kSecGenericItemAttr',
'sdmn': 'kSecSecurityDomainItemAttr',
'srvr': 'kSecServerItemAttr',
'atyp': 'kSecAuthenticationTypeItemAttr',
'port': 'kSecPortItemAttr',
'path': 'kSecPathItemAttr',
'vlme': 'kSecVolumeItemAttr',
'addr': 'kSecAddressItemAttr',
'ssig': 'kSecSignatureItemAttr',
'ptcl': 'kSecProtocolItemAttr',
'ctyp': 'kSecCertificateType',
'cenc': 'kSecCertificateEncoding',
'crtp': 'kSecCrlType',
'crnc': 'kSecCrlEncoding',
'alis': 'kSecAlias',
'inet': 'kSecInternetPasswordItemClass',
'genp': 'kSecGenericPasswordItemClass',
'ashp': 'kSecAppleSharePasswordItemClass',
CSSM_DL_DB_RECORD_X509_CERTIFICATE: 'kSecCertificateItemClass'
}
class _APPL_DB_HEADER(object):
STRUCT = Struct('> 4s i i i i')
def __init__(self, buffer):
(self.Signature, self.Version, self.HeaderSize, self.SchemaOffset,
self.AuthOffset) = _APPL_DB_HEADER.STRUCT.unpack(
buffer)
class _APPL_DB_SCHEMA(object):
STRUCT = Struct('> i i')
def __init__(self, buffer):
(self.SchemaSize, self.TableCount) = _APPL_DB_SCHEMA.STRUCT.unpack(buffer)
class _TABLE_HEADER(object):
STRUCT = Struct('> I I I I I I I')
def __init__(self, buffer):
(self.TableSize, self.TableId, self.RecordCount, self.Records, self.IndexesOffset, self.FreeListHead,
self.RecordNumbersCount) = _TABLE_HEADER.STRUCT.unpack(buffer)
class _DB_BLOB(object):
STRUCT = Struct('> 8s I I 16s I 8s 20s 8s 20s')
def __init__(self, buffer):
(self.CommonBlobBuffer, self.StartCryptoBlob, self.TotalLength, self.RandomSignature, self.Sequence,
self.ParamsBuffer, self.Salt, self.IV, self.BlobSignature) = _DB_BLOB.STRUCT.unpack(buffer)
self.CommonBlob = _COMMON_BLOB(self.CommonBlobBuffer)
self.Params = _DB_PARAMETERS(self.ParamsBuffer)
class _COMMON_BLOB(object):
STRUCT = Struct('> L l')
def __init__(self, buffer):
(self.Magic, self.BlobVersion) = _COMMON_BLOB.STRUCT.unpack(buffer)
class _DB_PARAMETERS(object):
STRUCT = Struct('> I I')
def __init__(self, buffer):
(self.IdleTimeout, self.LockOnSleep) = _DB_PARAMETERS.STRUCT.unpack(buffer)
class _GENERIC_PW_HEADER(object):
STRUCT = Struct('> I I I I I I I I I I I I I I I I I I I I I I')
def __init__(self, buffer):
(self.RecordSize, self.RecordNumber, self.Unknown2, self.Unknown3, self.SSGPArea, self.Unknown5,
self.CreationDate, self.ModDate, self.Description, self.Comment, self.Creator, self.Type, self.ScriptCode,
self.PrintName, self.Alias, self.Invisible, self.Negative, self.CustomIcon, self.Protected, self.Account,
self.Service, self.Generic,) = _GENERIC_PW_HEADER.STRUCT.unpack(buffer)
class _KEY_BLOB_REC_HEADER(object):
STRUCT = Struct('> I I 124s ')
def __init__(self, buffer):
(self.RecordSize, self.RecordCount, self.Dummy) = _KEY_BLOB_REC_HEADER.STRUCT.unpack(buffer)
class _KEY_BLOB(object):
STRUCT = Struct('> 8s I I 8s')
COMMON_BLOB_MAGIC = 0xFADE0711
def __init__(self, buffer):
(self.CommonBlobBuffer, self.StartCryptoBlob, self.TotalLength, self.IV,) = _KEY_BLOB.STRUCT.unpack(buffer)
self.CommonBlob = _COMMON_BLOB(self.CommonBlobBuffer)
# First 28 bytes are structured - remainder is our encrypted password.
class _SSGP(object):
STRUCT = Struct('> 4s 16s 8s')
def __init__(self, buffer):
(self.Magic, self.Label, self.IV,) = _SSGP.STRUCT.unpack(buffer[:28])
self.EncryptedPassword = buffer[28:]
class _INTERNET_PW_HEADER(object):
STRUCT = Struct('> I I I I I I I I I I I I I I I I I I I I I I I I I I')
def __init__(self, buffer):
(self.RecordSize, self.RecordNumber, self.Unknown2, self.Unknown3, self.SSGPArea, self.Unknown5,
self.CreationDate, self.ModDate, self.Description, self.Comment, self.Creator, self.Type, self.ScriptCode,
self.PrintName, self.Alias, self.Invisible, self.Negative, self.CustomIcon, self.Protected, self.Account,
self.SecurityDomain, self.Server, self.Protocol, self.AuthType, self.Port,
self.Path,) = _INTERNET_PW_HEADER.STRUCT.unpack(buffer)
class _APPLE_SHARE_HEADER(object):
STRUCT = Struct('> I I I I I I I I I I I I I I I I I I I I I I I I I I')
def __init__(self, buffer):
(self.RecordSize, self.RecordNumber, self.Unknown2, self.Unknown3, self.SSGPArea, self.Unknown5,
self.CreationDate, self.ModDate, self.Description, self.Comment, self.Creator, self.Type, self.ScriptCode,
self.PrintName, self.Alias, self.Invisible, self.Negative, self.CustomIcon, self.Protected, self.Account,
self.Volume, self.Server, self.Protocol, self.AuthType, self.Address,
self.Signature,) = _APPLE_SHARE_HEADER.STRUCT.unpack(buffer)
class _X509_CERT_HEADER(object):
STRUCT = Struct('> I I I I I I I I I I I I I I I')
def __init__(self, buffer):
(self.RecordSize, self.RecordNumber, self.Unknown1, self.Unknown2, self.CertSize, self.Unknown3, self.CertType,
self.CertEncoding, self.PrintName, self.Alias, self.Subject, self.Issuer, self.SerialNumber,
self.SubjectKeyIdentifier, self.PublicKeyHash,) = _X509_CERT_HEADER.STRUCT.unpack(buffer)
# # http://www.opensource.apple.com/source/Security/Security-55179.1/include/security_cdsa_utilities/KeySchema.h
# # http://www.opensource.apple.com/source/libsecurity_keychain/libsecurity_keychain-36940/lib/SecKey.h
class _SECKEY_HEADER(object):
STRUCT = Struct('> I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I')
def __init__(self, buffer):
(self.RecordSize, self.RecordNumber, self.Unknown1, self.Unknown2, self.BlobSize, self.Unknown3, self.KeyClass,
self.PrintName, self.Alias, self.Permanent, self.Private, self.Modifiable, self.Label, self.ApplicationTag,
self.KeyCreator, self.KeyType, self.KeySizeInBits, self.EffectiveKeySize, self.StartDate, self.EndDate,
self.Sensitive, self.AlwaysSensitive, self.Extractable, self.NeverExtractable, self.Encrypt, self.Decrypt,
self.Derive, self.Sign, self.Verify, self.SignRecover, self.VerifyRecover, self.Wrap,
self.UnWrap,) = _SECKEY_HEADER.STRUCT.unpack(buffer)
class _UNLOCK_BLOB(object):
STRUCT = Struct('> 8s 24s 16s')
def __init__(self, buffer):
(self.CommonBlobBuffer, self.MasterKey, self.BlobSignature) = _UNLOCK_BLOB.STRUCT.unpack(buffer)
self.CommonBlob = _COMMON_BLOB(self.CommonBlobBuffer)
class _KEYCHAIN_TIME(object):
STRUCT = Struct('>16s')
STRPTIME_FORMAT = "%Y%m%d%H%M%SZ"
def __init__(self, buffer):
self.Value = _KEYCHAIN_TIME.STRUCT.unpack(buffer)[0].strip('\x00')
self.Time = datetime.strptime(self.Value, _KEYCHAIN_TIME.STRPTIME_FORMAT)
def __repr__(self):
return
class _INT(object):
STRUCT = Struct('>I')
def __init__(self, buffer):
self.Value = _INT.STRUCT.unpack(buffer)[0]
class _FOUR_CHAR_CODE(object):
STRUCT = Struct('>4s')
def __init__(self, buffer):
self.Value = _FOUR_CHAR_CODE.STRUCT.unpack(buffer)[0]
class _LV(object):
def __init__(self, buffer, length):
self.STRUCT = Struct(">" + str(length) + "s")
self.Value = self.STRUCT.unpack(buffer)[0].strip('\x00')
class _RECORD_OFFSET(_INT):
pass
class _TABLE_ID(_INT):
pass