安卓微信本地数据库解密与删除聊天记录恢复 EnMicroMsg.db FTS5IndexMicroMsg_encrypt.db
- 前言
- 正文
- 经验回顾
- 新的问题
- 解决华为旧备份数据导出问题
- 解密索引数据库
- 先要解密微信消息库
- 解密索引库
- 从索引库恢复被删除的消息
- 总结
正文
经验回顾
- EnMicroMsg.db密码算法没有变化 ,这个密码算法仍然是IMEI与uin拼接后计算32位MD5值,然后取前7位(如果uin是负值也不需要变化);
- IMEI和最后一次登录的uin提取方法没有变化,IMEI在CompatibleInfo.cfg文件中,最后一次登录的uin在system_conf_prefs.xml文件中;
新的问题
解决华为旧备份数据导出问题
import sqlite3
import os
conn = sqlite3.connect('com.tencent.mm.db')
cursor = conn.cursor()
cursor.execute("SELECT count(*) FROM apk_file_info")
all = cursor.fetchone()[0]
cursor.execute("SELECT file_path,file_index FROM apk_file_info")
result = cursor.fetchall()
count = 0
while (count < all):if (result[count][1] > 0):fullname = result[count][0]findex = result[count][1]dirname,filename = os.path.split(fullname)fpath="." + dirnamefname="." + fullnameisExists=os.path.exists(fpath)if not isExists:os.makedirs(fpath)with open(fname, "wb") as output_file:cursor.execute("SELECT count(*) FROM apk_file_data WHERE file_index = " + str(findex))total = cursor.fetchone()[0]cursor.execute("SELECT file_data FROM apk_file_data WHERE file_index = " + str(findex))acount=0while (acount < total):ablob = cursor.fetchone()output_file.write(ablob[0])acount = acount+1count = count + 1
cursor.close()
conn.close()
解密索引数据库
先要解密微信消息库
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.security.MessageDigest;
import java.util.HashMap;
public class GetDBKey {public static void main(String[] args) {try {ObjectInputStream in = new ObjectInputStream(new FileInputStream("CompatibleInfo.cfg"));Object DL = in.readObject();HashMap hashWithOutFormat = (HashMap) DL;String s = String.valueOf(hashWithOutFormat.get(Integer.valueOf(258))); // 取手机的IMEISystem.out.println("IMEI:"+s);ObjectInputStream in1 = new ObjectInputStream(new FileInputStream("systemInfo.cfg"));Object DJ = in1.readObject();HashMap hashWithOutFormat1 = (HashMap) DJ;String t = String.valueOf(hashWithOutFormat1.get(Integer.valueOf(1))); // 取微信的uinSystem.out.println("uin:"+t);s = s + t; //合并到一个字符串s = encode(s); // MD5System.out.println("密码是 : " + s.substring(0, 7));in.close();in1.close();} catch (Exception e) {e.printStackTrace();}}public static String encode(String content){try {MessageDigest digest = MessageDigest.getInstance("MD5");digest.update(content.getBytes());return getEncode32(digest);}catch (Exception e){e.printStackTrace();}return null;}private static String getEncode32(MessageDigest digest){StringBuilder builder = new StringBuilder();for (byte b : digest.digest()){builder.append(Integer.toHexString((b >> 4) & 0xf));builder.append(Integer.toHexString(b & 0xf));}return builder.toString();}
}
from pysqlcipher3 import dbapi2 as sqlite
import hashlib
def decrypt( key ):conn = sqlite.connect( "EnMicroMsg.db" )c = conn.cursor() c.execute( "PRAGMA key = '" + key + "';" )c.execute( "PRAGMA cipher_use_hmac = OFF;" )c.execute( "PRAGMA cipher_page_size = 1024;" )c.execute( "PRAGMA kdf_iter = 4000;" )c.execute( "ATTACH DATABASE 'EnMicroMsg-decrypted.db' AS wechatdecrypted KEY '';" )c.execute( "SELECT sqlcipher_export( 'wechatdecrypted' );" )c.execute( "DETACH DATABASE wechatdecrypted;" )c.close()
def generate_key():imei = "866666666666666"uin = "1919191919"key = hashlib.md5( str( imei ).encode("utf8") + str( uin ).encode("utf8")).hexdigest()[ 0:7 ]return key
def main(): key = generate_key()decrypt( key )
main()
将代码中的imei值和uin值替换成刚才获得的值即可。将EnMicroMsg.db与python程序放在同一目录下运行即可解密,生成的文件名为EnMicroMsg-decrypted.db。
解密索引库
@rem Add default JVM options here. You can also use JAVA_OPTS and JADX_GUI_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xms1024M" "-Xmx7g" "-Dawt.useSystemAAFontSettings=lcd" "-Dswing.aatext=true" "-XX:+UseG1GC"
String absolutePath = new File(str, "FTS5IndexMicroMsg_encrypt.db").getAbsolutePath();
this.lXS = SQLiteDatabase.openOrCreateDatabase(absolutePath, com.tencent.mm.a.g.u(stringBuilder.append(a.OZ()).append(q.Kc()).append(com.tencent.mm.model.q.Wt()).toString().getBytes()).substring(0, 7).getBytes(), null, null);
CIPHER_AES256CBC = "aes-256-cbc";
kdfIteration = 64000;
hmacEnabled = true;
setPageSize=4096;
PRAGMA cipher = 'aes-256-cbc';
PRAGMA cipher_use_hmac = ON;
PRAGMA cipher_page_size = 4096;
PRAGMA kdf_iter = 64000;
综上所述,一切解密需要的素材都齐了,相应的python代码如下:
from os.path import isfile
# 用pip install pysqlcipher3安装python的sqlcipher支持库再引用
from pysqlcipher3 import dbapi2 as sqlite
import hashlib
import sys
import time
import logging
import relogging.basicConfig(filename='FTS5IndexMicroMsg_decrypt.log', format="%(asctime)s %(levelname)s: %(message)s", datefmt="%d-%b-%Y %I:%M:%S %p", level=logging.DEBUG)def decrypt( key ):logging.info( "连接数据库..." )conn = sqlite.connect( "FTS5IndexMicroMsg_encrypt.db" )c = conn.cursor() c.execute( "PRAGMA key = '" + key + "';" )c.execute( "PRAGMA cipher = 'aes-256-cbc';" )c.execute( "PRAGMA cipher_use_hmac = ON;" )c.execute( "PRAGMA cipher_page_size = 4096;" )c.execute( "PRAGMA kdf_iter = 64000;" )try:logging.info( "正在解密..." )c.execute( "ATTACH DATABASE 'FTS5IndexMicroMsg_decrypt.db' AS fts5indexdecrypt KEY '';" )c.execute( "SELECT sqlcipher_export( 'fts5indexdecrypt' );" )c.execute( "DETACH DATABASE fts5indexdecrypt;" )logging.info( "正在分离数据库..." )c.close()status = 1except:c.close()status = 0return statusdef generate_key():imei = "866666666666666"logging.info( "IMEI: " + str( imei ))uin = "2377777777"logging.info( "UIN: " + str( uin ))account = "wxid_1l8w9yqrxxxxxx"logging.info( "account: " + str( account ))logging.info( "正在生成密钥..." ) key = hashlib.md5( str( uin ).encode("utf8") + str( imei ).encode("utf8") + str( account ).encode("utf8")).hexdigest()[ 0:7 ]logging.info( "密钥: " + key )return keydef db_hash():f = open( 'FTS5IndexMicroMsg_decrypt.db', 'rb' ).read()logging.info( "正在生成哈希值..." ) if len( f ) > 0:db_md5 = hashlib.md5( f ).hexdigest()logging.info( "FTS5IndexMicroMsg_decrypt.db MD5: " + db_md5 )db_sha1 = hashlib.sha1( f ).hexdigest()logging.info( "FTS5IndexMicroMsg_decrypt.db SHA1: " + db_sha1 )returndef main(): if not ( isfile( "FTS5IndexMicroMsg_encrypt.db" )):print ("##########")print ("'FTS5IndexMicroMsg_encrypt.db'不存在!")print ("正在退出脚本...")print ("##########")sys.exit()logging.info( "脚本启动..." )key = generate_key()status = decrypt( key )if status == 1:db_hash()print ("##########")print ("解密成功!")print ("解密文件: FTS5IndexMicroMsg_decrypt.db")print ("日志文件: FTS5IndexMicroMsg_decrypt.log")print ("##########")logging.info( "解密成功!" )logging.info( "解密文件: FTS5IndexMicroMsg_decrypt.db" )else:print ("##########")print ("解密失败!")print ("日志文件: FTS5IndexMicroMsg_decrypt.log")print ("##########")logging.info( "解密失败!" )logging.info( "正在退出脚本..." )main()
从索引库恢复被删除的消息
如果有问题可以联系,15387172081,微信同号,1037512447 qq/微信
安卓微信本地数据库解密与删除聊天记录恢复 EnMicroMsg.db FTS5IndexMicroMsg_encrypt.db相关推荐
- 安卓微信本地数据库解密与删除聊天记录恢复完全教程
安卓微信本地数据库解密与删除聊天记录恢复完全教程 前言 正文 经验回顾 新的问题 解决华为旧备份数据导出问题 解密索引数据库 先要解密微信消息库 解密索引库 从索引库恢复被删除的消息 总结 [原创内容 ...
- Android逆向_微信本地数据库解密与删除聊天记录恢复完全教程
# 前言 在电子数据取证过程中,对微信本地数据库的解密.提取与恢复是非常重要的工作内容.本文以华为mate系列手机和最新版的微信(7.0.3)为例,通过总结互联网上已经发表的文章经验,主要针对**华为 ...
- 破解微信本地数据库,无法找回删除的聊天记录
[说明:操蛋的微信从4.0后本地数据库都加密了,密码是IMEI+UIN取MD5 32位小写加密前7作为密码] [数据库文件请ROOT后用RE浏览器得到] [UIN 文件路径:/data/data/ ...
- PC微信机器人之实战分析微信本地数据库获取密码
今天主要讨论一下怎么找PC微信本地数据库的密钥,我们知道微信使用的数据库是sqlite3,然后数据库是经过 aes 加密的,我们需要找到aes的密钥,才能解密,然后进行数据库操作.思路是在微信登陆的时 ...
- Android打开微信本地数据库详细步骤二
特别声明:本文章只是用于技术交流,不可用于非法行为. 阅读过上篇文章后,我想你一定去取出来微信本地数据库文件EnmicroMsg.db,但是取出来有什么用呢?又打不开,加密了.好比邂逅了个穿着铁内裤的 ...
- android应用卸载后,出现的本地数据库内容未删除现象
现象:应用使用一段时间后,本地数据库和SharedPreferences中产生数据,将应用卸载后,再次安装,原有数据出现在应用中.因此,为了安全起见,需要将allowBackup标志值设置为false ...
- SQL server 数据库危险存储过程删除与恢复
SQL的扩展的删除与恢复 删除 use master exec sp_dropextendedproc 'xp_cmdshell' exec sp_dropextendedproc 'xp_dir ...
- mysql数据库数据的删除与恢复
Part 1 删除数据, truncate 和 delete 的区别 转自:http://blog.is36.com/mysql_difference_of_truncate_and_delete/ ...
- 安卓开发:本地数据库SQLite的使用
上篇文章,讲述了安卓开发中文件存储和SharedPreferences存储方式.这里讲述SQLite数据库存储.我们的通讯录也存在与SQLite数据库中.存放的位置在:/data/data/com.a ...
- 微信小程序云开发之云数据库的数据删除
前两篇我已经详细介绍了云数据库的部署以及数据库的增加和查询.今天我们就一起来探讨微信云数据库的数据删除. 修改操作和之前讲的那几种操作稍微有些不同.因为删除是根据在数据库里的id进行删除操作的.如下图 ...
最新文章
- java代码内创建mysql索引_Java Mysql数据库创建视图、索引、备份和恢复
- OPENCV背景细分background segmentation的实例(附完整代码)
- 导出Excel java
- [NewLife.Net]单机400万长连接压力测试
- python读取数据文件夹_使用python依次读取文件中的所有csv格式的数据
- c语言删除堆栈所有的结点,深入浅出数据结构C语言版(15)——优先队列(堆)(示例代码)...
- CAD如何快速计算面积并标注?CAD计算面积并标注
- 【Python 3.7】熟食店:创建一个名为 sandwich_orders 的列表,在其中包含各种三明治的名 字;再创建一个名为 finished_sandwiches 的空列表……
- jsp之${CTX}理解
- 【读书笔记】【目标:提升记忆力】申一帆记忆力课程
- 微软远程桌面0x104_win10系统远程桌面出现错误0x204的解决方法
- 《冷读术》值得一看--读书笔记
- 安全问题层出不穷 加密手机悄然兴起
- 持续集成与持续部署(五)01-TravisCI——使用简介-Travis CI 只支持 Github,提供的是持续集成服务 配置项目的.travis.yml文件
- 疫情已经结束,快递行业现状如何
- python计算化学浓度_计算化学操作流程-孙磊.pdf
- python之xlwt、xlrd和openpyxl
- mysql中双引号和单引号有什么区别
- 2018年总结,2019年展望!
- matlab 将矩阵中的NAN替换为0