如何将 msgstore.db.crypt7 从 android 中的 whatsapp 转换为 msgstore.db?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24475815/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 08:15:44  来源:igfitidea点击:

how to convert msgstore.db.crypt7 to msgstore.db from whatsapp in android?

androiddatabasesqlite

提问by mahdi

I want add Automatically contacts that message to me in Whatsapp, so I need to access to Whatsapp's database for my program, but Whatsapp's database is not in .dbformat and is in .crypt7format and I cannot use it. How can I use Whatsapp db or convert .crypt7to .db?

我想在 Whatsapp 中自动添加该消息给我的联系人,所以我需要访问我的程序的 Whatsapp 数据库,但 Whatsapp 的数据库没有.db格式并且.crypt7格式正确,我无法使用它。如何使用 Whatsapp db 或转换.crypt7.db?

回答by moo

As Ashesh mentioned you can use the tool on the XDA developer website: [TOOL] Whatsapp Xtract: Backup Messages Extractor / Database Analyzer / Chat-Backup

正如 Ashesh 提到的,您可以使用 XDA 开发者网站上的工具:[TOOL] Whatsapp Xtract:备份消息提取器/数据库分析器/聊天备份

Alternatively you can do this manually as follows:

或者,您可以按如下方式手动执行此操作:

The WhatsApp Database is stored unencryptedat this path on the Android device:

WhatsApp 数据库未加密地存储在 Android 设备上的以下路径中:

/data/data/com.whatsapp/databases/msgstore.db

Backups of the database are also stored encryptedon the SD card typically at the following location:

数据库的备份也加密存储在 SD 卡上,通常位于以下位置:

/sdcard/WhatsApp/Databases/msgstore.db.crypt7

The unique key for the encrypted backup databases is stored here:

加密备份数据库的唯一密钥存储在此处:

/data/data/com.whatsapp/files/key

Access to the /data/data directory requires root access. Alternatively ADB (Android Debug Bridge) can be used to extract the above files after booting into recovery on the device.

访问 /data/data 目录需要 root 访问权限。或者,在设备上启动恢复后,可以使用 ADB(Android 调试桥)来提取上述文件。

How to Decrypt WhatsApp crypt7 Database Messages:

如何解密 WhatsApp crypt7 数据库消息:

(commands below are run from a linux enviroment)

(下面的命令是从 linux 环境运行的)

  1. Extract Key File: /data/data/com.whatsapp/files/key
  2. Extract crypt7 file: /sdcard/WhatsApp/Databases/msgstore.db.crypt7
  3. Extract Decryption Keys from "key" file extracted in step 1:

    • 256-bit AES key:

      hexdump -e '2/1 "%02x"' key | cut -b 253-316 > aes.txt

    • IV (initialisation vector):

      hexdump -e '2/1 "%02x"' key | cut -b 221-252 > iv.txt

  4. Strip Header in crypt7 File:

    dd if=msgstore.db.crypt7 of=msgstore.db.crypt7.nohdr ibs=67 skip=1

    Note: Size of header stripped file in bytes must be divisible by 16

  5. Decrypt crypt7 File:

    openssl enc -aes-256-cbc -d -nosalt -nopad -bufsize 16384 -in msgstore.db.crypt7.nohdr -K $(cat aes.txt) -iv $(cat iv.txt) > msgstore.db

  1. 提取密钥文件:/data/data/com.whatsapp/files/key
  2. 提取 crypt7 文件:/sdcard/WhatsApp/Databases/msgstore.db.crypt7
  3. 从步骤 1 中提取的“密钥”文件中提取解密密钥:

    • 256 位 AES 密钥:

      hexdump -e '2/1 "%02x"' key | cut -b 253-316 > aes.txt

    • IV(初始化向量):

      hexdump -e '2/1 "%02x"' key | cut -b 221-252 > iv.txt

  4. 删除 crypt7 文件中的标题:

    dd if=msgstore.db.crypt7 of=msgstore.db.crypt7.nohdr ibs=67 skip=1

    注意:标头剥离文件的大小(以字节为单位)必须能被 16 整除

  5. 解密 crypt7 文件:

    openssl enc -aes-256-cbc -d -nosalt -nopad -bufsize 16384 -in msgstore.db.crypt7.nohdr -K $(cat aes.txt) -iv $(cat iv.txt) > msgstore.db

回答by Ashesh Kumar Singh

Developers at XDA have made tools to perform such operations.

XDA 的开发人员已经制作了执行此类操作的工具。

Here is one (windows only)

这是一个(仅限窗户)

[TOOL] Whatsapp Xtract

[工具] Whatsapp Xtract

It's old but I'm sure there will be newer ones out there.

它很旧,但我相信会有更新的。