1 Star 0 Fork 17

ruowind/wxpc-miniprogram-decryption

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
wxmd.js 1.84 KB
一键复制 编辑 原始数据 按行查看 历史
猫头猫 提交于 2020-10-27 11:28 . fix: typo
const fs = require('fs').promises;
const crypto = require('crypto');
const path = require('path');
const program = require('commander');
const chalk = require('chalk');
// consts
const salt = 'saltiest';
const iv = 'the iv: 16 bytes';
// main
const wxmd = async (wxid, pkgsrc, pkgdst) => {
try {
const buf = await fs.readFile(pkgsrc);
const bufHead = buf.slice(6, 1024 + 6);
const bufTail = buf.slice(1024 + 6);
// handle head part
const dk = await new Promise((resolve, reject) => {
crypto.pbkdf2(wxid, salt, 1000, 32, 'sha1', (err, dk) => {
if (err) {
reject(err);
}
resolve(dk);
})
})
const decipher = crypto.createDecipheriv('aes-256-cbc', dk, iv);
const originalHead = Buffer.alloc(1024, decipher.update(bufHead));
// handle tail part
const xorKey = wxid.length < 2 ? 0x66 : wxid.charCodeAt(wxid.length - 2);
const tail = [];
for(let i = 0; i < bufTail.length; ++i){
tail.push(xorKey ^ bufTail[i]);
}
const originalTail = Buffer.from(tail);
// write to file
pkgdst = pkgdst || '.'
const fstate = await fs.lstat(pkgdst);
if(fstate.isDirectory()){
pkgdst = path.join(pkgdst, `/decrypt_${wxid}.wxapkg`);
}
await fs.writeFile(pkgdst, Buffer.concat([originalHead, originalTail]), 'binary');
console.log(chalk.green('解码完成'))
} catch (err) {
console.log(chalk.red(`错误: ${err}`));
}
}
program
.command('decry <wxid> <src> [dst]')
.description('解码PC端微信小程序包')
.action((wxid, src, dst) => {
wxmd(wxid, src, dst);
})
program.version('1.0.0')
.usage("decry <wxid> <src> [dst]")
.parse(process.argv);
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ruowind/wxpc-miniprogram-decryption.git
git@gitee.com:ruowind/wxpc-miniprogram-decryption.git
ruowind
wxpc-miniprogram-decryption
wxpc-miniprogram-decryption
master

搜索帮助