微信小程序反编译/解包
环境与工具
操作系统:Windows 11 23H2
微信版本:3.9.10.19
Q:如何找到小程序文件位置?
A:在微信的设置找到文件路径,小程序文件位于 \WeChat Files\Applet\
。
Q:小程序目录下文件太多了,找不到要解包的小程序?
A:使用 wxapkg 的 scan 功能,联网状态下会获取小程序名称。或者删除目录下所有文件再打开一次小程序。
wxapkg
⚠ 只支持 Windows 系统
安装
从 Github Release 下载可执行文件,或者下载源码编译。
使用
程序的使用说明。
|-------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | > .\wxapkg.exe
-h
A tool to scan and decrypt wechat mini program
Usage:
``wxapkg ``[command]
Available Commands:
``help Help about any command
``scan Scan the wechat mini program
``unpack Decrypt wechat mini program
Flags:
``--``disable-beautify
disable js,html,json beautify
``-h``, --help help ``for
wxapkg
``-v``, --version version ``for
wxapkg
Use ``"wxapkg [command] --help"
for
more information about a command.
|
使用 scan 功能解包小程序。
|----------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | # scan 功能会扫描指定目录下所有的小程序,选择解包。
> .\wxapkg.exe scan --help
Scan the wechat mini program
Usage:
``wxapkg scan ``[flags]
Examples:
``wxapkg.exe scan
-r
"D:\WeChat Files\Applet\wx12345678901234"
# 扫描小程序文件所在路径
> .\wxapkg.exe scan
-r
"D:\WeChat Files\Applet"
# 打印目录下的小程序,使用上下按键选择,回车确认。
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Name Developer Description ┃
┃────────────────────────────────────────────────────────┃
┃ 跳一跳 深圳市腾讯计算机系统有限公司 比比看,谁跳得更远 ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
``wxid: wx7c8d593b2c3a7703
``Name: 跳一跳
``Developer: 深圳市腾讯计算机系统有限公司
``Description: 比比看,谁跳得更远
``Location: D:\WeChat Files\Applet\wx7c8d593b2c3a7703
``Avatar: https://wx.qlogo.cn/mmhead/Q3auHgzwzM5GNaPCYMrxHaFLkh3kTduKFFbPlNmeHdkly2QlZLmtibQ/0
``All information see ``'.\wxid.json'
``enter unpack • ↑/k move up • ↓/j move down • q exit
# 选中后开始解包。
[+] unpack root ``'D:\WeChat Files\Applet\wx7c8d593b2c3a7703'
with 30 threads
[+] unpacked 185 files from ``'wx7c8d593b2c3a7703\92\__WITHOUT_MULTI_PLUGINCODE__.wxapkg'
[+] all 185 files saved to ``'wx7c8d593b2c3a7703'
[+] mini program detail info saved to ``'wx7c8d593b2c3a7703\detail.json'
[+] extension statistics:
``- .png 153
``- .mp3 22
``- .jpg 5
``- .json 3
``- .js 1
``- .ttf 1
``# 解包结果在当前目录下 wx 开头文件夹。
> ls .\wx7c8d593b2c3a7703\
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 2024/1/1 11:11 92
-a``--- 2024/1/1 11:11 302 detail.json
|
使用 unpack 功能解包小程序。
|-------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | # unpack 功能用于手动指定小程序和解包输出目录。
.\wxapkg.exe unpack
-h
Decrypt wechat mini program
Usage:
``wxapkg unpack ``[flags]
Examples:
``wxapkg.exe unpack
-o
unpack
-r
"D:\WeChat Files\Applet\wx12345678901234"
Flags:
``-h``, --help help ``for
unpack
``-o``, --output string the output path to save result (``default
"unpack"``)
``-r``, --root string the mini progress path you want to decrypt, see: C:\Users\Null\Documents\WeChat Files\Applet\wx00000000000000
``-n``, --thread int the thread number (``default
30)
Global Flags:
``--``disable-beautify
disable js,html,json beautify
# 不指定输出路径,指定要解包的小程序。
> .\wxapkg.exe unpack
-r
"D:\WeChat Files\Applet\wx7c8d593b2c3a7703\"
[+] unpack root ``'D:\WeChat Files\Applet\wx7c8d593b2c3a7703\'
with 30 threads
[+] unpacked 185 files from ``'92\__WITHOUT_MULTI_PLUGINCODE__.wxapkg'
[+] all 185 files saved to ``'unpack'
[+] extension statistics:
``- .png 153
``- .mp3 22
``- .jpg 5
``- .json 3
``- .ttf 1
``- .js 1
# 不指定输出路径的情况下,默认解压到当前目录的 unpack 文件夹。
> ls .\unpack\
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 2024/1/1 11:11 92
# 可以使用 -o 参数指定输出路径。
|
查看解包结果。
|-------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # 解包结果没有小程序原始工程文件结构,关键代码在 game.js 文件。
> tree .\unpack\92\ /f
D:\WXAPKG\UNPACK\92
│ app-config.json
│ game.js
│ package-lock.json
│ package.json
│
└─res
``│ 0.png
``│ 1.png
``│ ......
``├─2d
``│ 555.png
``│ auth.png
``│ ......
``└─auth
``rank_tip.png
``refresh.png
|
unveilr
⚠新版功能更丰富,但转为闭源,订阅制收费。本文使用 2.0 免费版本。
安装
付费使用最新版,免费使用流传最后一版免费版本。
使用
程序功能帮助。
|----------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | > .\unveilr.exe
-h
Usage: unveilr ``[wx] [options]
Options:
``-v``, --version output the version number
``-l``, --log-level <level> Set log level (choices: ``"debug"``, ``"info"``, ``"warn"``, ``"error"``, ``default``: ``"info"``)
``-h``, --help display help ``for
command
Commands:
``wx ``[options]
<packages...> Decompile the WeChat applet
``help ``[command]
display help ``for
command
Example:
``$ unveilr /path/to/wxapkg/dir/
``$ unveilr 1.wxapkg 2.wxapkg 3.wxapkg ...
``$ unveilr wx /path/to/wxapkg/dir/ Specify wx subcommand
``$ unveilr wx 1.wxapkg 2.wxapkg 3.wxapkg ... Specify wx subcommand
``$ unveilr wx
-h
Show wx help info
|
解包使用。
|-------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 1 2 3 4 5 6 | # 提供小程序包 wxapkg 所在路径直接解包,结果在目标小程序同路径下(\WeChat Files\Applet\wx000\01\)。
# 允许多个包输入或者一个路径。
> .\unveilr.exe ``"D:\WeChat Files\Applet\wx7c8d593b2c3a7703\92\"
[INFO]
00:29:08 <Core> From D:\WeChat Files\Applet\wx7c8d593b2c3a7703\92\__WITHOUT_MULTI_PLUGINCODE__.wxapkg detected wxAppId: wx7c8d593b2c3a7703
[INFO]
00:29:08 <Core> The package D:\WeChat Files\Applet\wx7c8d593b2c3a7703\92\__WITHOUT_MULTI_PLUGINCODE__.wxapkg type is: ``[GAME]
[INFO]
00:29:10 <Bucket> Storage has written 338 files
|
wx 子命令支持更多操作。
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | > .\unveilr.exe wx
-h
Usage: unveilr wx ``[options]
<packages...>
Decompile the WeChat applet
Arguments:
``packages Set package path, could be a file, directory or multiple files
Options:
``-i``, --appid <appid> Set wxAppId, not provided will try to fetch from path
``-f``, --format Enable format code
``--no-``clear-decompile
Retain decompiling residual files
``--no-``clear-save
The path to be saved will not be cleared
``-p``, --no-parse Only extract files, ``do
not parse
``-d``, --depth <depth> Set ``read-depth
(``default``: 1)
``-o``, --output <path> Set output path, ``default``: main package whit out
``--``clear-output
Empty the specified output folder
``-h``, --help display help ``for
command
# 解包小程序并输出到 .\tyt,同时格式化输出得到小程序原有结构。
> .\unveilr.exe wx ``"D:\WeChat Files\Applet\wx7c8d593b2c3a7703\92\"
-o
.\tyt ``-f
[WARN]
00:38:52 <Bucket> Turning on code formatting can slow down some operations
[INFO]
00:38:52 <Core> From D:\WeChat Files\Applet\wx7c8d593b2c3a7703\92\__WITHOUT_MULTI_PLUGINCODE__.wxapkg detected wxAppId: wx7c8d593b2c3a7703
[INFO]
00:38:52 <Core> The package D:\WeChat Files\Applet\wx7c8d593b2c3a7703\92\__WITHOUT_MULTI_PLUGINCODE__.wxapkg type is: ``[GAME]
[INFO]
00:38:57 <Bucket> Storage has written 338 files
# 解包结果有小程序原始工程文件结构,可以看到文件排布。
> tree .\tyt\ /f
D:\WXAPK\UNVEILR\TYT
│ game.js
│ game.json
│ package-lock.json
│ package.json
│
├─``@babel
│ └─runtime
│ └─helpers
│ Arrayincludes.js
│ ......
│
├─js
│ │ block.js
│ │ ......
│ │
│ ├─control
│ │ battleCtrl.js
│ │ ......
│ │
│ │ ......
│ │
│ └─util
│ common.js
│ encryption.js
│ forceUpdate.js
│ log.js
│ util.js
│
└─res
``│ ......
``│
``└─auth
``rank_tip.png
``refresh.png
|