dfindexeddb 20240224__py3-none-any.whl → 20240225__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.
- dfindexeddb/leveldb/ldb.py +14 -7
- dfindexeddb/leveldb/log.py +8 -11
- dfindexeddb/utils.py +4 -3
- dfindexeddb/version.py +1 -1
- {dfindexeddb-20240224.dist-info → dfindexeddb-20240225.dist-info}/METADATA +2 -1
- {dfindexeddb-20240224.dist-info → dfindexeddb-20240225.dist-info}/RECORD +10 -10
- {dfindexeddb-20240224.dist-info → dfindexeddb-20240225.dist-info}/AUTHORS +0 -0
- {dfindexeddb-20240224.dist-info → dfindexeddb-20240225.dist-info}/LICENSE +0 -0
- {dfindexeddb-20240224.dist-info → dfindexeddb-20240225.dist-info}/WHEEL +0 -0
- {dfindexeddb-20240224.dist-info → dfindexeddb-20240225.dist-info}/top_level.txt +0 -0
dfindexeddb/leveldb/ldb.py
CHANGED
|
@@ -21,6 +21,7 @@ import os
|
|
|
21
21
|
from typing import BinaryIO, Iterable, Tuple
|
|
22
22
|
|
|
23
23
|
import snappy
|
|
24
|
+
import zstd
|
|
24
25
|
|
|
25
26
|
from dfindexeddb import utils
|
|
26
27
|
|
|
@@ -90,17 +91,24 @@ class LdbBlock:
|
|
|
90
91
|
data: bytes = field(repr=False)
|
|
91
92
|
footer: bytes # 5 bytes = 1 byte compressed flag + 4 bytes checksum.
|
|
92
93
|
|
|
93
|
-
|
|
94
|
+
SNAPPY_COMPRESSED = 1
|
|
95
|
+
ZSTD_COMPRESSED = 2
|
|
94
96
|
RESTART_ENTRY_LENGTH = 4
|
|
95
97
|
|
|
96
|
-
def
|
|
97
|
-
"""Returns true if the block is compressed."""
|
|
98
|
-
return self.footer[0] == self.
|
|
98
|
+
def IsSnappyCompressed(self) -> bool:
|
|
99
|
+
"""Returns true if the block is snappy compressed."""
|
|
100
|
+
return self.footer[0] == self.SNAPPY_COMPRESSED
|
|
101
|
+
|
|
102
|
+
def IsZstdCompressed(self) -> bool:
|
|
103
|
+
"""Returns true if the block is zstd compressed."""
|
|
104
|
+
return self.footer[0] == self.ZSTD_COMPRESSED
|
|
99
105
|
|
|
100
106
|
def GetBuffer(self) -> bytes:
|
|
101
107
|
"""Returns the block buffer, decompressing if required."""
|
|
102
|
-
if self.
|
|
108
|
+
if self.IsSnappyCompressed():
|
|
103
109
|
return snappy.decompress(self.data)
|
|
110
|
+
if self.IsZstdCompressed():
|
|
111
|
+
return zstd.decompress(self.data)
|
|
104
112
|
return self.data
|
|
105
113
|
|
|
106
114
|
def GetRecords(self) -> Iterable[LdbKeyValueRecord]:
|
|
@@ -246,8 +254,7 @@ class LdbFileReader:
|
|
|
246
254
|
LdbKeyValueRecords.
|
|
247
255
|
"""
|
|
248
256
|
for block in self.GetBlocks():
|
|
249
|
-
|
|
250
|
-
yield record
|
|
257
|
+
yield from block.GetRecords()
|
|
251
258
|
|
|
252
259
|
def RangeIter(self) -> Iterable[Tuple[bytes, bytes]]: #pylint: disable=C0103
|
|
253
260
|
"""Returns an iterator of key-value pairs.
|
dfindexeddb/leveldb/log.py
CHANGED
|
@@ -20,7 +20,6 @@ from enum import IntEnum
|
|
|
20
20
|
import io
|
|
21
21
|
from typing import BinaryIO, Generator, Iterable, Optional
|
|
22
22
|
|
|
23
|
-
from dfindexeddb import errors
|
|
24
23
|
from dfindexeddb import utils
|
|
25
24
|
|
|
26
25
|
|
|
@@ -198,11 +197,10 @@ class Block:
|
|
|
198
197
|
LogFileRecord
|
|
199
198
|
"""
|
|
200
199
|
buffer = io.BytesIO(self.data)
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
return
|
|
200
|
+
buffer_length = len(self.data)
|
|
201
|
+
|
|
202
|
+
while buffer.tell() < buffer_length:
|
|
203
|
+
yield PhysicalRecord.FromStream(buffer, base_offset=self.offset)
|
|
206
204
|
|
|
207
205
|
@classmethod
|
|
208
206
|
def FromStream(cls, stream: BinaryIO) -> Optional[Block]:
|
|
@@ -212,7 +210,8 @@ class Block:
|
|
|
212
210
|
stream: the binary stream to be parsed.
|
|
213
211
|
|
|
214
212
|
Returns:
|
|
215
|
-
the Block or None if there is no data to read from the stream.
|
|
213
|
+
the Block or None if there is no data to read from the stream.
|
|
214
|
+
"""
|
|
216
215
|
offset = stream.tell()
|
|
217
216
|
data = stream.read(cls.BLOCK_SIZE) # reads full and partial blocks
|
|
218
217
|
if not data:
|
|
@@ -266,8 +265,7 @@ class LogFileReader:
|
|
|
266
265
|
PhysicalRecord
|
|
267
266
|
"""
|
|
268
267
|
for block in self.GetBlocks():
|
|
269
|
-
|
|
270
|
-
yield physical_record
|
|
268
|
+
yield from block.GetPhysicalRecords()
|
|
271
269
|
|
|
272
270
|
def GetWriteBatches(self) -> Generator[WriteBatch, None, None]:
|
|
273
271
|
"""Returns an iterator of WriteBatch instances.
|
|
@@ -304,5 +302,4 @@ class LogFileReader:
|
|
|
304
302
|
KeyValueRecord
|
|
305
303
|
"""
|
|
306
304
|
for batch in self.GetWriteBatches():
|
|
307
|
-
|
|
308
|
-
yield record
|
|
305
|
+
yield from batch.records
|
dfindexeddb/utils.py
CHANGED
|
@@ -68,10 +68,10 @@ class StreamDecoder:
|
|
|
68
68
|
offset = self.stream.tell()
|
|
69
69
|
buffer = self.stream.read(count)
|
|
70
70
|
if count == -1 and not buffer:
|
|
71
|
-
raise errors.DecoderError('No bytes available')
|
|
71
|
+
raise errors.DecoderError(f'No bytes available at offset {offset}')
|
|
72
72
|
if count != -1 and len(buffer) != count:
|
|
73
73
|
raise errors.DecoderError(
|
|
74
|
-
f'Read {len(buffer)}, wanted {count}
|
|
74
|
+
f'Read {len(buffer)} bytes, but wanted {count} at offset {offset}')
|
|
75
75
|
return offset, buffer
|
|
76
76
|
|
|
77
77
|
def PeekBytes(self, count: int) -> Tuple[int, bytes]:
|
|
@@ -225,7 +225,8 @@ class LevelDBDecoder(StreamDecoder):
|
|
|
225
225
|
offset = self.stream.tell()
|
|
226
226
|
buffer = self.stream.read()
|
|
227
227
|
if len(buffer) % 2:
|
|
228
|
-
raise errors.DecoderError(
|
|
228
|
+
raise errors.DecoderError(
|
|
229
|
+
f'Odd number of bytes encountered at offset {offset}')
|
|
229
230
|
return offset, buffer.decode('utf-16-be')
|
|
230
231
|
|
|
231
232
|
def DecodeBlobWithLength(self) -> Tuple[int, bytes]:
|
dfindexeddb/version.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: dfindexeddb
|
|
3
|
-
Version:
|
|
3
|
+
Version: 20240225
|
|
4
4
|
Summary: dfindexeddb is an experimental Python tool for performing digital forensic analysis of IndexedDB and leveldb files.
|
|
5
5
|
Author-email: Syd Pleno <sydp@google.com>
|
|
6
6
|
Maintainer-email: dfIndexeddb Developers <dfindexeddb-dev@googlegroups.com>
|
|
@@ -218,6 +218,7 @@ Description-Content-Type: text/markdown
|
|
|
218
218
|
License-File: LICENSE
|
|
219
219
|
License-File: AUTHORS
|
|
220
220
|
Requires-Dist: python-snappy ==0.6.1
|
|
221
|
+
Requires-Dist: zstd ==1.5.5.1
|
|
221
222
|
|
|
222
223
|
# dfIndexeddb
|
|
223
224
|
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
dfindexeddb/__init__.py,sha256=KPYL9__l8od6_OyDfGRTgaJ6iy_fqIgZ-dS2S-e3Rac,599
|
|
2
2
|
dfindexeddb/errors.py,sha256=PNpwyf_lrPc4TE77oAakX3mu5D_YcP3f80wq8Y1LkvY,749
|
|
3
|
-
dfindexeddb/utils.py,sha256=
|
|
4
|
-
dfindexeddb/version.py,sha256
|
|
3
|
+
dfindexeddb/utils.py,sha256=g9iiGRX4DB1wFBSBHa6b9lg7JzAdE0SN0DrdB2aS_Co,10091
|
|
4
|
+
dfindexeddb/version.py,sha256=PiFacIFljjKL8Q1cSjdiapC9lqsgpPS4GDZDrPlBy4o,750
|
|
5
5
|
dfindexeddb/indexeddb/__init__.py,sha256=kExXSVBCTKCD5BZJkdMfUMqGksH-DMJxP2_lI0gq-BE,575
|
|
6
6
|
dfindexeddb/indexeddb/blink.py,sha256=MblpYfv-ByG7n_fjYKu2EUhpfVJdUveoW4oSAg5T4tY,3534
|
|
7
7
|
dfindexeddb/indexeddb/chromium.py,sha256=N1aCoJETNqLER8T_C4bmfrxiNr1csJhUJ4-14qrl0nc,42291
|
|
8
8
|
dfindexeddb/indexeddb/definitions.py,sha256=yline3y3gmZx6s-dwjpPDNs5HO4zT6KZqPWQfEsHDoM,7413
|
|
9
9
|
dfindexeddb/indexeddb/v8.py,sha256=ldqpc9T1kG7BOdjnHjQ5hNO9OCXZ3_Zd6vRSpC-NrEA,21893
|
|
10
10
|
dfindexeddb/leveldb/__init__.py,sha256=KPYL9__l8od6_OyDfGRTgaJ6iy_fqIgZ-dS2S-e3Rac,599
|
|
11
|
-
dfindexeddb/leveldb/ldb.py,sha256=
|
|
12
|
-
dfindexeddb/leveldb/log.py,sha256=
|
|
13
|
-
dfindexeddb-
|
|
14
|
-
dfindexeddb-
|
|
15
|
-
dfindexeddb-
|
|
16
|
-
dfindexeddb-
|
|
17
|
-
dfindexeddb-
|
|
18
|
-
dfindexeddb-
|
|
11
|
+
dfindexeddb/leveldb/ldb.py,sha256=uShhXjQe4Sz3dn54IXbGxRtE6D8RNpu1NDy5Zb0P9LA,7927
|
|
12
|
+
dfindexeddb/leveldb/log.py,sha256=cyMfjDz5a6gfGb5NonxC1Y72OmHYBWzYK8UMVzP_umw,8532
|
|
13
|
+
dfindexeddb-20240225.dist-info/AUTHORS,sha256=QbvjbAom57fpEkekkCVFUj0B9KUMGraR510aUMBC-PE,286
|
|
14
|
+
dfindexeddb-20240225.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
15
|
+
dfindexeddb-20240225.dist-info/METADATA,sha256=ZRr-aOFy5SlgZ2nTgeaYpLCjauP7qzW5XSSsFCyeFOQ,15474
|
|
16
|
+
dfindexeddb-20240225.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
17
|
+
dfindexeddb-20240225.dist-info/top_level.txt,sha256=X9OTaub1c8S_JJ7g-f8JdkhhdiZ4x1j4eni1hdUCwE4,12
|
|
18
|
+
dfindexeddb-20240225.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|