Skip to content

Commit

Permalink
fix #14.
Browse files Browse the repository at this point in the history
  • Loading branch information
0xlane committed Nov 25, 2024
1 parent 3977c15 commit 0d18905
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "wechat-dump-rs"
version = "1.0.19"
version = "1.0.20"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ key: f11fd83bxxxxxx4f3f4x4ddxxxxxe417696b4axx19e09489ad48c

### 使用 sqlcipher browser 浏览数据库

工具目前对稍微大点的库文件解密后可能存在畸形问题,建议使用 [DB Browser for SQLCipher](https://sqlitebrowser.org/) 进行浏览
工具自动解密后的文件可能存在畸形问题,可以直接使用 [DB Browser for SQLCipher](https://sqlitebrowser.org/) 浏览原始数据库文件

打开 sqlcipher 数据库时,选择 “原始密钥”,微信 V3 选择 sqlcipher3,V4 选择 sqlcipher4,每个数据库文件对应的原始密钥都是不一样的,获取方式如下:

Expand Down
16 changes: 3 additions & 13 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -949,21 +949,11 @@ fn decrypt_db_file_v4(path: &PathBuf, pkey: &String) -> Result<Vec<u8>> {
};

// 每页大小4096,分别解密
let total_page = (buf.len() as f64 / PAGE_SIZE as f64).ceil() as usize;
let total_page = buf.len() / PAGE_SIZE;
for cur_page in 0..total_page {
let offset = if cur_page == 0 { SALT_SIZE } else { 0 };
let start: usize = cur_page * PAGE_SIZE;
let end: usize = if (cur_page + 1) == total_page {
start + buf.len() % PAGE_SIZE
} else {
start + PAGE_SIZE
};

// 搞不懂,这一堆0是干啥的,文件大小直接翻倍了
if buf[start..end].iter().all(|&x| x == 0) {
decrypted_buf.extend(&buf[start..]);
break;
}
let end: usize = start + PAGE_SIZE;

// 校验哈希
type HamcSha512 = Hmac<Sha512>;
Expand Down Expand Up @@ -1086,7 +1076,7 @@ fn cli() -> clap::Command {
use clap::{arg, value_parser, Command};

Command::new("wechat-dump-rs")
.version("1.0.19")
.version("1.0.20")
.about("A wechat db dump tool")
.author("REinject")
.help_template("{name} ({version}) - {author}\n{about}\n{all-args}")
Expand Down

0 comments on commit 0d18905

Please sign in to comment.