extract-msg 0.48.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- extract_msg/__init__.py +71 -0
- extract_msg/__main__.py +115 -0
- extract_msg/_rtf/__init__.py +21 -0
- extract_msg/_rtf/create_doc.py +29 -0
- extract_msg/_rtf/inject_rtf.py +174 -0
- extract_msg/_rtf/token.py +35 -0
- extract_msg/_rtf/tokenize_rtf.py +253 -0
- extract_msg/attachments/__init__.py +144 -0
- extract_msg/attachments/attachment.py +188 -0
- extract_msg/attachments/attachment_base.py +730 -0
- extract_msg/attachments/broken_att.py +42 -0
- extract_msg/attachments/custom_att.py +173 -0
- extract_msg/attachments/custom_att_handler/__init__.py +80 -0
- extract_msg/attachments/custom_att_handler/custom_handler.py +134 -0
- extract_msg/attachments/custom_att_handler/lnk_obj_att.py +109 -0
- extract_msg/attachments/custom_att_handler/outlook_image_dib.py +141 -0
- extract_msg/attachments/emb_msg_att.py +134 -0
- extract_msg/attachments/signed_att.py +234 -0
- extract_msg/attachments/unsupported_att.py +40 -0
- extract_msg/attachments/web_att.py +74 -0
- extract_msg/constants/__init__.py +294 -0
- extract_msg/constants/ps.py +46 -0
- extract_msg/constants/re.py +42 -0
- extract_msg/constants/st.py +110 -0
- extract_msg/data/logging-config/logging-nt.json +64 -0
- extract_msg/data/logging-config/logging-posix.json +64 -0
- extract_msg/encoding/__init__.py +277 -0
- extract_msg/encoding/_dt/__init__.py +4 -0
- extract_msg/encoding/_dt/_mac_ce.py +8 -0
- extract_msg/encoding/_dt/_mac_cyrillic.py +8 -0
- extract_msg/encoding/_dt/_mac_greek.py +8 -0
- extract_msg/encoding/_dt/_mac_iceland.py +8 -0
- extract_msg/encoding/_dt/_mac_turkish.py +8 -0
- extract_msg/encoding/_dt/_win874_dec.py +8 -0
- extract_msg/encoding/_dt/_win950_dec.py +6 -0
- extract_msg/encoding/utils.py +329 -0
- extract_msg/enums.py +2067 -0
- extract_msg/exceptions.py +170 -0
- extract_msg/msg_classes/__init__.py +49 -0
- extract_msg/msg_classes/appointment.py +195 -0
- extract_msg/msg_classes/calendar.py +92 -0
- extract_msg/msg_classes/calendar_base.py +496 -0
- extract_msg/msg_classes/contact.py +1335 -0
- extract_msg/msg_classes/journal.py +131 -0
- extract_msg/msg_classes/meeting_cancellation.py +108 -0
- extract_msg/msg_classes/meeting_exception.py +55 -0
- extract_msg/msg_classes/meeting_forward.py +115 -0
- extract_msg/msg_classes/meeting_related.py +65 -0
- extract_msg/msg_classes/meeting_request.py +189 -0
- extract_msg/msg_classes/meeting_response.py +74 -0
- extract_msg/msg_classes/message.py +12 -0
- extract_msg/msg_classes/message_base.py +1382 -0
- extract_msg/msg_classes/message_signed.py +17 -0
- extract_msg/msg_classes/message_signed_base.py +168 -0
- extract_msg/msg_classes/msg.py +1172 -0
- extract_msg/msg_classes/post.py +53 -0
- extract_msg/msg_classes/sticky_note.py +67 -0
- extract_msg/msg_classes/task.py +363 -0
- extract_msg/msg_classes/task_request.py +86 -0
- extract_msg/null_date.py +34 -0
- extract_msg/ole_writer.py +1086 -0
- extract_msg/open_msg.py +204 -0
- extract_msg/properties/__init__.py +23 -0
- extract_msg/properties/named.py +481 -0
- extract_msg/properties/prop.py +506 -0
- extract_msg/properties/properties_store.py +476 -0
- extract_msg/py.typed +0 -0
- extract_msg/recipient.py +362 -0
- extract_msg/structures/__init__.py +34 -0
- extract_msg/structures/_helpers.py +345 -0
- extract_msg/structures/business_card.py +422 -0
- extract_msg/structures/cfoas.py +108 -0
- extract_msg/structures/contact_link_entry.py +51 -0
- extract_msg/structures/dev_mode_a.py +621 -0
- extract_msg/structures/dv_target_device.py +168 -0
- extract_msg/structures/entry_id.py +697 -0
- extract_msg/structures/misc_id.py +222 -0
- extract_msg/structures/mon_stream.py +55 -0
- extract_msg/structures/odt.py +74 -0
- extract_msg/structures/ole_pres.py +302 -0
- extract_msg/structures/ole_stream_struct.py +117 -0
- extract_msg/structures/recurrence_pattern.py +199 -0
- extract_msg/structures/report_tag.py +127 -0
- extract_msg/structures/system_time.py +158 -0
- extract_msg/structures/time_zone_definition.py +111 -0
- extract_msg/structures/time_zone_struct.py +102 -0
- extract_msg/structures/toc_entry.py +137 -0
- extract_msg/structures/tz_rule.py +148 -0
- extract_msg/utils.py +1270 -0
- extract_msg-0.48.2.dist-info/LICENSE.txt +674 -0
- extract_msg-0.48.2.dist-info/METADATA +321 -0
- extract_msg-0.48.2.dist-info/RECORD +95 -0
- extract_msg-0.48.2.dist-info/WHEEL +5 -0
- extract_msg-0.48.2.dist-info/entry_points.txt +2 -0
- extract_msg-0.48.2.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
"""
|
|
2
|
+
The constants used in extract_msg. If you modify any of these without explicit
|
|
3
|
+
instruction to do so from one of the contributers, please do not complain about
|
|
4
|
+
bugs.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
__all__ = [
|
|
8
|
+
# Modules.
|
|
9
|
+
'ps',
|
|
10
|
+
're',
|
|
11
|
+
'st',
|
|
12
|
+
|
|
13
|
+
# Constants.
|
|
14
|
+
'DATE_FORMAT',
|
|
15
|
+
'DEFAULT_CLSID',
|
|
16
|
+
'DT_FORMAT',
|
|
17
|
+
'FIXED_LENGTH_PROPS',
|
|
18
|
+
'FIXED_LENGTH_PROPS_STRING',
|
|
19
|
+
'HEADER_FORMAT',
|
|
20
|
+
'HEADER_FORMAT_TYPE',
|
|
21
|
+
'HEADER_FORMAT_VALUE_TYPE',
|
|
22
|
+
'KNOWN_CLASS_TYPES',
|
|
23
|
+
'KNOWN_FILE_FLAGS',
|
|
24
|
+
'MAINDOC',
|
|
25
|
+
'MSG_PATH',
|
|
26
|
+
'MULTIPLE_16_BYTES',
|
|
27
|
+
'MULTIPLE_16_BYTES_HEX',
|
|
28
|
+
'MULTIPLE_2_BYTES',
|
|
29
|
+
'MULTIPLE_2_BYTES_HEX',
|
|
30
|
+
'MULTIPLE_4_BYTES',
|
|
31
|
+
'MULTIPLE_4_BYTES_HEX',
|
|
32
|
+
'MULTIPLE_8_BYTES',
|
|
33
|
+
'MULTIPLE_8_BYTES_HEX',
|
|
34
|
+
'NEEDS_ARG',
|
|
35
|
+
'NULL_DATE',
|
|
36
|
+
'PTYPES',
|
|
37
|
+
'PYTPFLOATINGTIME_START',
|
|
38
|
+
'REFUSED_CLASS_TYPES',
|
|
39
|
+
'REPOSITORY_URL',
|
|
40
|
+
'SAVE_TYPE',
|
|
41
|
+
'VARIABLE_LENGTH_PROPS',
|
|
42
|
+
'VARIABLE_LENGTH_PROPS_STRING',
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
from datetime import datetime
|
|
47
|
+
from typing import (
|
|
48
|
+
Any, Callable, Dict, Final, List, Optional, Tuple, Type, TypeVar, Union
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
from . import ps, re, st
|
|
52
|
+
from ..enums import SaveType
|
|
53
|
+
from ..null_date import NullDate
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
_T = TypeVar('_T')
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
# Constants for formating datetime objects.
|
|
60
|
+
DATE_FORMAT: Final[str] = '%d %B, %Y'
|
|
61
|
+
DT_FORMAT: Final[str] = '%a, %d %b %Y %H:%M:%S %z'
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
# Typing Constants.
|
|
65
|
+
HEADER_FORMAT_VALUE_TYPE = Union[str, Tuple[Union[str, None], bool], None]
|
|
66
|
+
# Basically a dict of HEADER_FORMAT_TYPE and dicts containing them.
|
|
67
|
+
HEADER_FORMAT_TYPE = Optional[Dict[str, Union[HEADER_FORMAT_VALUE_TYPE, Dict[str, HEADER_FORMAT_VALUE_TYPE]]]]
|
|
68
|
+
SAVE_TYPE = Tuple[SaveType, Union[List[str], str, None]]
|
|
69
|
+
MSG_PATH = Union[str, List[str], Tuple[str]]
|
|
70
|
+
# Type used for the getXAs methods' overrideClass argument.
|
|
71
|
+
OVERRIDE_CLASS = Union[Type[_T], Callable[[Any], _T]]
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
FIXED_LENGTH_PROPS: Final[Tuple[int, ...]] = (
|
|
75
|
+
0x0000,
|
|
76
|
+
0x0001,
|
|
77
|
+
0x0002,
|
|
78
|
+
0x0003,
|
|
79
|
+
0x0004,
|
|
80
|
+
0x0005,
|
|
81
|
+
0x0006,
|
|
82
|
+
0x0007,
|
|
83
|
+
0x000A,
|
|
84
|
+
0x000B,
|
|
85
|
+
0x0014,
|
|
86
|
+
0x0040,
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
FIXED_LENGTH_PROPS_STRING: Final[Tuple[str, ...]] = (
|
|
90
|
+
'0000',
|
|
91
|
+
'0001',
|
|
92
|
+
'0002',
|
|
93
|
+
'0003',
|
|
94
|
+
'0004',
|
|
95
|
+
'0005',
|
|
96
|
+
'0006',
|
|
97
|
+
'0007',
|
|
98
|
+
'000A',
|
|
99
|
+
'000B',
|
|
100
|
+
'0014',
|
|
101
|
+
'0040',
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
VARIABLE_LENGTH_PROPS: Final[Tuple[int, ...]] = (
|
|
105
|
+
0x000D,
|
|
106
|
+
0x001E,
|
|
107
|
+
0x001F,
|
|
108
|
+
0x0048,
|
|
109
|
+
0x00FB,
|
|
110
|
+
0x00FD,
|
|
111
|
+
0x00FE,
|
|
112
|
+
0X0102,
|
|
113
|
+
0x1002,
|
|
114
|
+
0x1003,
|
|
115
|
+
0x1004,
|
|
116
|
+
0x1005,
|
|
117
|
+
0x1006,
|
|
118
|
+
0x1007,
|
|
119
|
+
0x1014,
|
|
120
|
+
0x101E,
|
|
121
|
+
0x101F,
|
|
122
|
+
0x1040,
|
|
123
|
+
0x1048,
|
|
124
|
+
0x1102,
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
VARIABLE_LENGTH_PROPS_STRING: Final[Tuple[str, ...]] = (
|
|
128
|
+
'000D',
|
|
129
|
+
'001E',
|
|
130
|
+
'001F',
|
|
131
|
+
'0048',
|
|
132
|
+
'00FB',
|
|
133
|
+
'00FD',
|
|
134
|
+
'00FE',
|
|
135
|
+
'0102',
|
|
136
|
+
'1002',
|
|
137
|
+
'1003',
|
|
138
|
+
'1004',
|
|
139
|
+
'1005',
|
|
140
|
+
'1006',
|
|
141
|
+
'1007',
|
|
142
|
+
'1014',
|
|
143
|
+
'101E',
|
|
144
|
+
'101F',
|
|
145
|
+
'1040',
|
|
146
|
+
'1048',
|
|
147
|
+
'1102',
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
# Multiple type properties that take up 2 bytes.
|
|
151
|
+
MULTIPLE_2_BYTES: Final[Tuple[str, ...]] = (
|
|
152
|
+
'1002',
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
MULTIPLE_2_BYTES_HEX: Final[Tuple[int, ...]] = (
|
|
156
|
+
0x1002,
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
# Multiple type properties that take up 4 bytes.
|
|
160
|
+
MULTIPLE_4_BYTES: Final[Tuple[str, ...]] = (
|
|
161
|
+
'1003',
|
|
162
|
+
'1004',
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
MULTIPLE_4_BYTES_HEX: Final[Tuple[int, ...]] = (
|
|
166
|
+
0x1003,
|
|
167
|
+
0x1004,
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
# Multiple type properties that take up 8 bytes.
|
|
171
|
+
MULTIPLE_8_BYTES: Final[Tuple[str, ...]] = (
|
|
172
|
+
'1005',
|
|
173
|
+
'1006',
|
|
174
|
+
'1007',
|
|
175
|
+
'1014',
|
|
176
|
+
'1040',
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
MULTIPLE_8_BYTES_HEX: Final[Tuple[int, ...]] = (
|
|
180
|
+
0x1005,
|
|
181
|
+
0x1006,
|
|
182
|
+
0x1007,
|
|
183
|
+
0x1014,
|
|
184
|
+
0x1040,
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
# Multiple type properties that take up 16 bytes.
|
|
188
|
+
MULTIPLE_16_BYTES: Final[Tuple[str, ...]] = (
|
|
189
|
+
'1048',
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
MULTIPLE_16_BYTES_HEX: Final[Tuple[int, ...]] = (
|
|
193
|
+
0x1048,
|
|
194
|
+
)
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
# Used to format the header for saving only the header.
|
|
198
|
+
HEADER_FORMAT: Final[str] = """From: {From}
|
|
199
|
+
To: {To}
|
|
200
|
+
Cc: {Cc}
|
|
201
|
+
Bcc: {Bcc}
|
|
202
|
+
Subject: {subject}
|
|
203
|
+
Date: {Date}
|
|
204
|
+
Message-ID: {Message-Id}
|
|
205
|
+
"""
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
KNOWN_CLASS_TYPES: Final[Tuple[str, ...]] = (
|
|
209
|
+
'ipm.activity',
|
|
210
|
+
'ipm.appointment', # [MS-OXOCAL]
|
|
211
|
+
'ipm.contact', # [MS-OXOCNTC]
|
|
212
|
+
'ipm.configuration', # [MS-OXOCFG]
|
|
213
|
+
'ipm.distlist',
|
|
214
|
+
'ipm.document',
|
|
215
|
+
'ipm.ole.class',
|
|
216
|
+
'ipm.outlook.recall',
|
|
217
|
+
'ipm.note',
|
|
218
|
+
'ipm.post',
|
|
219
|
+
'ipm.stickynote',
|
|
220
|
+
'ipm.recall.report',
|
|
221
|
+
'ipm.remote',
|
|
222
|
+
'ipm.report',
|
|
223
|
+
'ipm.resend',
|
|
224
|
+
'ipm.schedule',
|
|
225
|
+
'ipm.task',
|
|
226
|
+
'ipm.taskrequest',
|
|
227
|
+
'report',
|
|
228
|
+
)
|
|
229
|
+
|
|
230
|
+
# Each item is a tuple of the lowercase class type and the issue number
|
|
231
|
+
# associated with it.
|
|
232
|
+
REFUSED_CLASS_TYPES: Final[Tuple[Tuple[str, str], ...]] = (
|
|
233
|
+
('ipm.outlook.recall', '235'),
|
|
234
|
+
)
|
|
235
|
+
|
|
236
|
+
PYTPFLOATINGTIME_START: Final[datetime] = datetime(1899, 12, 30)
|
|
237
|
+
# Do modifications before assigning to the constant.
|
|
238
|
+
_tmp = NullDate(4500, 8, 31, 23, 59)
|
|
239
|
+
_tmp.filetime = 915046235400000000
|
|
240
|
+
NULL_DATE: Final[NullDate] = _tmp
|
|
241
|
+
|
|
242
|
+
# Constants used for argparse stuff.
|
|
243
|
+
KNOWN_FILE_FLAGS: Final[Tuple[str, ...]] = (
|
|
244
|
+
'--out-name',
|
|
245
|
+
)
|
|
246
|
+
NEEDS_ARG: Final[Tuple[str, ...]]= (
|
|
247
|
+
'--out-name',
|
|
248
|
+
)
|
|
249
|
+
REPOSITORY_URL: Final[str] = 'https://github.com/TeamMsgExtractor/msg-extractor'
|
|
250
|
+
MAINDOC: Final[str] = f"""extract_msg:
|
|
251
|
+
\tExtracts emails and attachments saved in Microsoft Outlook's .msg files.
|
|
252
|
+
|
|
253
|
+
{REPOSITORY_URL}"""
|
|
254
|
+
|
|
255
|
+
# Default class ID for the root entry for OleWriter. This should be
|
|
256
|
+
# referencing Outlook if I understand it correctly.
|
|
257
|
+
DEFAULT_CLSID: Final[bytes] = b'\x0b\r\x02\x00\x00\x00\x00\x00\xc0\x00\x00\x00\x00\x00\x00F'
|
|
258
|
+
|
|
259
|
+
PTYPES: Final[Dict[int, str]]= {
|
|
260
|
+
0x0000: 'PtypUnspecified',
|
|
261
|
+
0x0001: 'PtypNull',
|
|
262
|
+
0x0002: 'PtypInteger16', # Signed short.
|
|
263
|
+
0x0003: 'PtypInteger32', # Signed int.
|
|
264
|
+
0x0004: 'PtypFloating32', # Float.
|
|
265
|
+
0x0005: 'PtypFloating64', # Double.
|
|
266
|
+
0x0006: 'PtypCurrency',
|
|
267
|
+
0x0007: 'PtypFloatingTime',
|
|
268
|
+
0x000A: 'PtypErrorCode',
|
|
269
|
+
0x000B: 'PtypBoolean',
|
|
270
|
+
0x000D: 'PtypObject/PtypEmbeddedTable/Storage',
|
|
271
|
+
0x0014: 'PtypInteger64', # Signed longlong.
|
|
272
|
+
0x001E: 'PtypString8',
|
|
273
|
+
0x001F: 'PtypString',
|
|
274
|
+
0x0040: 'PtypTime', # Use filetimeToUtc to convert to unix time stamp.
|
|
275
|
+
0x0048: 'PtypGuid',
|
|
276
|
+
0x00FB: 'PtypServerId',
|
|
277
|
+
0x00FD: 'PtypRestriction',
|
|
278
|
+
0x00FE: 'PtypRuleAction',
|
|
279
|
+
0x0102: 'PtypBinary',
|
|
280
|
+
0x1002: 'PtypMultipleInteger16',
|
|
281
|
+
0x1003: 'PtypMultipleInteger32',
|
|
282
|
+
0x1004: 'PtypMultipleFloating32',
|
|
283
|
+
0x1005: 'PtypMultipleFloating64',
|
|
284
|
+
0x1006: 'PtypMultipleCurrency',
|
|
285
|
+
0x1007: 'PtypMultipleFloatingTime',
|
|
286
|
+
0x1014: 'PtypMultipleInteger64',
|
|
287
|
+
0x101E: 'PtypMultipleString8',
|
|
288
|
+
0x101F: 'PtypMultipleString',
|
|
289
|
+
0x1040: 'PtypMultipleTime',
|
|
290
|
+
0x1048: 'PtypMultipleGuid',
|
|
291
|
+
0x1102: 'PtypMultipleBinary',
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
# END CONSTANTS.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Property set identifier constants.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
__all__ = [
|
|
6
|
+
'PSETID_ADDRESS',
|
|
7
|
+
'PSETID_AIRSYNC',
|
|
8
|
+
'PSETID_APPOINTMENT',
|
|
9
|
+
'PSETID_ATTACHMENT',
|
|
10
|
+
'PSETID_CALENDAR_ASSISTANT',
|
|
11
|
+
'PSETID_COMMON',
|
|
12
|
+
'PSETID_LOG',
|
|
13
|
+
'PSETID_MEETING',
|
|
14
|
+
'PSETID_MESSAGING',
|
|
15
|
+
'PSETID_NOTE',
|
|
16
|
+
'PSETID_POSTRSS',
|
|
17
|
+
'PSETID_SHARING',
|
|
18
|
+
'PSETID_TASK',
|
|
19
|
+
'PSETID_UNIFIEDMESSAGING',
|
|
20
|
+
'PSETID_XMLEXTRACTEDENTITIES',
|
|
21
|
+
'PS_INTERNET_HEADERS',
|
|
22
|
+
'PS_MAPI',
|
|
23
|
+
'PS_PUBLIC_STRINGS',
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
from typing import Final
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
PS_MAPI: Final[str] = '{00020328-0000-0000-C000-000000000046}'
|
|
30
|
+
PS_PUBLIC_STRINGS: Final[str] = '{00020329-0000-0000-C000-000000000046}'
|
|
31
|
+
PSETID_COMMON: Final[str] = '{00062008-0000-0000-C000-000000000046}'
|
|
32
|
+
PSETID_ADDRESS: Final[str] = '{00062004-0000-0000-C000-000000000046}'
|
|
33
|
+
PS_INTERNET_HEADERS: Final[str] = '{00020386-0000-0000-C000-000000000046}'
|
|
34
|
+
PSETID_APPOINTMENT: Final[str] = '{00062002-0000-0000-C000-000000000046}'
|
|
35
|
+
PSETID_MEETING: Final[str] = '{6ED8DA90-450B-101B-98DA-00AA003F1305}'
|
|
36
|
+
PSETID_LOG: Final[str] = '{0006200A-0000-0000-C000-000000000046}'
|
|
37
|
+
PSETID_MESSAGING: Final[str] = '{41F28F13-83F4-4114-A584-EEDB5A6B0BFF}'
|
|
38
|
+
PSETID_NOTE: Final[str] = '{0006200E-0000-0000-C000-000000000046}'
|
|
39
|
+
PSETID_POSTRSS: Final[str] = '{00062041-0000-0000-C000-000000000046}'
|
|
40
|
+
PSETID_TASK: Final[str] = '{00062003-0000-0000-C000-000000000046}'
|
|
41
|
+
PSETID_UNIFIEDMESSAGING: Final[str] = '{4442858E-A9E3-4E80-B900-317A210CC15B}'
|
|
42
|
+
PSETID_AIRSYNC: Final[str] = '{71035549-0739-4DCB-9163-00F0580DBBDF}'
|
|
43
|
+
PSETID_SHARING: Final[str] = '{00062040-0000-0000-C000-000000000046}'
|
|
44
|
+
PSETID_XMLEXTRACTEDENTITIES: Final[str] = '{23239608-685D-4732-9C55-4C95CB4E8E33}'
|
|
45
|
+
PSETID_ATTACHMENT: Final[str] = '{96357F7F-59E1-47D0-99A7-46515C183B54}'
|
|
46
|
+
PSETID_CALENDAR_ASSISTANT: Final[str] = '{11000E07-B51B-40D6-AF21-CAA85EDAB1D0}'
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Regular expression constants.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
__all__ = [
|
|
7
|
+
'HTML_BODY_START',
|
|
8
|
+
'HTML_SAN_SPACE',
|
|
9
|
+
'INVALID_FILENAME_CHARS',
|
|
10
|
+
'INVALID_OLE_PATH',
|
|
11
|
+
'RTF_ENC_BODY_START',
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
import re
|
|
16
|
+
|
|
17
|
+
from typing import Final
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
# Allow better typing in versions above 3.8.
|
|
21
|
+
import sys
|
|
22
|
+
if sys.version_info >= (3, 9):
|
|
23
|
+
_RE_STR_TYPE = re.Pattern[str]
|
|
24
|
+
_RE_BYTES_TYPE = re.Pattern[bytes]
|
|
25
|
+
else:
|
|
26
|
+
_RE_STR_TYPE = re.Pattern
|
|
27
|
+
_RE_BYTES_TYPE = re.Pattern
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
# Characters that are invalid in a filename.
|
|
31
|
+
INVALID_FILENAME_CHARS: Final[_RE_STR_TYPE] = re.compile(r'[\\/:*?"<>|]')
|
|
32
|
+
# Regular expression to find sections of spaces for htmlSanitize.
|
|
33
|
+
HTML_SAN_SPACE: Final[_RE_STR_TYPE] = re.compile(' +')
|
|
34
|
+
# Regular expression to find the start of the html body.
|
|
35
|
+
HTML_BODY_START: Final[_RE_BYTES_TYPE] = re.compile(b'<body[^>]*>')
|
|
36
|
+
# Regular expression to find the start of the html body in encapsulated RTF.
|
|
37
|
+
# This is used for one of the pattern types that makes life easy.
|
|
38
|
+
RTF_ENC_BODY_START: Final[_RE_BYTES_TYPE] = re.compile(br'\{\\\*\\htmltag[0-9]* ?<body[^>]*>\}')
|
|
39
|
+
# Used in the vaildation of OLE paths. Any of these characters in a name make it
|
|
40
|
+
# invalid.
|
|
41
|
+
INVALID_OLE_PATH: Final[_RE_STR_TYPE] = re.compile(r'[:/\\!]')
|
|
42
|
+
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Struct constants.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
__all__ = [
|
|
6
|
+
'ST_BC_FIELD_INFO',
|
|
7
|
+
'ST_BC_HEAD',
|
|
8
|
+
'ST_BE_F32',
|
|
9
|
+
'ST_BE_F64',
|
|
10
|
+
'ST_BE_I16',
|
|
11
|
+
'ST_BE_I32',
|
|
12
|
+
'ST_BE_I64',
|
|
13
|
+
'ST_BE_I8',
|
|
14
|
+
'ST_BE_UI16',
|
|
15
|
+
'ST_BE_UI32',
|
|
16
|
+
'ST_BE_UI64',
|
|
17
|
+
'ST_BE_UI8',
|
|
18
|
+
'ST_CF_DIR_ENTRY',
|
|
19
|
+
'ST_GUID',
|
|
20
|
+
'ST_LE_F32',
|
|
21
|
+
'ST_LE_F64',
|
|
22
|
+
'ST_LE_I16',
|
|
23
|
+
'ST_LE_I32',
|
|
24
|
+
'ST_LE_I64',
|
|
25
|
+
'ST_LE_I8',
|
|
26
|
+
'ST_LE_UI16',
|
|
27
|
+
'ST_LE_UI32',
|
|
28
|
+
'ST_LE_UI64',
|
|
29
|
+
'ST_LE_UI8',
|
|
30
|
+
'ST_NP_ENT',
|
|
31
|
+
'ST_PEID',
|
|
32
|
+
'ST_PROP_BASE',
|
|
33
|
+
'ST_PROP_VAR',
|
|
34
|
+
'ST_PROPSTORE_HEADER',
|
|
35
|
+
'ST_RGB',
|
|
36
|
+
'ST_SBO_I8',
|
|
37
|
+
'ST_SBO_I16',
|
|
38
|
+
'ST_SBO_I32',
|
|
39
|
+
'ST_SBO_I64',
|
|
40
|
+
'ST_SBO_UI8',
|
|
41
|
+
'ST_SBO_UI16',
|
|
42
|
+
'ST_SBO_UI32',
|
|
43
|
+
'ST_SBO_UI64',
|
|
44
|
+
'ST_SYSTEMTIME',
|
|
45
|
+
'ST_TZ',
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
import struct
|
|
50
|
+
|
|
51
|
+
from typing import Final
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
# Define pre-compiled structs to make unpacking slightly faster.
|
|
55
|
+
# General structs.
|
|
56
|
+
ST_PROPSTORE_HEADER: Final[struct.Struct] = struct.Struct('<8x4I')
|
|
57
|
+
ST_PROP_BASE: Final[struct.Struct] = struct.Struct('<2HI')
|
|
58
|
+
# Struct used for unpacking a system time.
|
|
59
|
+
ST_SYSTEMTIME: Final[struct.Struct] = struct.Struct('<8H')
|
|
60
|
+
# Struct used for unpacking a GUID from bytes.
|
|
61
|
+
ST_GUID: Final[struct.Struct] = struct.Struct('<IHH8s')
|
|
62
|
+
# Struct for unpacking a TimeZoneStruct from bytes.
|
|
63
|
+
ST_TZ: Final[struct.Struct] = struct.Struct('<iiiH16sH16s')
|
|
64
|
+
# Struct for packing a compount file directory entry.
|
|
65
|
+
ST_CF_DIR_ENTRY: Final[struct.Struct] = struct.Struct('<64sHBBIII16sIQQIQ')
|
|
66
|
+
# Struct used for unpacking the entries in the entry stream
|
|
67
|
+
ST_NP_ENT: Final[struct.Struct] = struct.Struct('<IHH')
|
|
68
|
+
# Structs used by prop.py
|
|
69
|
+
ST_PROP_VAR: Final[struct.Struct] = struct.Struct('<2I')
|
|
70
|
+
# PermanentEntryID parsing struct
|
|
71
|
+
ST_PEID: Final[struct.Struct] = struct.Struct('<B3x16s4xI')
|
|
72
|
+
# Struct for unpacking the first part of the BusinessCardDisplayDefinition
|
|
73
|
+
# structure.
|
|
74
|
+
ST_BC_HEAD: Final[struct.Struct] = struct.Struct('BBBBBBBBBBBxB')
|
|
75
|
+
# Struct for completely unpacking the FieldInfo structure.
|
|
76
|
+
ST_BC_FIELD_INFO: Final[struct.Struct] = struct.Struct('HBBBxHBBBxBBBx')
|
|
77
|
+
# Structs for parsing basic types.
|
|
78
|
+
ST_LE_I8: Final[struct.Struct] = struct.Struct('<b')
|
|
79
|
+
ST_LE_I16: Final[struct.Struct] = struct.Struct('<h')
|
|
80
|
+
ST_LE_I32: Final[struct.Struct] = struct.Struct('<i')
|
|
81
|
+
ST_LE_I64: Final[struct.Struct] = struct.Struct('<q')
|
|
82
|
+
ST_LE_UI8: Final[struct.Struct] = struct.Struct('<B')
|
|
83
|
+
ST_LE_UI16: Final[struct.Struct] = struct.Struct('<H')
|
|
84
|
+
ST_LE_UI32: Final[struct.Struct] = struct.Struct('<I')
|
|
85
|
+
ST_LE_UI64: Final[struct.Struct] = struct.Struct('<Q')
|
|
86
|
+
ST_LE_F32: Final[struct.Struct] = struct.Struct('<f')
|
|
87
|
+
ST_LE_F64: Final[struct.Struct] = struct.Struct('<d')
|
|
88
|
+
ST_BE_I8: Final[struct.Struct] = struct.Struct('>b')
|
|
89
|
+
ST_BE_I16: Final[struct.Struct] = struct.Struct('>h')
|
|
90
|
+
ST_BE_I32: Final[struct.Struct] = struct.Struct('>i')
|
|
91
|
+
ST_BE_I64: Final[struct.Struct] = struct.Struct('>q')
|
|
92
|
+
ST_BE_UI8: Final[struct.Struct] = struct.Struct('>B')
|
|
93
|
+
ST_BE_UI16: Final[struct.Struct] = struct.Struct('>H')
|
|
94
|
+
ST_BE_UI32: Final[struct.Struct] = struct.Struct('>I')
|
|
95
|
+
ST_BE_UI64: Final[struct.Struct] = struct.Struct('>Q')
|
|
96
|
+
ST_BE_F32: Final[struct.Struct] = struct.Struct('>f')
|
|
97
|
+
ST_BE_F64: Final[struct.Struct] = struct.Struct('>d')
|
|
98
|
+
# Structs that use the system byte order, where consistency on a single system
|
|
99
|
+
# is all that matters. Mainly used for quick casts between signed and unsigned.
|
|
100
|
+
ST_SBO_I8: Final[struct.Struct] = struct.Struct('@b')
|
|
101
|
+
ST_SBO_I16: Final[struct.Struct] = struct.Struct('@h')
|
|
102
|
+
ST_SBO_I32: Final[struct.Struct] = struct.Struct('@i')
|
|
103
|
+
ST_SBO_I64: Final[struct.Struct] = struct.Struct('@q')
|
|
104
|
+
ST_SBO_UI8: Final[struct.Struct] = struct.Struct('@B')
|
|
105
|
+
ST_SBO_UI16: Final[struct.Struct] = struct.Struct('@H')
|
|
106
|
+
ST_SBO_UI32: Final[struct.Struct] = struct.Struct('@I')
|
|
107
|
+
ST_SBO_UI64: Final[struct.Struct] = struct.Struct('@Q')
|
|
108
|
+
# Struct for an RGB value that, in little endian, would be an int written in hex
|
|
109
|
+
# as 0x00BBGGRR.
|
|
110
|
+
ST_RGB: Final[struct.Struct] = struct.Struct('<BBBx')
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"disable_existing_loggers": false,
|
|
4
|
+
"formatters": {
|
|
5
|
+
"simple": {
|
|
6
|
+
"format": "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
|
|
7
|
+
}
|
|
8
|
+
},
|
|
9
|
+
"handlers": {
|
|
10
|
+
"console": {
|
|
11
|
+
"class": "logging.StreamHandler",
|
|
12
|
+
"level": "DEBUG",
|
|
13
|
+
"formatter": "simple",
|
|
14
|
+
"stream": "ext://sys.stdout"
|
|
15
|
+
},
|
|
16
|
+
"info_file_handler": {
|
|
17
|
+
"class": "logging.handlers.RotatingFileHandler",
|
|
18
|
+
"level": "INFO",
|
|
19
|
+
"formatter": "simple",
|
|
20
|
+
"filename": "%LOCALAPPDATA%/extract_msg/extract_msg.log",
|
|
21
|
+
"maxBytes": 10485760,
|
|
22
|
+
"backupCount": 20,
|
|
23
|
+
"encoding": "utf8"
|
|
24
|
+
},
|
|
25
|
+
"error_file_handler": {
|
|
26
|
+
"class": "logging.handlers.RotatingFileHandler",
|
|
27
|
+
"level": "ERROR",
|
|
28
|
+
"formatter": "simple",
|
|
29
|
+
"filename": "%LOCALAPPDATA%/extract_msg/extract_msg.log",
|
|
30
|
+
"maxBytes": 10485760,
|
|
31
|
+
"backupCount": 20,
|
|
32
|
+
"encoding": "utf8"
|
|
33
|
+
},
|
|
34
|
+
"warning_file_handler": {
|
|
35
|
+
"class": "logging.handlers.RotatingFileHandler",
|
|
36
|
+
"level": "WARNING",
|
|
37
|
+
"formatter": "simple",
|
|
38
|
+
"filename": "%LOCALAPPDATA%/extract_msg/extract_msg.log",
|
|
39
|
+
"maxBytes": 10485760,
|
|
40
|
+
"backupCount": 20,
|
|
41
|
+
"encoding": "utf8"
|
|
42
|
+
},
|
|
43
|
+
"developer_file_handler": {
|
|
44
|
+
"class": "logging.handlers.RotatingFileHandler",
|
|
45
|
+
"level": "DEVELOPER",
|
|
46
|
+
"formatter": "simple",
|
|
47
|
+
"filename": "%LOCALAPPDATA%/extract_msg/extract_msg.log",
|
|
48
|
+
"maxBytes": 10485760,
|
|
49
|
+
"backupCount": 20,
|
|
50
|
+
"encoding": "utf8"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"loggers": {
|
|
54
|
+
"my_module": {
|
|
55
|
+
"level": "ERROR",
|
|
56
|
+
"handlers": ["console"],
|
|
57
|
+
"propagate": "no"
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"root": {
|
|
61
|
+
"level": "DEVELOPER",
|
|
62
|
+
"handlers": ["console", "info_file_handler", "error_file_handler", "warning_file_handler", "developer_file_handler"]
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"disable_existing_loggers": false,
|
|
4
|
+
"formatters": {
|
|
5
|
+
"simple": {
|
|
6
|
+
"format": "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
|
|
7
|
+
}
|
|
8
|
+
},
|
|
9
|
+
"handlers": {
|
|
10
|
+
"console": {
|
|
11
|
+
"class": "logging.StreamHandler",
|
|
12
|
+
"level": "DEBUG",
|
|
13
|
+
"formatter": "simple",
|
|
14
|
+
"stream": "ext://sys.stdout"
|
|
15
|
+
},
|
|
16
|
+
"info_file_handler": {
|
|
17
|
+
"class": "logging.handlers.RotatingFileHandler",
|
|
18
|
+
"level": "INFO",
|
|
19
|
+
"formatter": "simple",
|
|
20
|
+
"filename": "/var/log/extract_msg/extract_msg.log",
|
|
21
|
+
"maxBytes": 10485760,
|
|
22
|
+
"backupCount": 20,
|
|
23
|
+
"encoding": "utf8"
|
|
24
|
+
},
|
|
25
|
+
"error_file_handler": {
|
|
26
|
+
"class": "logging.handlers.RotatingFileHandler",
|
|
27
|
+
"level": "ERROR",
|
|
28
|
+
"formatter": "simple",
|
|
29
|
+
"filename": "/var/log/extract_msg/extract_msg.log",
|
|
30
|
+
"maxBytes": 10485760,
|
|
31
|
+
"backupCount": 20,
|
|
32
|
+
"encoding": "utf8"
|
|
33
|
+
},
|
|
34
|
+
"warning_file_handler": {
|
|
35
|
+
"class": "logging.handlers.RotatingFileHandler",
|
|
36
|
+
"level": "WARNING",
|
|
37
|
+
"formatter": "simple",
|
|
38
|
+
"filename": "/var/log/extract_msg/extract_msg.log",
|
|
39
|
+
"maxBytes": 10485760,
|
|
40
|
+
"backupCount": 20,
|
|
41
|
+
"encoding": "utf8"
|
|
42
|
+
},
|
|
43
|
+
"developer_file_handler": {
|
|
44
|
+
"class": "logging.handlers.RotatingFileHandler",
|
|
45
|
+
"level": "DEVELOPER",
|
|
46
|
+
"formatter": "simple",
|
|
47
|
+
"filename": "/var/log/extract_msg/extract_msg.log",
|
|
48
|
+
"maxBytes": 10485760,
|
|
49
|
+
"backupCount": 20,
|
|
50
|
+
"encoding": "utf8"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"loggers": {
|
|
54
|
+
"my_module": {
|
|
55
|
+
"level": "ERROR",
|
|
56
|
+
"handlers": ["console"],
|
|
57
|
+
"propagate": "no"
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"root": {
|
|
61
|
+
"level": "DEVELOPER",
|
|
62
|
+
"handlers": ["console", "info_file_handler", "error_file_handler", "warning_file_handler", "developer_file_handler"]
|
|
63
|
+
}
|
|
64
|
+
}
|