Teach you step by step how to decompile small programs

This experimental environment

Operating system: win10 10.0.19042

node: v14.17.0

WeChat developer tools: Stable 1.05.2110290

Preliminary preparation

  1. Install the simulator tool on the computer. Here we take the Night God simulator as an example.

    • Install WeChat in the simulator: used to load the mini program package when WeChat opens the mini program.
    • File manager in the simulator: used to view small program packages. Here we use the Amaze that comes with the simulator.
    • File sharing path: You can view the file sharing path through the emulator's file assistant. The Android sharing path in the emulator corresponds to the computer sharing path. The function is to facilitate subsequent finding and copying of small program packages.
      Insert image description here
  2. Download decompilation tool

    Follow the WeChat public account "Anqianmahou" and then send the keyword xcx688to get it.

Start decompiling the applet

Get the applet package

  1. Here we take the Oriental Fortune applet as an example. Log in to WeChat in the Yeshen simulator, then find and open the Oriental Fortune applet.

  2. Open the Amaze file manager in the simulator and enter the following path to find the source code package (you can distinguish the source code package you want based on the download time of the file). The hash value in the middle of different mini programs is different./data/data/com.tencent.mm/MicroMsg/7931eb2bec903760d4266d663b5fbd0e/appbrand/pkg

  3. Copy the applet file package to the simulator shared folder. For convenience, you can create a new folder first wxcodeand put the copied applet package into a folder under this folder 东方财富.


  4. Then in the shared folder on the computer, you can see the small program package you just copied.
    Insert image description here

Start unpacking

  1. Enter the root directory of the decompilation tool wxappUnpackerproject and run yarn installthe installation dependency package

  2. In wxappUnpackerthe project root directory, execute the unpack command node wuWxapkg.js <path/to/xxx.wxapkg>. A small program usually has multiple packages, and we need to find the main package. When executing the unpacking command, the following parameters need to be specific to the file name of the main package. After many experiments, we found that generally the main package _-starts with, and the file name looks different from other files.
    Insert image description here

You can see the following command line output:

$ node wuWxapkg.js ../dongFangCaiFu/_-2081057737_66.wxapkg
Unpack file ../dongFangCaiFu/_-2081057737_66.wxapkg...

Header info:
  firstMark: 0xbe
  unknownInfo:  0
  infoListLength:  6445
  dataLength:  2158356
  lastMark: 0xed

File list info:
  fileCount:  172
