linear-mcp-fast 0.1.0__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.
Files changed (39) hide show
  1. ccl_chromium_reader/__init__.py +2 -0
  2. ccl_chromium_reader/ccl_chromium_cache.py +1335 -0
  3. ccl_chromium_reader/ccl_chromium_filesystem.py +302 -0
  4. ccl_chromium_reader/ccl_chromium_history.py +357 -0
  5. ccl_chromium_reader/ccl_chromium_indexeddb.py +1060 -0
  6. ccl_chromium_reader/ccl_chromium_localstorage.py +454 -0
  7. ccl_chromium_reader/ccl_chromium_notifications.py +268 -0
  8. ccl_chromium_reader/ccl_chromium_profile_folder.py +568 -0
  9. ccl_chromium_reader/ccl_chromium_sessionstorage.py +368 -0
  10. ccl_chromium_reader/ccl_chromium_snss2.py +332 -0
  11. ccl_chromium_reader/ccl_shared_proto_db_downloads.py +189 -0
  12. ccl_chromium_reader/common.py +19 -0
  13. ccl_chromium_reader/download_common.py +78 -0
  14. ccl_chromium_reader/profile_folder_protocols.py +276 -0
  15. ccl_chromium_reader/serialization_formats/__init__.py +0 -0
  16. ccl_chromium_reader/serialization_formats/ccl_blink_value_deserializer.py +401 -0
  17. ccl_chromium_reader/serialization_formats/ccl_easy_chromium_pickle.py +133 -0
  18. ccl_chromium_reader/serialization_formats/ccl_protobuff.py +276 -0
  19. ccl_chromium_reader/serialization_formats/ccl_v8_value_deserializer.py +627 -0
  20. ccl_chromium_reader/storage_formats/__init__.py +0 -0
  21. ccl_chromium_reader/storage_formats/ccl_leveldb.py +582 -0
  22. ccl_simplesnappy/__init__.py +1 -0
  23. ccl_simplesnappy/ccl_simplesnappy.py +306 -0
  24. linear_mcp_fast/__init__.py +8 -0
  25. linear_mcp_fast/__main__.py +6 -0
  26. linear_mcp_fast/reader.py +433 -0
  27. linear_mcp_fast/server.py +367 -0
  28. linear_mcp_fast/store_detector.py +117 -0
  29. linear_mcp_fast-0.1.0.dist-info/METADATA +160 -0
  30. linear_mcp_fast-0.1.0.dist-info/RECORD +39 -0
  31. linear_mcp_fast-0.1.0.dist-info/WHEEL +5 -0
  32. linear_mcp_fast-0.1.0.dist-info/entry_points.txt +2 -0
  33. linear_mcp_fast-0.1.0.dist-info/top_level.txt +4 -0
  34. tools_and_utilities/Chromium_dump_local_storage.py +111 -0
  35. tools_and_utilities/Chromium_dump_session_storage.py +92 -0
  36. tools_and_utilities/benchmark.py +35 -0
  37. tools_and_utilities/ccl_chrome_audit.py +651 -0
  38. tools_and_utilities/dump_indexeddb_details.py +59 -0
  39. tools_and_utilities/dump_leveldb.py +53 -0
