以一個簡單的例子(中銀E路通小程序)介紹下小程序反編譯操作流程
實驗環境
- 操作系統:macOS10.13.6
- node:v10.8.0
- 微信開發者工具:Stable v1.02.1910120
前置準備
- 需要安裝pc端模擬器工具可以選擇網易MuMu,或者其它模擬器
- 模擬器設置中配置共享文件夾
- 下載反編譯工具wxAppUnpacker
模擬器內軟件安裝
需要安裝以下兩個軟件
安裝APP
- RE文件管理器(查看小程序壓縮包)
- 微信(使用微信打開小程序以下載小程序包)
獲取小程序包
1.使用自己手機上的微信打開"中銀E路通"小程序,可以添加到"我的小程序";
2.打開模擬器的微信并登錄;
3.在模擬器微信的下拉小程序最近使用歷史中打開"中銀E路通",如果歷史記錄中沒有就在我的小程序中找一找;
4.打開小程序等待加載之后就可以去找源碼包了;
5.打開RE文件管理器,進入到以下路徑查找源碼包(可以根據下載時間區分出你想要的源碼包);
/data/data/com.tencent.mm/MicroMsg/4c8188dbf07eec893d0ac90974657aeb/appbrand/pkg
6.拷貝小程序包至模擬器共享文件夾,為了方便解包重命名為zyel
小程序包
獲取完畢。
開始解包
解包流程
1.進入克隆下來的反編譯工具根目錄
如果沒有安裝過npm包就先執行安裝
npm install
2.解包
node wuWxapkg.js <path/to/zyel.wxapkg>
可以看到命令行輸出如下提示
Unpack file zyel2.wxapkg... Header info: firstMark: 0xbe unknownInfo: 0 infoListLength: 1547 dataLength: 971189 lastMark: 0xed File list info: fileCount: 42 { name: '/components/home/images/home-icon1.png', off: 1561, size: 2969 } { name: '/components/home/images/home-load-btn.png', off: 4530, size: 235 } { name: '/components/key/imgs/back.png', off: 4765, size: 4369 } { name: '/images/arrow-right.png', off: 9134, size: 223 } { name: '/images/detailsCoins-btn1-ac.png', off: 9357, size: 1180 } { name: '/images/detailsCoins-btn1.png', off: 10537, size: 614 } { name: '/images/detailsCoins-btn2-ac.png', off: 11151, size: 936 } { name: '/images/detailsCoins-btn2.png', off: 12087, size: 546 } { name: '/images/home-ac.png', off: 12633, size: 2281 } { name: '/images/home.png', off: 14914, size: 1565 } { name: '/images/mine-ac.png', off: 16479, size: 2324 } { name: '/images/mine-icon1.png', off: 18803, size: 1115 } { name: '/images/mine-icon3.png', off: 19918, size: 852 } { name: '/images/mine-icon4.png', off: 20770, size: 1038 } { name: '/images/mine-icon5.png', off: 21808, size: 1039 } { name: '/images/mine-icon6.png', off: 22847, size: 9137 } { name: '/images/mine-icon7.png', off: 31984, size: 1796 } { name: '/images/mine.png', off: 33780, size: 1682 } { name: '/images/ranking-one.png', off: 35462, size: 4883 } { name: '/images/ranking-three.png', off: 40345, size: 4993 } { name: '/images/ranking-two.png', off: 45338, size: 4928 } { name: '/images/shop-ac.png', off: 50266, size: 2393 } { name: '/images/shop.png', off: 52659, size: 1807 } { name: '/app-config.json', off: 54466, size: 18010 } { name: '/app-service.js', off: 72476, size: 728734 } { name: '/pages/CSR/CSR.html', off: 801210, size: 3759 } { name: '/pages/card/card.html', off: 804969, size: 5518 } { name: '/pages/coinRecord/coinRecord.html', off: 810487, size: 3832 } { name: '/pages/coinShop/coinShop.html', off: 814319, size: 469 } { name: '/pages/detailsCoins/detailsCoins.html', off: 814788, size: 4498 } { name: '/pages/home/home.html', off: 819286, size: 5043 } { name: '/pages/integralDec/integralDec.html', off: 824329, size: 3153 } { name: '/pages/integralTask/integralTask.html', off: 827482, size: 5007 } { name: '/pages/login/login.html', off: 832489, size: 1649 } { name: '/pages/mine/mine.html', off: 834138, size: 2429 } { name: '/pages/orderList/orderList.html', off: 836567, size: 5701 } { name: '/pages/ranking/ranking.html', off: 842268, size: 4388 } { name: '/pages/share/share.html', off: 846656, size: 5327 } { name: '/pages/shop/creditBuy.html', off: 851983, size: 2730 } { name: '/pages/shop/shop.html', off: 854713, size: 3175 } { name: '/pages/welfare/welfare.html', off: 857888, size: 751 } { name: '/page-frame.html', off: 858639, size: 114111 } Saving files... Unpack done. Split app-service.js and make up configs & wxss & wxml & wxs... Decompile ./pages/CSR/CSR.wxml... Decompile success! Decompile ./pages/card/card.wxml... Decompile success! Decompile ./pages/coinRecord/coinRecord.wxml... Decompile success! Decompile ./pages/coinShop/coinShop.wxml... Decompile success! Decompile ./pages/detailsCoins/detailsCoins.wxml... Decompile success! Decompile ./pages/home/home.wxml... Decompile success! Decompile ./pages/integralDec/integralDec.wxml... Decompile success! Decompile ./pages/integralTask/integralTask.wxml... Decompile success! Decompile ./pages/login/login.wxml... Decompile success! Decompile ./pages/mine/mine.wxml... Decompile success! Decompile ./pages/orderList/orderList.wxml... Decompile success! Decompile ./pages/ranking/ranking.wxml... Decompile success! Decompile ./pages/share/share.wxml... Decompile success! Decompile ./pages/shop/creditBuy.wxml... Decompile success! Decompile ./pages/shop/shop.wxml... Decompile success! Decompile ./pages/welfare/welfare.wxml... Decompile success! Guess wxss(first turn)... Splitting "/Users/gangxue/demo/wxappUnpacker/zyel/app-service.js" done. Import count info: {} Guess wxss(first turn) done. Generate wxss(second turn)... Generate wxss(second turn) done. Save wxss... Split and make up done. Delete files... Deleted. File done. Total use: 3148.983ms
3.如果想單獨執行config、js、wxml、wxss的反編譯可以在解包時加-o參數不做后續操作
工具用法
- node wuConfig.js<files...> 將 app-config.json 中的內容拆分到各個文件對應的 .json 和 app.json , 并通過搜索 app-config.json 所在文件夾下的所有文件嘗試將 iconData 還原為 iconPath 。
- node wuJs.js<files...> 將 app-service.js (或小游戲中的 game.js ) 拆分成一系列原先獨立的 JAVAscript 文件,并使用 Uglify-ES 美化,從而盡可能還原編譯前的情況。
- node wuWxml.js[-m]<files...> 將編譯/混合到 page-frame.html ( 或 app-wxss.js ) 中的 wxml 和 wxs 文件還原為獨立的、未編譯的文件。如果加上 -m指令,就會阻止 block塊自動省略,可能幫助解決一些相關過程的 bug 。
- node wuWxss.js<dirs...> 通過獲取文件夾下的 page-frame.html ( 或 app-wxss.js ) 和其他 html 文件的內容,還原出編譯前 wxss 文件的內容。
- node wuWxapkg.js[-o][-d][-s=<MainDir>]<files...> 將 wxapkg 文件解包,并將包中上述命令中所提的被編譯/混合的文件自動地恢復原狀。如果加上 -o指令,表示僅解包,不做后續操作。如果加上 -d指令,就會保留編譯/混合后所生成的新文件,否則會自動刪去這些文件。同時,前面命令中的指令也可直接加在這一命令上。
導入開發者工具
打開微信開發者工具,導入項目即可
注意在中銀E路通解包后的項目設置中
- 注意勾選不校驗合法域名
- 勾掉e6轉es5(這個小程序貌似并沒有使用es6語法)
解包后導入項目
解包其它小程序可能項目配置略有不同。