破解修改 Electron 软件 | 游戏

更新:用这个7Zip插件可以直接解压asar,但对于被加密过的仍旧没办法,例如CocosCreator

Electron 是 Github 发布跨平台桌面应用开发工具,支持 Web 技术开发桌面应用开发,其本身是基于 C++ 开发的,GUI 核心来自于 Chrome,而 JavaScript 引擎使用 v8。

微软的VsCode与触控的Cocos Creator都是基于Electron开发的。

这里以Steam上的独立游戏《The Curious Expedition》为例:

一个Electron应用,目录下主要是这两部分:

electron.exe则是启动器,他是软件无关的,也就是说,所有基于Electron开发的软件都可以用这个启动器来启动,它是通用的,

应用的核心部分是resource文件下的app.asar

app.asar则是整个项目的所有资源文件的压缩包,包括js脚本,纹理、声音等其他资源,

它的压缩与解压参考:ASAR: how to unpack a .asar file?

简单来说,就是先通过npm安装asar(前提是你要安装了npm管理器):npm install -g asar

然后通过asar解压:asar extract app.asar destfolder 

解压后便可以得到所有文件:

一般来说,这个时候获取到的游戏主js文件都是混淆过的,比如上面的"min-cegame.js"

注:经测试,接下来部分的内容与游戏没有任何关系,删掉也不影响

接下来便是根目录下的pak文件了

pak文件的解压方式参考:how to unpack resources.pak from google chrome?

How to unpack .pak files and then repack them on Linux?

pak文件的二进制内容大概是:

4 byte version number 
4 byte number of resources
1 byte encoding

For each resource:
2 byte resource id
4 byte resource offset in file

There is an extra resource entry at the end with ID 0 giving the end of the last resource (which is essentially the length of the file).

After these resource entries the raw file data is written for each file. You can see the file ui/base/resource/data_pack_literal.cc in the chromium source tree for a couple commented example resource files.

 解压步骤:

1.首选clone下这个别人已经写好的解压库: git clone https://chromium.googlesource.com/chromium/src/tools/grit

2.在项目里找到data_pack.py,并将 print "%s: %s" % (resource_id, text) 部分替换成 with open(str(resource_id), "wb") as file: file.write(text)

3.命令行执行python data_pack.py yourfile.pak,就会将pak里的东西都解压到data_pack.py目录下(注意并没有格式)

原文地址:https://www.cnblogs.com/jeason1997/p/6853737.html