From 3d3e41b15d0b4f0de5df4414c17b688d155cc4e8 Mon Sep 17 00:00:00 2001 From: ttttupup <31303661+ttttupup@users.noreply.github.com> Date: Wed, 29 Mar 2023 10:08:19 +0800 Subject: [PATCH] Updated Home (markdown) --- Home.md | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Home.md b/Home.md index 32bcfd4..d38a959 100644 --- a/Home.md +++ b/Home.md @@ -45,4 +45,25 @@ sqlite3_close函数特征最明显,直接搜索字符串 "unable to close due 和sqlite3.c里api保持一致。 微信使用的是SQLCipher加密sqlite3,推而广之也开源采用此方法定位key相关的函数。 -再推而广之,开源项目的逆向基本上都可以采用这种套路。 \ No newline at end of file +再推而广之,开源项目的逆向基本上都可以采用这种套路。 + +# 数据库解密 +经过简单分析可以确定微信是使用的SQLCipher进行加密。可以简单分析一下SQLCipher的加密过程如下: +![image](https://user-images.githubusercontent.com/31303661/228406245-1c536a96-370f-4131-acea-1e6f33b46c67.png) + +然后看下crypto.h,解密就是反过程: +![image](https://user-images.githubusercontent.com/31303661/228405488-d9e30857-0e49-4011-93be-c19c6b956c8a.png) + +![image](https://user-images.githubusercontent.com/31303661/228404744-db7852c4-6a2e-401b-9619-640de339a66b.png) +![image](https://user-images.githubusercontent.com/31303661/228404801-5aa29891-b820-48ad-98b4-ed7a9c1aadc7.png) +![image](https://user-images.githubusercontent.com/31303661/228404881-0aebe345-94ca-4211-941b-c46e23032617.png) + +这些事当然要先看看官方的解密工具 https://github.com/sqlcipher/sqlcipher-tools , 简单测试了一下,只解密了第一页,应该是后面更新了版本的原因, +也编译了sqlcipher,不过也没解密成功,因为微信用的是3.40的sqlite,版本不一致。这种体力活,肯定是先搜一搜有现成的工具没有,然后参考了一个博主的python脚本, +简单修改一下即可。 +![image](https://user-images.githubusercontent.com/31303661/228407515-545e6b6d-9ee9-409c-adfb-ecdde32b0158.png) + +测试了一下效果还可以。 +![image](https://user-images.githubusercontent.com/31303661/228407983-cc594b44-a9fe-4c52-91a3-29f88a058c42.png) + +