标签: crypt12

如何为WhatsApp的.crypt12格式生成页眉和页脚?

WhatsApp将所有消息存储在sqlite文件中,该文件首先经过zlib压缩,然后经过AES加密。

解密/解压缩可以很容易地完成,例如:

def decrypt(db_file, key_file):
    """ Function decrypt Crypt12 Database """
    try:
        with open(key_file, "rb") as fh:
            key_data = fh.read()

        key = key_data[126:]
        with open(db_file, "rb") as fh:
            db_data = fh.read()

        iv = db_data[51:67]
        aes = AES.new(key, mode=AES.MODE_GCM, nonce=iv)
        with open("msgstore.db", "wb") as fh:
            fh.write(zlib.decompress(aes.decrypt(db_data[67:-20])))

        print db_file + " decrypted, msgstore.db created."
    except Exception as e:
print "An error has ocurred decrypting the Database:", e
Run Code Online (Sandbox Code Playgroud)

但是,如果要撤消该过程,则必须生成页眉,页脚和IV。起初我以为您可以从另一个已经存在的crypt12文件中复制它们,如下所示:

def encrypt(db_file, key_file, db_cript):
    """ Function encrypt msgstore Database """
    try:
        with open(key_file, "rb") …
Run Code Online (Sandbox Code Playgroud)

python encryption aes whatsapp crypt12

7
推荐指数
1
解决办法
426
查看次数

标签 统计

aes ×1

crypt12 ×1

encryption ×1

python ×1

whatsapp ×1