Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you *read* leveldb data without the proper comparator?

I'm trying to access leveldbs generated by Chrome storing indexeddbs. I get keys and values. But they are either in an unknown encoding - I've tried many ways to detect them - or they are scrambled in some way.

import plyvel    
db = plyvel.DB(dirname, comparator=cmp, comparator_name="idb_cmp1")
for key, value in db:
    print(key) 
    print(value)

I don't mind if the keys are in random order as described here. But it would be nice to get the keys and values in a readable fashion. I'm not dealing with binary data in the leveldb, either.

I'm using plyvel in python to iterate over the db. This answer might be related: LevelDB C iterator

like image 945
Dej Avatar asked Nov 09 '22 03:11

Dej


1 Answers

you may fake it by passing exactly the same comparator name to a custom comparator in plyvel. that comparator may work differently from the one originally used to create the database. that would get you past the first hurdle i guess.

but since leveldb does not provide a read-only mode of operation, there may be a background thread kicking in to do some compaction while you read the database. and since the comparator is mishaving, this can lead to data loss and destruction of your database.

like image 175
wouter bolsterlee Avatar answered Nov 14 '22 23:11

wouter bolsterlee