0%

Decompile the source code of WeChat applet

Decompile the source code of WeChat applet

This article records the process of obtaining the source code of the WeChat applet through decompilation.

1. Environmental preparation

  1. Download node.js, go directly to official website to download

  2. Decompiled script

    Provided directly here, click link to download, and unzip after downloading

  3. Mobile phone simulator

  4. RE file manager (not required), I think this is better to operate

3. Find the WeChat applet source file package

In the following directory,

/data/data/com.tencent.mm/MicroMsg/{{a 32-bit hexadecimal string folder}}/appbrand/pkg/

You will find some files of type xxxxxxx.wxapkg, these are the packages of the WeChat applet

Determine the source file package based on time

4. Transfer the source file to the computer

It can be shared through the file sharing of the night god simulator, or you can install QQ, compress the source file and transfer it to the computer

5. Find the storage directory of the decompiled script just unzipped, then win+R open the following window and enter cmd

Click OK, cd to this storage directory, enter the following command to install dependencies

npm install esprima
npm install css-tree
npm install cssbeautify
npm install vm2
npm install uglify-es

6. Decompile the .wxapkg file

node .\wuWxapkg.js D:\_-472979937_90.wxapkg
D:\_-472979937_90.wxapkg change to the absolute directory where you store the source files

Just run it, the following figure shows the successful operation

7. About errors

If Cannot find module'xxx' appears, it means the module is not installed
Run the command npm install'xxx', install dependencies
If you encounter an error like __vd_version_info__ is not defined
The solution is as follows:

Modify the code of the decompiled script wuWxss.js and replace the original code

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]();
}
}

To

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]();
}
}

8. Generate a folder after decompilation, which is the same directory as the source file

Open the WeChat developer tool and import the applet

Remarks:
Other platform applets can try on their own

-------------The end of this articleThank you for your reading-------------