一、node.js运行环境
1 |
安装node.js地址:nodejs.org/en/ |
二、下载反编译脚本
1 2 |
https<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span>pan<span class="token punctuation">.</span>baidu<span class="token punctuation">.</span>com<span class="token operator">/</span>s<span class="token operator">/</span><span class="token number">1</span>XE6fM4vSMbrYzyIgHV1J1w <a href="https://longsheng.org/wp-content/uploads/2022/04/wxappUnpacker-master.zip" rel="">wxappUnpacker-master</a> |
三、安装模拟器
1 2 |
下载夜神模拟器或其他android模拟器(推荐),下载微信,登录微信,打开你要编译的小程序,退回界面,点击文件管理器, |
1 2 |
文件在 <span class="token operator">/</span><span class="token keyword">data</span><span class="token operator">/</span><span class="token keyword">data</span><span class="token operator">/</span>com<span class="token punctuation">.</span>tencent<span class="token punctuation">.</span>mm<span class="token operator">/</span>MicroMsg<span class="token operator">/</span>一串<span class="token number">32</span>位的<span class="token number">16</span>进制字符串文件夹<span class="token operator">/</span>appbrand<span class="token operator">/</span>pkg<span class="token operator">/</span> 下<span class="token punctuation">,</span>根据时间找到源文件包压缩后,选中你要的小程序<span class="token punctuation">.</span>wxapkg文件, |
1 2 |
退回根目录,进入 /mnt/shared/Other/ ,把.wxapkg文件粘贴在这 |
1 2 |
然后打开电脑分享文件夹,然后把.wxapkg文件复制到你想放的地方 |
1 2 3 4 5 6 7 8 9 |
然后win+R,输入cmd,回车,打开命令窗口,cd到编译脚本的目录,依次输入以下命令 npm install esprima npm install css-tree npm install cssbeautify npm install vm2 npm install uglify-es npm install js-beautify 安装好依赖之后,就是最后一步了,反编译 .wxapkg 文件 在当前目录下输入命令:node .\wuWxapkg.js F:\zyt_file\_-472979937_90.wxapkg(_-472979937_90.wxapkg是你需要反编译的源文件) |
1 2 3 4 |
如果出现 Cannot find module 'xxx' 表示模块未安装 运行命令 npm install 'xxx' , 安装依赖 如果遇到 __vd_version_info__ is not defined这种报错 解决方法如下: |
修改反编译脚本wuWxss.js代码,将原代码
1 2 3 4 5 6 7 8 9 |
function runVM(name,code){ let wxAppCode={},handle={cssFile:name}; let vm=new VM({sandbox:Object.assign(new GwxCfg(),{__wxAppCode__:wxAppCode,setCssToHead:cssRebuild.bind(handle)})}); vm.run(code); for(let name in wxAppCode)if(name.endsWith(".wxss")){ handle.cssFile=path.resolve(frameName,"..",name); wxAppCode[name](); } } |
修改为
1 2 3 4 5 6 7 8 9 10 11 |
function runVM(name,code){ let wxAppCode={},handle={cssFile:name}; let gg = new GwxCfg(); let tsandbox ={$gwx:GwxCfg.prototype["$gwx"],__mainPageFrameReady__:GwxCfg.prototype["$gwx"],__wxAppCode__:wxAppCode,setCssToHead:cssRebuild.bind(handle)}; let vm = new VM({sandbox:tsandbox}); vm.run(code); for(let name in wxAppCode)if(name.endsWith(".wxss")){ handle.cssFile=path.resolve(frameName,"..",name); wxAppCode[name](); } } |
或者修改这个,将原代码
1 2 3 |
function runOnce(){ for(let name in runList)runVM(name,runList[name]); } |
修改为
1 2 3 4 5 6 7 8 9 10 11 12 |
function runOnce() { for (let name in runList) { // console.log(name, runList[name]); var start = `var window = window || {}; var __pageFrameStartTime__ = Date.now(); var __webviewId__; var __wxAppCode__={}; var __mainPageFrameReady__ = function(){}; var __WXML_GLOBAL__={entrys:{},defines:{},modules:{},ops:[],wxs_nf_init:undefined,total_ops:0}; var __vd_version_info__=__vd_version_info__||{}; $gwx=function(path,global){ if(typeof global === 'undefined') global={};if(typeof __WXML_GLOBAL__ === 'undefined') {__WXML_GLOBAL__={}; }__WXML_GLOBAL__.modules = __WXML_GLOBAL__.modules || {}; }`; runVM(name, start + " \r\n" + runList[name]); } } |
参考地址
1 2 3 4 |
反编译流程参考地址: [https://baijiahao.baidu.com/s?id=1626150833428399320&wfr=spider&for=pc](https://baijiahao.baidu.com/s?id=1626150833428399320&wfr=spider&for=pc) __vd_version_info__ is not defined错误解决方法参考地址: [https://blog.csdn.net/weixin_43764814/article/details/91135302](https://blog.csdn.net/weixin_43764814/article/details/91135302) |