Mac数据库一键解密

环境

安装brew

1
2
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
source .zprofile

安装SQLCipher

1
brew install sqlcipher

获取SQLCipher全路径

1
2
$ which sqlcipher
/opt/homebrew/bin/sqlcipher

创建自动化项目

  • 选择快速操作
    • 工作流程收到当前选择文件或文件夹
    • 位于选择访达.app
  • 添加运行Shell脚本
    • shell选择/bin/bash
    • 传递输入选作为自变量
    • 添加命令
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/opt/homebrew/bin/sqlcipher "$@" -cmd "
PRAGMA key = '密钥';

PRAGMA cipher_page_size = 1024;

PRAGMA kdf_iter = 64000;

PRAGMA cipher_hmac_algorithm = HMAC_SHA1;

PRAGMA cipher_kdf_algorithm = PBKDF2_HMAC_SHA1;

ATTACH DATABASE '$@.decrypted.db' AS plaintext KEY '';

SELECT sqlcipher_export('plaintext');

DETACH DATABASE plaintext;

exit;"

open -a 'DB Browser for SQLite' "$@.decrypted.db"
echo "end"
  • 添加结果输出

保存

如果执行无反应,可在最后添加随意一句报错代码,看弹窗输出提示