Crawling the online code of the applet

Crawling the online code of the applet

For some reason, I lost part of the small program code, but the program runs normally online, so I found a tool that can crawl the online code and slowly decompile it back.

Tools needed

Prepare the environment

  1. Install Night God (nothing to say)
  2. Open the Android emulator, install 微信, andRE文件浏览器
  3. The root permission to open the emulator (for the RE file browser to find files inside) is actually enabled by default, just confirm it yourself

Insert picture description here

  1. Log in to WeChat and open the corresponding applet (if the applet has subcontracting, you need to trigger the subcontracting, and click everywhere)

Get wxapkg

Open what we have installed RE文件浏览器. If you want root privileges, remember to pass the instructions
in wxappUnpacker . It is already very clear. But there is one thing that may be confused, and that is the directory file of the file!

Original: The required wxapkg file is in /data/data/com.tencent.mm/MicroMsg//appbrand/pkg/ in this directory

Pit : Attention MicroMsg//appbrand/. After the MicroMsgdouble slash! Then the content inside is uncertain. How to understand this sentence, look at the following picture:

Insert picture description here

  • We want to file in 6d98xxxxxb6a folder inside. And there is another directory at the same level appbrand. This is easy to enter appbrand. Found that the corresponding file could not be found
  • Secondly, the folder corresponding to each applet is different, so you can judge by yourself according to the modification time of the folder!
  • There is also the question of why root privileges are required: if you do not give root privileges, you may not be able to enter, or you may not have to copy files if you enter, so remember to give root at the beginning

2020/6/11 Update Why re file manager needs root privileges. Because we need to change all file permissions to 7777, in the pkg file directory, long press, modify permissions, and tick all permissions. If you are a bit linux-based, you know the meaning of 777. If you don’t select 777 for permissions After copying the file, it still cannot be used!

After understand the directory structure, continue to the next step, find our wxapkgfile
Insert picture description here

There may be more than one small program wxapkg. Because there may be subcontracting.

  • Go back to the pkg folder, long press, compress,
  • Then find the location of the compressed package, long press and send to WeChat.
  • Log in to WeChat on the computer, and send the compressed pkg package to the computer in the file transfer assistant

Choose a handy tool

The following tools all need node support. If a development computer doesn't even have a node environment, it won't be justified~ Install node and skip it.

At the beginning of the article, there are two libraries mentioned, but they are actually encapsulated based on the same library
. The original library no longer exists, but you can still download the source code in replace. If you are interested, please see https://github.com/qwerty472123/wxappUnpacker/releases

CrackMinApp

Link: https://github.com/Cherrison/CrackMinApp

advantage:

  • Graphical interface
  • Completely out of command line operation

Disadvantages:

  • Unable to resolve subcontract
  • It must be placed in the root directory of Disk D before it can be used.

After downloading, the author also said very clearly, put the package in pkg into the specified directory, then open the graphical interface, click to analyze

Because there are many packages, the resolution and order do not matter. For example, if there are 10 packages, which package is parsed first is OK. But he can only parse the main package, not the sub-package. Only the corresponding directory structure and .html files are parsed, and there is no JS and wxss we want. wxml

but!After tossing for so long, how could it be possible to give up here! Next is the focused library wxappUnpacker!

wxappUnpacker

Link: https://github.com/xuedingmiaojun/wxappUnpacker

advantage:

  • Support subcontract analysis

Disadvantages:

  • emmm. No disadvantages!

After downloading on github:
Insert picture description here

  • Install node dependencies
npm install
  • pkgUnzip the folder of our small program (this is the package taken out in Yeshen) and put it in the root directory pkg of the library (actually, I can put it anywhere, I just find it for myself~)

  • Start decompiling
    in the directory of the downloaded library

./bingo.sh ./pkg/你的小程序代码包.wxapk -s=./
  1. ./pkg/你的小程序代码包.wxapk This is the path of your code package
  2. -s It is for parsing sub-packages. Of course, the main package can also be parsed, so all add, -s is followed by the output path of the parsed sub-package. I asked him to output it to the corresponding directory.

If there are a lot of code packages, don't you want to get soft? What if I got the first one if I remember it wrong!

In the Linux/Shellenvironment, the command-line best in the world! Let's introduce batch analysis! . The premise is that there is a shell environment, gitbash can also be used

for wxpkg in ./pkg/*.wxapkg;do ./bingo.sh $wxpkg -s=./;done
  • for in loop
  • All in ./pkg directory to .wxapkgthe end of the file
  • Execute the compile command, which $wxpkgis the variable name of for in.
  • Unzip the old rules to the current package directory
  • There may be some errors after execution, emmm did not go into it

Insert picture description here

Results of the:
Insert picture description here

Although an exception was thrown, our code is still generated. Look at the following directory:
Insert picture description here

Entering a certain subcontract is also OK
Insert picture description here

Why the json file corresponding to the directory is gone!

The json files are parsed in the main package, because the json file may be configured with some components. You can search for *.json in the pkg directory to find out who is the main package~

Can the crawled code run?

I haven't tried this yet~. Because I just want to find some code that I am missing. But what is certain is that the wxml.wxss.json file is intact, followed by the js file, which must have been packaged and compressed. It can’t be said that I can’t understand it, but the variable name is compressed. After restoring according to the directory structure, the corresponding resource is successfully imported and it can still run.

I hope everyone will not lose the code, after all, the compressed JS looks really uncomfortable~

Guess you like

Origin blog.csdn.net/Jioho_chen/article/details/105121377