WeChat applet decompilation report SyntaxError: Unexpected token '}' Imperfect solution

1. Decompilation error

Recently, I am working on a small program. I refer to the WeChat applet decompilation blog of the Csdn blog, step by step, and get the .wxapkg. Execute the cmd command in the wxappUnpacker directory: node wuWxapkg.js (small program appid).wxapkg, but reported the following The error
insert image description here
reported Unexpected token '}' error, but some files can be decompiled, and the decompiled part can be opened with WeChat developer tools
insert image description here

2. Analyze the decompiled files

  1. The console reports an error that app.json is not found
  2. The js, wxss, wxml, and json files of the page are not decompiled
  3. The decompiled html is not the wxml page file of the WeChat applet
  4. Not sure what the appservice.js file is
  5. Not sure what the page-frame.html file is
  6. I don't know what the app-config.json file is.
    The index.html file is opened as follows.
    insert image description here
    The appservice.js file is opened as follows.
    insert image description here
    The page-frame.html file is opened as follows.
    insert image description here

I can't understand it at all, and then I searched this blog on the Internet, explaining what each file means, and how to solve the
"decompilation" of WeChat applets (2): Source code restoration
From this blog, I learned about appservice.js and page What do -frame.html, app-config.json mean, and I concluded that my decompilation of the applet failed.

3. Error reason

I personally launched it because the wxappUnpacker open source package is a bit old, and the WeChat applet has been updated, resulting in the failure of decompiling the wxss style file and wxml file of WeChat and reporting an exception, resulting in only a part of the decompilation, and the second half of the exception is decompiled. The code is not executed, so there are index.appservice.js and app-config.json files to be decompiled.

4. There is no perfect solution

My solution is:
use the decompile single js and config commands provided by the wxappUnpacker open source package to get js, page.json and app.json, and ignore the wxss style and wxml files.
Executing the node wuConfig.js and node wuJs.js commands in cmd went smoothly:
insert image description hereinsert image description here
while executing the node wuWxml.js and node wuWxss.js commands both failed:
insert image description here
the final decompiled project structure
insert image description here
was obtained, page(index).js, page(index ).json, app.json files, but wxml and wxss files cannot be decompiled,
but after getting the most important js file, you can almost get how the main functions of the applet are realized.

If the small program is simple, you can refer to the file that has not been completely decompiled, build an empty project by yourself, then import js, write wxml and wxss by yourself, and you can run the original small program completely, but if it is more complicated or large. It's kind of hard to do that.

I hope that some big guys will pass by and mention a perfect and feasible solution, thank you and thank you for watching

5. Small notes

Source Wechat applet "decompilation" actual combat (2): Source code restoration :
1. app-config.json:
applet project mainly includes three categories: tool configuration project.config.json, global configuration app.json and page configuration page.json JSON configuration file. in:

project.config.json is mainly used to personalize the configuration of developer tools and include some basic configurations of applet project projects, so it will not be "compiled" into the .wxapkg package;

app.json is the global configuration of the current applet, including all page paths, interface performance, network timeout, bottom tab, etc. of the applet;

page.json is used to configure the window performance of each page, and the configuration items in the page will override the same configuration items in the window of app.json.

Therefore, the "compiled" file app-config.json is actually a summary of app.json and the configuration files of each page

2. app-service.js
JS file is responsible for the interaction logic in the applet project, mainly including app.js, page.js of each page, JS files customized by the developer and imported third-party JS files. "After that all these JS files will be aggregated into the app-service.js file

3.page-frame.html
uses the WXML file to describe the structure of the page in the applet, and the WXSS file to describe the style of the page. There is an app.wxss file in the project to define some global styles, which will be automatically imported into each page; in addition, each page also contains page.wxml and page.wxss to describe the structure and style of its page; At the same time, we will also customize some public xxxCommon.wxss style files and public xxxTemplate.wxml template files for reuse by some pages, and generally import them in page.wxss and page.wxml of their respective pages.

After "compiling" the applet, all .wxml files, app.wxss and public xxxCommon.wxss style files will be integrated into the page-frame.html file, and the page.wxss style files of each page will be Generate a page.html file separately in their respective paths

4. The command node wuConfig.js <path/to/app-config.json> provided by the wxappUnpacker open source package
: split the content in app-config.json into page.json and app.json corresponding to each page;

node wuJs.js <path/to/app-service.js> : split app-service.js into a series of original independent JS files, and use the Uglify-ES beautification tool to restore the code as much as possible before "compilation" content;

node wuWxml.js [-m] <path/to/page-frame.html> : Extract and restore the .wxml and app.wxss and common .wxss style files of each page from page-frame.html;

node wuWxss.js <path/to/unpack_dir> : The command parameter is the unpacked directory of .wxapkg, it will analyze and extract and restore the page.wxss style files of each page from each page.html;

6. Related Links

I personally think that the decompilation of WeChat applets with relatively high dry goods comes from
the problems encountered in CSDN-BLOG decompiling applets and how to decompile
applets. Decompilation 2021 is available for personal testing

Guess you like

Origin blog.csdn.net/qq_34060370/article/details/124597739