Saving files...
Unpack done.
Split app-service.js and make up configs & wxss & wxml & wxs...
deal config ok
deal js ok
deal html ok
deal css ok
splitJs: F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66\app-se
rvice.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 02CB91817FA2198
C64ADF986253F1537.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 0FD5E5F37FA2198
C69B38DF4E56F1537.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 11EAF9667FA2198
C778C91613F8F1537.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 1CC3D0F37FA2198
C7AA5B8F4A5BF1537.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 212D2CB47FA2198
C474B44B3E9ED1537.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 24EFAE017FA2198
C4289C606DDFE1537.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 3CE424D77FA2198
C5A824CD01A9F1537.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 44199CD77FA2198
C227FF4D0319E1537.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 4C52C3117FA2198
C2A34AB16818D1537.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 4E3F4A367FA2198
C28592231639D1537.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 50E340B47FA2198
C368528B3AD5E1537.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 5A0161E27FA2198
C3C6709E5BCAF1537.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 5B1C0EE47FA2198
C3D7A66E321EF1537.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 61219CD57FA2198
C0747F4D25F6E1537.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 6249DFF57FA2198
C042FB7F293FE1537.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 680649437FA2198
C0E602144E54F1537.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 69160F537FA2198
C0F706754BA2E1537.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 6987BC357FA2198
C0FE1D432427F1537.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 7B819AE57FA2198
C1DE7F2E233DE1537.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 8AC58DF47FA2198
CECA3E5F3B31E1537.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 8ACE1F557FA2198
CECA8775277FD1537.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 8D1643E27FA2198
CEB702BE507CD1537.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 99D2EAB27FA2198
CFFB482B564BD1537.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 @babel/runtime/
helpers/arrayLikeToArray.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 @babel/runtime/
helpers/arrayWithHoles.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 @babel/runtime/
helpers/arrayWithoutHoles.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 @babel/runtime/
helpers/asyncToGenerator.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 @babel/runtime/
helpers/defineProperty.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 @babel/runtime/
helpers/interopRequireDefault.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 @babel/runtime/
helpers/iterableToArray.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 @babel/runtime/
helpers/iterableToArrayLimit.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 @babel/runtime/
helpers/nonIterableRest.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 @babel/runtime/
helpers/nonIterableSpread.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 @babel/runtime/
helpers/objectSpread2.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 @babel/runtime/
helpers/slicedToArray.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 @babel/runtime/
helpers/toConsumableArray.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 @babel/runtime/
helpers/typeof.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 @babel/runtime/
helpers/unsupportedIterableToArray.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 @babel/runtime/
regenerator.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 A2A31AD37FA2198
CC4C572D43E9E1537.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 A2E1F3817FA2198
CC4879B86A08E1537.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 ADC668017FA2198
CCBA0000675CF1537.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 B33469017FA2198
CD552010620FF1537.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 B4790A047FA2198
CD21F6203CEAE1537.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 C6F555147FA2198
CA0933D13385F1537.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 C7D2F7C37FA2198
CA1B49FC4CE1F1537.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 C92323547FA2198
CAF454B537B2F1537.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 D5D51E667FA2198
CB3B37661A5AD1537.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 D7E073717FA2198
CB1861B76F3EE1537.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 DD9D93E57FA2198
CBBFBFBE2D12E1537.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 E174D1B77FA2198
C8712B9B0BC0F1537.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 E48C9AB07FA2198
C82EAF2B73D3E1537.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 E9AA86447FA2198
C8FCCEE438F4E1537.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 F19F4B857FA2198
C97F92382008F1537.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 F4E555647FA2198
C92833D6310CE1537.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 F917D9857FA2198
C9F71B182FFCF1537.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 FE8EF1457FA2198
C98E8994269DD1537.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 FF3491C77FA2198
C9952F9C0870E1537.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 app.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 components/base
-modal/modal.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 components/call
-login-modal/call-login-modal.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 components/down
form/downform.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 components/foot
bar-share/footbar-share.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 components/foot
bar/footbar.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 components/imag
e-share copy/image-share.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 components/imag
e-share/image-share.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 components/kaih
uform/kaihuform.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 components/logi
n-modal/login-modal.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 components/moda
l/modal.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 components/navb
ar/navbar.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 components/navi
gator/navigator.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 components/open
app copy/openapp.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 components/open
app/openapp.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 components/stoc
k-list/stock-list.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 components/user
/user.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 components/zhi-
shu/zhi-shu.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 pages/download
copy/download.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 pages/index/ind
ex.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 pages/kaihu/kai
hu.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 pages/kaihuDeta
il/kaihuDetail.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 pages/download/
download.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 pages/market/ma
rket.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 pages/stockDeta
il/stockDetail.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 pages/gubaDetai
l/gubaDetail.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 pages/protocol/
index.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 pages/LoginInde
x/LoginIndex.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 pages/timeShare
/timeShare.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 pages/timeShare
HK/timeShareHK.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 pages/timeShare
US/timeShareUS.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 pages/SearchPag
e/SearchPage.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 pages/informati
onDetail/informationDetail.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 pages/LoginPage
/Login.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 pages/My/My.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 pages/Bindinged
EMPage/BindingedEMPage.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 pages/zixun/zix
un.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 pages/zixunDeta
il/zixunDetail.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 pages/gubaPost/
gubaPost.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 pages/loginByTe
l/loginByTel.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 pages/BPTest/BP
Test.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 pages/viewDialo
g/viewDialog.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 pages/test/test
.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 pages/bankuai/b
ankuai.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 pages/data/data
.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 pages/me/me.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 pages/error/err
or.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 pages/Agreement
View/AgreementView.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 pages/fissionkh
Auth/fissionkhAuth.js
F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66 pages/fissionkh
AuthSucc/fissionkhAuthSucc.js
Splitting "F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66\app-
service.js" done.
Decompile ./components/base-modal/modal.wxml...
Decompile success!
Decompile ./components/call-login-modal/call-login-modal.wxml...
Decompile success!
Decompile ./components/downform/downform.wxml...
Decompile success!
Decompile ./components/footbar-share/footbar-share.wxml...
Decompile success!
Decompile ./components/footbar/footbar.wxml...
Decompile success!
Decompile ./components/image-share copy/image-share.wxml...
Decompile success!
Decompile ./components/image-share/image-share.wxml...
Decompile success!
Decompile ./components/kaihuform/kaihuform.wxml...
Decompile success!
Decompile ./components/login-modal/login-modal.wxml...
Decompile success!
Decompile ./components/modal/modal.wxml...
Decompile success!
Decompile ./components/navbar/navbar.wxml...
Decompile success!
Decompile ./components/navigator/navigator.wxml...
Decompile success!
Decompile ./components/openapp copy/openapp.wxml...
Decompile success!
Decompile ./components/openapp/openapp.wxml...
Decompile success!
Decompile ./components/stock-list/stock-list.wxml...
Decompile success!
Decompile ./components/user/user.wxml...
Decompile success!
Decompile ./components/zhi-shu/zhi-shu.wxml...
Decompile success!
Decompile ./pages/AgreementView/AgreementView.wxml...
Decompile success!
Decompile ./pages/BPTest/BPTest.wxml...
Decompile success!
Decompile ./pages/BindingedEMPage/BindingedEMPage.wxml...
Decompile success!
Decompile ./pages/LoginIndex/LoginIndex.wxml...
Decompile success!
Decompile ./pages/LoginPage/Login.wxml...
Decompile success!
Decompile ./pages/My/My.wxml...
Decompile success!
Decompile ./pages/SearchPage/SearchPage.wxml...
Decompile success!
Decompile ./pages/bankuai/bankuai.wxml...
Decompile success!
Decompile ./pages/data/data.wxml...
Decompile success!
Decompile ./pages/download copy/download.wxml...
Decompile success!
Decompile ./pages/download/download.wxml...
Decompile success!
Decompile ./pages/error/error.wxml...
Decompile success!
Decompile ./pages/fissionkhAuth/fissionkhAuth.wxml...
Decompile success!
Decompile ./pages/fissionkhAuthSucc/fissionkhAuthSucc.wxml...
Decompile success!
Decompile ./pages/gubaDetail/gubaDetail.wxml...
Decompile success!
Decompile ./pages/gubaPost/gubaPost.wxml...
Decompile success!
Decompile ./pages/index/index.wxml...
Decompile success!
Decompile ./pages/informationDetail/informationDetail.wxml...
Decompile success!
Decompile ./pages/kaihu/kaihu.wxml...
Decompile success!
Decompile ./pages/kaihuDetail/kaihuDetail.wxml...
Decompile success!
Decompile ./pages/loginByTel/loginByTel.wxml...
Decompile success!
Decompile ./pages/market/market.wxml...
Decompile success!
Decompile ./pages/me/me.wxml...
Decompile success!
Decompile ./pages/protocol/index.wxml...
Decompile success!
Decompile ./pages/stockDetail/stockDetail.wxml...
Decompile success!
Decompile ./pages/test/test.wxml...
Decompile success!
Decompile ./pages/timeShare/timeShare.wxml...
Decompile success!
Decompile ./pages/timeShareHK/timeShareHK.wxml...
Decompile success!
Decompile ./pages/timeShareUS/timeShareUS.wxml...
Decompile success!
Decompile ./pages/viewDialog/viewDialog.wxml...
Decompile success!
Decompile ./pages/zixun/zixun.wxml...
Decompile success!
Decompile ./pages/zixunDetail/zixunDetail.wxml...
Decompile success!
Guess wxss(first turn)...
Regard F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66\app.wxss
 as pure import file.
