Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/360.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何访问Firefox';使用Python的内部indexedDB文件?_Python_Firefox_Indexeddb - Fatal编程技术网

如何访问Firefox';使用Python的内部indexedDB文件?

如何访问Firefox';使用Python的内部indexedDB文件?,python,firefox,indexeddb,Python,Firefox,Indexeddb,我需要使用python阅读firefox的indexeddb 我使用slite3包检索indexeddb的内容: with sqlite3.connect(indexeddb_file) as conn: c = conn.cursor() c.execute('select * from object_data;') rows = c.fetchall() for row in rows: print row[2] 然而,尽管我知道数据库中的内

我需要使用python阅读firefox的indexeddb

我使用
slite3
包检索indexeddb的内容:

with sqlite3.connect(indexeddb_file) as conn:
    c = conn.cursor()
    c.execute('select * from object_data;')
    rows = c.fetchall()
    for row in rows:
        print row[2]
然而,尽管我知道数据库中的内容是字符串,但它们存储为sqlite。有没有办法从python中读取存储为blob的字符串

我试过:

  • sql方法只是将blob编码为十六进制
  • 当我
更新

按照@paa在这个问题的一个评论中指出的在firefox中实现indexeddb的编码方案,我在python中实现了数据库密钥的部分FF编码方法。到目前为止,我只为字符串实现了它,但为其他类型实现它会更容易:

BYTE_LENGTH = 8

def hex_to_bin(hex_str):
    """Return binary representation of hexadecimal string."""
    return str(trim_bin(int(hex_str, 16)).zfill(len(hex_str) * 4))

def byte_to_unicode(bin_byte):
    """Return unicode encoding for binary byte."""
    return chr(int(str(bin_byte), 2))

def trim_bin(int_n):
    """Return int num converted to trimmed bin representation."""
    return bin(int_n)[2:]

def decode(key):
    """Return decoded idb key."""
    decoded = key
    m = re.search("[1-9]", key)  # change for non-zero
    if m:
        i = m.start()
        typeoffset = int(key[i])
    else:
        # error
        pass
    data = key[i + 1:]
    if typeoffset is 1:
        # decode number
        pass
    elif typeoffset is 2:
        # decode date
        pass
    elif typeoffset is 3:
        # decode string
        bin_repr = hex_to_bin(data)
        decoded = ""
        for i in xrange(0, len(bin_repr), BYTE_LENGTH):
            byte = bin_repr[i:i + BYTE_LENGTH]
            if byte[0] is '0':
                byte_1 = int(byte, 2) - 1
                decoded += byte_to_unicode(trim_bin(byte_1))
            else:
                byte = byte[2:]
                if byte[1] is '0':
                    byte_127 = int(byte, 2) + 127
                    decoded += byte_to_unicode(trim_bin(byte_127))
                    i += BYTE_LENGTH
                    decoded += byte_to_unicode(bin_repr[i:i + BYTE_LENGTH])
                elif byte[1] is '1':
                    decoded += byte_to_unicode(byte)
                    i += BYTE_LENGTH
                    decoded += byte_to_unicode(bin_repr[i:i + BYTE_LENGTH])
                    i += BYTE_LENGTH
                    decoded += byte_to_unicode(bin_repr[i:i + 2])
        return decoded
    elif typeoffset is 4:
        # decode array
        pass
    else:
        # error
        pass
    return decoded
但是,我仍然无法解码indexeddb的数据字段。在我看来,他们并没有使用任何复杂的方案,比如密钥方案,因为当我用UTF-16编码时,我可以读取实际值的某些部分。

(在这里键入,因为我还不能评论…)

对于数据本身,我一直在尝试对数据块做同样的事情。对于我的问题,我正在尝试提取JSON字符串。如果我查看我试图筛选的数据库,我确实看到了UTF-16编码字符,大多数情况下。但有些奇怪的情况下,我有这样的想法:

“我们走了”编码为7400 6800 6500 7200 6500 2000 77[05060C]6700 6F00。[05060C]应该编码为“e”


我正在调查,看看是否有任何线索。目录中应该有很多其他的源文件可以提供帮助。

很酷的问题!如果没有其他人响应,我会在找到私人时间后进行调查。我怀疑firefox的实现对indexeddb数据进行了加密,但我在他们的源代码中找不到。以下是负责将新记录插入数据库的方法:(from)from:
在Firefox的IndexedDB实现中(我相信IE也是如此),文件透明地存储在实际数据库之外。
我错了,他们可能没有加密它。问题可能是:
Firefox IndexedDB实现甚至足够聪明,如果在IndexedDB数据库中存储相同的Blob多个文件,它只会创建文件的一个副本。
内容没有加密,但经过编码。你会发现这个@Kits89,如果你能在我之前找到它,请发布你的答案!更妙的是,可以通过电子邮件向