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.
- ccl_chromium_reader/__init__.py +2 -0
- ccl_chromium_reader/ccl_chromium_cache.py +1335 -0
- ccl_chromium_reader/ccl_chromium_filesystem.py +302 -0
- ccl_chromium_reader/ccl_chromium_history.py +357 -0
- ccl_chromium_reader/ccl_chromium_indexeddb.py +1060 -0
- ccl_chromium_reader/ccl_chromium_localstorage.py +454 -0
- ccl_chromium_reader/ccl_chromium_notifications.py +268 -0
- ccl_chromium_reader/ccl_chromium_profile_folder.py +568 -0
- ccl_chromium_reader/ccl_chromium_sessionstorage.py +368 -0
- ccl_chromium_reader/ccl_chromium_snss2.py +332 -0
- ccl_chromium_reader/ccl_shared_proto_db_downloads.py +189 -0
- ccl_chromium_reader/common.py +19 -0
- ccl_chromium_reader/download_common.py +78 -0
- ccl_chromium_reader/profile_folder_protocols.py +276 -0
- ccl_chromium_reader/serialization_formats/__init__.py +0 -0
- ccl_chromium_reader/serialization_formats/ccl_blink_value_deserializer.py +401 -0
- ccl_chromium_reader/serialization_formats/ccl_easy_chromium_pickle.py +133 -0
- ccl_chromium_reader/serialization_formats/ccl_protobuff.py +276 -0
- ccl_chromium_reader/serialization_formats/ccl_v8_value_deserializer.py +627 -0
- ccl_chromium_reader/storage_formats/__init__.py +0 -0
- ccl_chromium_reader/storage_formats/ccl_leveldb.py +582 -0
- ccl_simplesnappy/__init__.py +1 -0
- ccl_simplesnappy/ccl_simplesnappy.py +306 -0
- linear_mcp_fast/__init__.py +8 -0
- linear_mcp_fast/__main__.py +6 -0
- linear_mcp_fast/reader.py +433 -0
- linear_mcp_fast/server.py +367 -0
- linear_mcp_fast/store_detector.py +117 -0
- linear_mcp_fast-0.1.0.dist-info/METADATA +160 -0
- linear_mcp_fast-0.1.0.dist-info/RECORD +39 -0
- linear_mcp_fast-0.1.0.dist-info/WHEEL +5 -0
- linear_mcp_fast-0.1.0.dist-info/entry_points.txt +2 -0
- linear_mcp_fast-0.1.0.dist-info/top_level.txt +4 -0
- tools_and_utilities/Chromium_dump_local_storage.py +111 -0
- tools_and_utilities/Chromium_dump_session_storage.py +92 -0
- tools_and_utilities/benchmark.py +35 -0
- tools_and_utilities/ccl_chrome_audit.py +651 -0
- tools_and_utilities/dump_indexeddb_details.py +59 -0
- tools_and_utilities/dump_leveldb.py +53 -0
|
@@ -0,0 +1,268 @@
|
|
|
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 datetime
|
|
24
|
+
import enum
|
|
25
|
+
import io
|
|
26
|
+
import os
|
|
27
|
+
import struct
|
|
28
|
+
import sys
|
|
29
|
+
import pathlib
|
|
30
|
+
import dataclasses
|
|
31
|
+
import typing
|
|
32
|
+
|
|
33
|
+
from .storage_formats import ccl_leveldb
|
|
34
|
+
from .serialization_formats import ccl_blink_value_deserializer, ccl_v8_value_deserializer, ccl_protobuff as pb
|
|
35
|
+
|
|
36
|
+
__version__ = "0.3"
|
|
37
|
+
__description__ = "Library for reading Chrome/Chromium notifications (Platform Notifications)"
|
|
38
|
+
__contact__ = "Alex Caithness"
|
|
39
|
+
|
|
40
|
+
# See content/browser/notifications/notification_database.cc
|
|
41
|
+
# and content/browser/notifications/notification_database_data.proto
|
|
42
|
+
|
|
43
|
+
EPOCH = datetime.datetime(1601, 1, 1)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
# stolen from ccl_chromium_indexeddb 20230907
|
|
47
|
+
@dataclasses.dataclass(frozen=True)
|
|
48
|
+
class BlinkTrailer:
|
|
49
|
+
# third_party/blink/renderer/bindings/core/v8/serialization/trailer_reader.h
|
|
50
|
+
offset: int
|
|
51
|
+
length: int
|
|
52
|
+
|
|
53
|
+
TRAILER_SIZE: typing.ClassVar[int] = 13
|
|
54
|
+
MIN_WIRE_FORMAT_VERSION_FOR_TRAILER: typing.ClassVar[int] = 21
|
|
55
|
+
|
|
56
|
+
@classmethod
|
|
57
|
+
def from_buffer(cls, buffer, trailer_offset: int):
|
|
58
|
+
tag, offset, length = struct.unpack(">cQI", buffer[trailer_offset: trailer_offset + BlinkTrailer.TRAILER_SIZE])
|
|
59
|
+
if tag != ccl_blink_value_deserializer.Constants.tag_kTrailerOffsetTag:
|
|
60
|
+
raise ValueError(
|
|
61
|
+
f"Trailer doesn't start with kTrailerOffsetTag "
|
|
62
|
+
f"(expected: 0x{ccl_blink_value_deserializer.Constants.tag_kTrailerOffsetTag.hex()}; "
|
|
63
|
+
f"got: 0x{tag.hex()}")
|
|
64
|
+
|
|
65
|
+
return BlinkTrailer(offset, length)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class ClosedReason(enum.IntEnum):
|
|
69
|
+
USER = 0
|
|
70
|
+
DEVELOPER = 1
|
|
71
|
+
UNKNOWN = 2
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class ActionType(enum.IntEnum):
|
|
75
|
+
BUTTON = 0
|
|
76
|
+
TEXT = 1
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
class Direction(enum.IntEnum):
|
|
80
|
+
LEFT_TO_RIGHT = 0
|
|
81
|
+
RIGHT_TO_LEFT = 1
|
|
82
|
+
AUTO = 2
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def read_datetime(stream):
|
|
86
|
+
ms = pb.read_le_varint(stream)
|
|
87
|
+
return EPOCH + datetime.timedelta(microseconds=ms)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
NotificationAction_Structure = {
|
|
91
|
+
1: pb.ProtoDecoder("action", pb.read_string),
|
|
92
|
+
2: pb.ProtoDecoder("title", pb.read_string),
|
|
93
|
+
3: pb.ProtoDecoder("icon", pb.read_string),
|
|
94
|
+
4: pb.ProtoDecoder("type", lambda x: ActionType(pb.read_le_varint(x))),
|
|
95
|
+
5: pb.ProtoDecoder("placeholder", pb.read_string),
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
NotificationData_Structure = {
|
|
99
|
+
1: pb.ProtoDecoder("title", pb.read_string),
|
|
100
|
+
2: pb.ProtoDecoder("closed_reason", lambda x: Direction(pb.read_le_varint(x))),
|
|
101
|
+
3: pb.ProtoDecoder("lang", pb.read_string),
|
|
102
|
+
4: pb.ProtoDecoder("body", pb.read_string),
|
|
103
|
+
5: pb.ProtoDecoder("tag", pb.read_string),
|
|
104
|
+
6: pb.ProtoDecoder("icon", pb.read_string),
|
|
105
|
+
7: pb.ProtoDecoder("silent", lambda x: pb.read_le_varint(x) != 0),
|
|
106
|
+
8: pb.ProtoDecoder("data", pb.read_blob),
|
|
107
|
+
9: pb.ProtoDecoder("vibration", pb.read_blob),
|
|
108
|
+
10: pb.ProtoDecoder(
|
|
109
|
+
"actions", lambda x: pb.read_embedded_protobuf(x, NotificationAction_Structure, use_friendly_tag=True)),
|
|
110
|
+
11: pb.ProtoDecoder("require_interaction", lambda x: pb.read_le_varint(x) != 0),
|
|
111
|
+
12: pb.ProtoDecoder("timestamp", read_datetime),
|
|
112
|
+
13: pb.ProtoDecoder("renotify", lambda x: pb.read_le_varint(x) != 0),
|
|
113
|
+
14: pb.ProtoDecoder("badge", pb.read_string),
|
|
114
|
+
15: pb.ProtoDecoder("image", pb.read_string),
|
|
115
|
+
16: pb.ProtoDecoder("show_trigger_timestamp", read_datetime),
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
NotificationDatabaseDataProto_Structure = {
|
|
119
|
+
1: pb.ProtoDecoder("persistent_notification_id", pb.read_le_varint),
|
|
120
|
+
2: pb.ProtoDecoder("origin", pb.read_string),
|
|
121
|
+
3: pb.ProtoDecoder("service_worker_registration_id", pb.read_le_varint),
|
|
122
|
+
4: pb.ProtoDecoder(
|
|
123
|
+
"notification_data", lambda x: pb.read_embedded_protobuf(x, NotificationData_Structure, use_friendly_tag=True)),
|
|
124
|
+
5: pb.ProtoDecoder("notification_id", pb.read_string),
|
|
125
|
+
6: pb.ProtoDecoder("replaced_existing_notification", lambda x: pb.read_le_varint(x) != 0),
|
|
126
|
+
7: pb.ProtoDecoder("num_clicks", pb.read_le_varint32),
|
|
127
|
+
8: pb.ProtoDecoder("num_action_button_clicks", pb.read_le_varint32),
|
|
128
|
+
9: pb.ProtoDecoder("creation_time_millis", read_datetime),
|
|
129
|
+
10: pb.ProtoDecoder("time_until_first_click_millis", pb.read_le_varint),
|
|
130
|
+
11: pb.ProtoDecoder("time_until_last_click_millis", pb.read_le_varint),
|
|
131
|
+
12: pb.ProtoDecoder("time_until_close_millis", pb.read_le_varint),
|
|
132
|
+
13: pb.ProtoDecoder("closed_reason", lambda x: ClosedReason(pb.read_le_varint(x))),
|
|
133
|
+
14: pb.ProtoDecoder("has_triggered", lambda x: pb.read_le_varint(x) != 0),
|
|
134
|
+
15: pb.ProtoDecoder("is_shown_by_browser", lambda x: pb.read_le_varint(x) != 0),
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
@dataclasses.dataclass(frozen=True)
|
|
139
|
+
class LevelDbInfo:
|
|
140
|
+
user_key: bytes
|
|
141
|
+
origin_file: os.PathLike
|
|
142
|
+
seq_no: int
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
@dataclasses.dataclass(frozen=True)
|
|
146
|
+
class NotificationAction:
|
|
147
|
+
action: typing.Optional[str]
|
|
148
|
+
title: typing.Optional[str]
|
|
149
|
+
icon: typing.Optional[str]
|
|
150
|
+
action_type: typing.Optional[ActionType]
|
|
151
|
+
placeholder: typing.Optional[str]
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
@dataclasses.dataclass(frozen=True)
|
|
155
|
+
class ChromiumNotification:
|
|
156
|
+
level_db_info: LevelDbInfo
|
|
157
|
+
origin: str
|
|
158
|
+
persistent_notification_id: int
|
|
159
|
+
notification_id: str
|
|
160
|
+
title: typing.Optional[str]
|
|
161
|
+
body: typing.Optional[str]
|
|
162
|
+
data: typing.Optional[typing.Any]
|
|
163
|
+
timestamp: datetime.datetime
|
|
164
|
+
creation_time: datetime.datetime # from creation_time_millis
|
|
165
|
+
closed_reason: ClosedReason
|
|
166
|
+
time_until_first_click_millis: int
|
|
167
|
+
time_until_last_click_millis: int
|
|
168
|
+
time_until_close_millis: int
|
|
169
|
+
|
|
170
|
+
tag: typing.Optional[str]
|
|
171
|
+
image: typing.Optional[str]
|
|
172
|
+
icon: typing.Optional[str]
|
|
173
|
+
badge: typing.Optional[str]
|
|
174
|
+
|
|
175
|
+
actions: typing.Optional[typing.Iterable[NotificationAction]]
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
class NotificationReader:
|
|
179
|
+
def __init__(self, notification_input_path: pathlib.Path):
|
|
180
|
+
self._db = ccl_leveldb.RawLevelDb(notification_input_path)
|
|
181
|
+
|
|
182
|
+
def close(self):
|
|
183
|
+
self._db.close()
|
|
184
|
+
|
|
185
|
+
def __enter__(self):
|
|
186
|
+
return self
|
|
187
|
+
|
|
188
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
189
|
+
self._db.close()
|
|
190
|
+
|
|
191
|
+
def read_notifications(self) -> typing.Iterable[ChromiumNotification]:
|
|
192
|
+
blink_deserializer = ccl_blink_value_deserializer.BlinkV8Deserializer()
|
|
193
|
+
for record in self._db.iterate_records_raw():
|
|
194
|
+
if record.state != ccl_leveldb.KeyState.Live:
|
|
195
|
+
continue
|
|
196
|
+
|
|
197
|
+
key = record.user_key.decode("utf-8")
|
|
198
|
+
record_type, key_info = key.split(":", 1)
|
|
199
|
+
origin, key_id = key_info.split("\0", 1)
|
|
200
|
+
level_db_info = LevelDbInfo(record.user_key, record.origin_file, record.seq)
|
|
201
|
+
if record_type == "DATA":
|
|
202
|
+
with io.BytesIO(record.value) as stream:
|
|
203
|
+
root = pb.ProtoObject(
|
|
204
|
+
0x2,
|
|
205
|
+
"root",
|
|
206
|
+
pb.read_protobuff(stream, NotificationDatabaseDataProto_Structure, use_friendly_tag=True))
|
|
207
|
+
|
|
208
|
+
data = root.only("notification_data").only("data").value
|
|
209
|
+
if data:
|
|
210
|
+
if data[0] != 0xff:
|
|
211
|
+
print(key)
|
|
212
|
+
print(data)
|
|
213
|
+
raise ValueError("Missing blink tag at the start of data")
|
|
214
|
+
blink_version, blink_version_bytes = pb._read_le_varint(io.BytesIO(data[1:]))
|
|
215
|
+
data_start = 1 + len(blink_version_bytes)
|
|
216
|
+
if blink_version >= BlinkTrailer.MIN_WIRE_FORMAT_VERSION_FOR_TRAILER:
|
|
217
|
+
trailer = BlinkTrailer.from_buffer(data, data_start) # TODO: do something with the trailer?
|
|
218
|
+
data_start += BlinkTrailer.TRAILER_SIZE
|
|
219
|
+
|
|
220
|
+
with io.BytesIO(data[data_start:]) as obj_raw:
|
|
221
|
+
try:
|
|
222
|
+
deserializer = ccl_v8_value_deserializer.Deserializer(
|
|
223
|
+
obj_raw, host_object_delegate=blink_deserializer.read)
|
|
224
|
+
except ValueError:
|
|
225
|
+
print("Error record:")
|
|
226
|
+
print(level_db_info, key)
|
|
227
|
+
raise
|
|
228
|
+
data = deserializer.read()
|
|
229
|
+
|
|
230
|
+
yield ChromiumNotification(
|
|
231
|
+
level_db_info,
|
|
232
|
+
root.only("origin").value,
|
|
233
|
+
root.only("persistent_notification_id").value,
|
|
234
|
+
root.only("notification_id").value,
|
|
235
|
+
root.only("notification_data").only("title").value,
|
|
236
|
+
root.only("notification_data").only("body").value,
|
|
237
|
+
data,
|
|
238
|
+
root.only("notification_data").only("timestamp").value,
|
|
239
|
+
root.only("creation_time_millis").value,
|
|
240
|
+
root.only("closed_reason").value,
|
|
241
|
+
root.only("time_until_first_click_millis").value,
|
|
242
|
+
root.only("time_until_last_click_millis").value,
|
|
243
|
+
root.only("time_until_close_millis").value,
|
|
244
|
+
root.only("notification_data").only("tag").value,
|
|
245
|
+
root.only("notification_data").only("image").value,
|
|
246
|
+
root.only("notification_data").only("icon").value,
|
|
247
|
+
root.only("notification_data").only("badge").value,
|
|
248
|
+
tuple(
|
|
249
|
+
NotificationAction(
|
|
250
|
+
x.only("action").value,
|
|
251
|
+
x.only("title").value,
|
|
252
|
+
x.only("icon").value,
|
|
253
|
+
x.only("type").value,
|
|
254
|
+
x.only("placeholder").value
|
|
255
|
+
)
|
|
256
|
+
for x in root["notification_data"][0]["actions"])
|
|
257
|
+
)
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
if __name__ == '__main__':
|
|
261
|
+
if len(sys.argv) < 2:
|
|
262
|
+
print(f"USAGE: {pathlib.Path(sys.argv[0]).name} <Platform Notifications Folder>")
|
|
263
|
+
exit(1)
|
|
264
|
+
|
|
265
|
+
_reader = NotificationReader(pathlib.Path(sys.argv[1]))
|
|
266
|
+
_blink_deserializer = ccl_blink_value_deserializer.BlinkV8Deserializer()
|
|
267
|
+
for notification in _reader.read_notifications():
|
|
268
|
+
print(notification)
|