Regard F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66\pages\ba
nkuai\bankuai.wxss as pure import file.
Regard F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66\pages\gu
baDetail\gubaDetail.wxss as pure import file.
Regard F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66\pages\ti
meShare\timeShare.wxss as pure import file.
Import count info: {
    
    "./app.wxss":7,"./pages/index/index.wxss":5,"./pages/gubaD
etail/gubaDetail.wxss":2,"./timeShareCommon.wxss":4}
Guess wxss(first turn) done.
Generate wxss(second turn)...
Generate wxss(second turn) done.
Save wxss...
saveDir: F:\webstormProjects\mini-program\dongFangCaiFu\_-2081057737_66
Split and make up done.
Delete files...
Deleted.

File done.
Total use: 5.626s
  1. If you want to perform decompilation of config, js, wxml, and wxss separately, you can add the -o parameter when unpacking without performing subsequent operations.

  2. Usage of other scripts of the tool:

    • node wuConfig.js <files...>Split the content in app-config.json into .json and app.json corresponding to each file, and try to restore iconData to iconPath by searching all files in the folder where app-config.json is located.
    • node wuJs.js <files...>Split app-service.js (or game.js in mini-games) into a series of original independent javascript files, and use Uglify-ES to beautify them to restore the pre-compilation situation as much as possible.
    • node wuWxml.js [-m] <files...>Restore wxml and wxs files compiled/mixed into page-frame.html (or app-wxss.js) into separate, uncompiled files. If you add -mthe directive, it will prevent blockthe block from being automatically omitted, which may help solve some bugs in the related process.
    • node wuWxss.js <dirs...>By obtaining the contents of page-frame.html (or app-wxss.js) and other html files in the folder, restore the contents of the wxss file before compilation.
    • node wuWxapkg.js [-o] [-d] [-s=<Main Dir>] <files...>Unpack the wxapkg file and automatically restore the compiled/mixed files in the package as mentioned in the above command. If -othe instruction is added, it means only unpacking and no subsequent operations. If -dthe directive is added, the new files generated after compilation/mixing will be retained, otherwise these files will be automatically deleted. At the same time, the instructions in the previous command can also be added directly to this command.

Import developer tools

Open the WeChat developer tools and import the project.

After unpacking this Oriental Fortune applet, pay attention to 详情--->本地设置the

  • Uncheck e6 to convert to es5 (this small program does not seem to use es6 syntax)
  • Note that check does not verify legal domain names

Unpacking other small programs may have slightly different project configurations and multiple debugging.

Extended summary

Unpacking the trial version

For the trial version, you need to find the file starting with debug (in the form: debug_xxx without a suffix), then get the file and manually add the wxapkg suffix and perform the above operations to complete the unpacking.

When unpacking, it prompts that it is a sub-package.

Solution: Some small programs may adopt a sub-packaging strategy, so there is a main package and multiple sub-packages. After many experiments, we found that generally the main package _-starts with, and the file name looks different from other files.

Insert image description here

write at the end

That’s all for sharing today’s dry stuff. Welcome to click three links and continue to pay attention to "An Qian Ma Hou", a technical account that only outputs dry information instead of following the crowd. In addition, the money-making account "Lei Shield" is also under continuous development. Those who are interested in investing can pay attention first. It is definitely a good thing. Come on, you guys.

Guess you like

Origin blog.csdn.net/KOOK007/article/details/129784426