@@ -0,0 +1,276 @@
1
+ """
2
+ Copyright 2022, CCL Forensics
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
5
+ this software and associated documentation files (the "Software"), to deal in
6
+ the Software without restriction, including without limitation the rights to
7
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
8
+ of the Software, and to permit persons to whom the Software is furnished to do
9
+ so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ SOFTWARE.
21
+ """
22
+
23
+ import sys
24
+ import struct
25
+ import io
26
+ import typing
27
+
28
+ __version__ = "0.8"
29
+ __description__ = "Module for naive parsing of Protocol Buffers"
30
+ __contact__ = "Alex Caithness"
31
+
32
+ DEBUG = False
33
+
34
+
35
+ class Empty:
36
+ value = None
37
+
38
+
39
+ class ProtoObject:
40
+ def __init__(self, tag, name, value):
41
+ self.tag = tag
42
+ self.name = name
43
+ self.value = value
44
+ self.wire = tag & 0x07
45
+
46
+ def __str__(self):
47
+ if self.name:
48
+ return "{0} ({1}): {2}".format(
49
+ self.tag if self.tag > 0x7f else hex(self.tag), self.name, repr(self.value))
50
+ else:
51
+ return "{0}: {1}".format(
52
+ self.tag if self.tag > 0x7f else hex(self.tag), repr(self.value))
53
+ __repr__ = __str__
54
+
55
+ @property
56
+ def friendly_tag(self) -> int:
57
+ """:return the "real" tag (i.e. the one that would be seen inside the .proto schema)"""
58
+ return self.tag >> 3
59
+
60
+ def get_items_by_tag(self, tag_id: int) -> list[typing.Any]:
61
+ """
62
+ :param tag_id: the tag id for the child items
63
+ :return: list of child items with this tag number
64
+ """
65
+ if not isinstance(self.value, list):
66
+ raise ValueError("This object does not support child items")
67
+ if not isinstance(tag_id, int):
68
+ raise TypeError("Expected type: int; actual type: {0}".format(type(tag_id)))
69
+ return [x for x in self.value if x.tag == tag_id]
70
+
71
+ def get_items_by_name(self, name: str) -> list[typing.Any]:
72
+ """
73
+ :param name: the field name for the child items
74
+ :return: list of child items with this name
75
+ """
76
+ if not isinstance(self.value, list):
77
+ raise ValueError("This object does not support child items")
78
+ if not isinstance(name, str):
79
+ raise TypeError("Expected type: str; actual type: {0}".format(type(name)))
80
+ return [x for x in self.value if x.name == name]
81
+
82
+ def only(self, name: str, default=Empty):
83
+ """
84
+ Returns a single item which matches the name parameter. Use this to streamline getting non-repeating items
85
+ :param name: the name of the child item
86
+ :param default: optional: the value to return if the item is not present (default: None)
87
+ :return: the single child item
88
+ :exception: ValueError: if there is more than one child item which matches this name
89
+ """
90
+ got = self.get_items_by_name(name)
91
+ if len(got) == 0:
92
+ return default
93
+ elif len(got) == 1:
94
+ return got[0]
95
+ else:
96
+ raise ValueError("More than one value with this key")
97
+
98
+ def __getitem__(self, key: typing.Union[str, int]) -> list[typing.Any]:
99
+ if isinstance(key, str):
100
+ return self.get_items_by_name(key)
101
+ elif isinstance(key, int):
102
+ return self.get_items_by_tag(key)
103
+ else:
104
+ raise TypeError("Key should be int or str; actual type: {0}".format(type(key)))
105
+
106
+ def __len__(self) -> int:
107
+ return self.value.__len__()
108
+
109
+ def __iter__(self):
110
+ if not isinstance(self.value, list):
111
+ raise ValueError("This object does not support child items")
112
+ else:
113
+ yield from (x.tag for x in self.value)
114
+
115
+
116
+ class ProtoDecoder:
117
+ def __init__(self, object_name, func):
118
+ self.func = func
119
+ self.object_name = object_name
120
+
121
+ def __call__(self, arg):
122
+ return self.func(arg)
123
+
124
+
125
+ def _read_le_varint(stream: typing.BinaryIO, is_32bit=False) -> typing.Optional[typing.Tuple[int, bytes]]:
126
+ # this only outputs unsigned
127
+ limit = 5 if is_32bit else 10
128
+ i = 0
129
+ result = 0
130
+ underlying_bytes = []
131
+ while i < limit: # 64 bit max possible?
132
+ raw = stream.read(1)
133
+ if len(raw) < 1:
134
+ return None
135
+ tmp, = raw
136
+ underlying_bytes.append(tmp)
137
+ result |= ((tmp & 0x7f) << (i * 7))
138
+ if (tmp & 0x80) == 0:
139
+ break
140
+ i += 1
141
+ return result, bytes(underlying_bytes)
142
+
143
+
144
+ def read_le_varint(stream: typing.BinaryIO, is_32bit=False) -> typing.Optional[int]:
145
+ x = _read_le_varint(stream, is_32bit)
146
+ if x is None:
147
+ return None
148
+ else:
149
+ return x[0]
150
+
151
+
152
+ def read_le_varint32(stream: typing.BinaryIO) -> typing.Optional[int]:
153
+ return read_le_varint(stream, True)
154
+
155
+
156
+ def read_tag(
157
+ stream: typing.BinaryIO,
158
+ tag_mappings: dict[int, typing.Callable[[typing.BinaryIO], typing.Any]],
159
+ log_out=sys.stderr, use_friendly_tag=False) -> typing.Optional[ProtoObject]:
160
+ tag_id = read_le_varint(stream)
161
+ if tag_id is None:
162
+ return None
163
+ decoder = tag_mappings.get(tag_id if not use_friendly_tag else tag_id >> 3)
164
+ name = None
165
+ if isinstance(decoder, ProtoDecoder):
166
+ name = decoder.object_name
167
+
168
+ available_wirebytes = io.BytesIO(_get_bytes_for_wiretype(tag_id, stream))
169
+
170
+ tag_value = decoder(available_wirebytes) if decoder else _fallback_decode(
171
+ tag_id, available_wirebytes, log_out)
172
+
173
+ return ProtoObject(tag_id, name, tag_value)
174
+
175
+
176
+ def read_protobuff(
177
+ stream: typing.BinaryIO,
178
+ tag_mappings: dict [int, typing.Callable[[typing.BinaryIO], typing.Any]],
179
+ use_friendly_tag=False) -> list[ProtoObject]:
180
+ result = []
181
+ while True:
182
+ tag = read_tag(stream, tag_mappings, use_friendly_tag=use_friendly_tag)
183
+ if tag is None:
184
+ break
185
+ result.append(tag)
186
+
187
+ return result
188
+
189
+
190
+ def read_blob(stream: typing.BinaryIO) -> bytes:
191
+ blob_length = read_le_varint(stream)
192
+ blob = stream.read(blob_length)
193
+ return blob
194
+
195
+
196
+ def read_string(stream: typing.BinaryIO) -> str:
197
+ raw_string = read_blob(stream)
198
+ string = raw_string.decode("utf-8")
199
+ return string
200
+
201
+
202
+ def read_double(stream: typing.BinaryIO) -> float:
203
+ return struct.unpack("<d", stream.read(8))[0]
204
+
205
+
206
+ def read_long(stream: typing.BinaryIO) -> int:
207
+ return struct.unpack("<q", stream.read(8))[0]
208
+
209
+
210
+ def read_int(stream: typing.BinaryIO) -> int:
211
+ return struct.unpack("<i", stream.read(4))[0]
212
+
213
+
214
+ def read_embedded_protobuf(stream: typing.BinaryIO, mappings, use_friendly_tag=False) -> list[ProtoObject]:
215
+ blob_blob = read_blob(stream)
216
+ blob_stream = io.BytesIO(blob_blob)
217
+ return read_protobuff(blob_stream, mappings, use_friendly_tag)
218
+
219
+
220
+ def read_fixed_blob(stream: typing.BinaryIO, length: int) -> bytes:
221
+ data = stream.read(length)
222
+ if len(data) != length:
223
+ raise ValueError("Couldn't read enough data")
224
+ return data
225
+
226
+
227
+ _fallback_wire_types = {
228
+ 0: read_le_varint,
229
+ 1: lambda x: read_fixed_blob(x, 8),
230
+ 2: read_blob,
231
+ 5: lambda x: read_fixed_blob(x, 4)
232
+ }
233
+
234
+ _wire_type_friendly_names = {
235
+ 0: "Varint",
236
+ 1: "64-Bit",
237
+ 2: "Length Delimited",
238
+ 5: "32-Bit"
239
+ }
240
+
241
+
242
+ def _get_bytes_for_wiretype(tag_id: int, stream: typing.BinaryIO):
243
+ wire_type = tag_id & 0x07
244
+ if wire_type == 0:
245
+ read_bytes = []
246
+ for i in range(10):
247
+ x = stream.read(1)[0]
248
+ read_bytes.append(x)
249
+ if x & 0x80 == 0:
250
+ break
251
+ buffer = bytes(read_bytes)
252
+ elif wire_type == 1:
253
+ buffer = stream.read(8)
254
+ elif wire_type == 2:
255
+ l, b = _read_le_varint(stream)
256
+ available_bytes = stream.read(l)
257
+ if len(available_bytes) < l:
258
+ raise ValueError("Stream too short")
259
+ buffer = b + available_bytes
260
+ elif wire_type == 5:
261
+ buffer = stream.read(4)
262
+ else:
263
+ raise ValueError("Invalid wiretype")
264
+
265
+ return buffer
266
+
267
+
268
+ def _fallback_decode(tag_id, stream, log):
269
+ fallback_func = _fallback_wire_types.get(tag_id & 0x07)
270
+ if not fallback_func:
271
+ raise ValueError("No appropriate fallback function for tag {0} (wire type {1})".format(
272
+ tag_id, tag_id & 0x07))
273
+ if DEBUG:
274
+ log.write("Tag {0} ({1}) not defined, using fallback decoding.\n".format(
275
+ tag_id if tag_id > 0x7f else hex(tag_id), _wire_type_friendly_names[tag_id & 0x07]))
276
+ return fallback_func(stream)