68

通过 node 打 patch 破解 mac 应用

 5 years ago
source link: http://www.52cik.com/2018/10/07/sizeup-patch.html?amp%3Butm_medium=referral
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

升级 macos mojove 后,各种蛋疼,一些应用也要重新安装了。

其中 SizeUp 这款工具也失效了,找破解版的时候发现了一篇2016年3月的文章。

照着流程操作,竟然到现在还有用,单字节爆破,简单粗暴的方法,我喜欢。

于是乎写成了 node 模块,方便自己和一些朋友使用。

有钱的支持正版,我这样的穷逼,自己写工具。。

寻找特征码

逆向工程 SizeUp 》文章中介绍了怎么爆破,不会爆破的朋友,可能完全不懂这是什么鬼。

不过不要紧张,我这里说的东西非常简单,是个程序员都懂,因为只是找到文件的第几个字节,然后修改下而已。

  1. 按照他的流程找到关键点修改后,不要保存,点上面那个图标切换到十六进制视图。
    ZJreaiZ.png!web
  2. 看到红色那个,就是你修改的地方,记录他前面 6 个字节,也可以是 10 个或者更多,只要这个是唯一的就行。
    NZfiuuB.png!web
  3. 用 UltraEdit 之类合适编辑十六进制的工具打开,搜索刚才记录的6个字节,即可得到最终物理地址。
    2Y3yAvm.png!web

最终我们得到了 0x947d 这个地址,将他修改为 0x00 即可。

node 修改指定位置字节

我们用 fs.openSync(path, 'rs+') 模式打开文件,’rs+’ 以同步读写模式打开文件,命令操作系统绕过本地文件系统缓存。

然后 fs.writeSync(fd, Buffer.from([0x00]), 0, 1, 0x947d); 即可,核心代码就这么两句。

其他都是辅助,例如判断是否正常安装的,以及特征码对比,检测版本是否支持。

完整代码:

const fs = require('fs');

const path = '/Applications/SizeUp.app/Contents/MacOS/SizeUp';
const buf = Buffer.alloc(6); // tmp
const signature = Buffer.from([0xe8, 0xae, 0x5c, 0x01, 0x00, 0xba]); // 特征码
const patch = Buffer.from([0x00]); // 补丁字节
const position = 0x947d; // 地址

(function main() {
  if (!fs.existsSync(path)) {
    console.log('SizeUp is not installed!');
    console.log('You can use this command `brew cask install sizeup`');
    return false;
  }

  const fd = fs.openSync(path, 'rs+');

  fs.readSync(fd, buf, 0, 6, position - 6);

  if (buf.compare(signature) !== 0) {
    console.log('This version is not supported!');
    return false;
  }

  fs.writeSync(fd, patch, 0, 1, position);
  console.log('Patch success!');

  fs.closeSync(fd);

  return true;
})();

是不是比想象中简单的太多了。

dd 命令直接修改

如果你是 shell 大佬,其实可以直接 dd 命令来修改。

$ printf '\x00' | dd seek=$((0x947d)) conv=notrunc bs=1 of=/Applications/SizeUp.app/Contents/MacOS/SizeUp

效果是一样的。

只是 node 做了一些判断,相对来说更安全。

使用

我已经把这个写成模块发布了,项目 52cik/sizeup-patch

你可以直接使用。

$ npx sizeup-patch

简单,方便,无污染。

如果你没安装 SizeUp 直接运行,你会得到 ‘You can use this command brew cask install sizeup ‘ 提示。

直接 brew cask install sizeup 安装完成后,重新 npx sizeup-patch 即可使用了。

小结

不提倡使用破解,否则生态就越来越差,越来越没有优秀的工具了。

这句话相信很多人都见过,或者知道,但真的是这样么?

其实不是的,破解一直存在,而且也不会让某个产品死掉,看微软就知道了。

很多作者早期自己写软件自己出破解版到处发,为了更快的赢得用户。

到中后期才会封杀破解,当你离不开这款工具的时候,你也会咬牙买下的。

当然,这并不是你装逼炫耀的理由,自己私底下用用就好了。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK