简单实现Mac版微信防撤回

网上Mac微信插件有好多了,也比较成熟,更新后功能好多,

0.准备,自己下载安装theos,和insert_dylib(习惯用optool的也可以)

1.写一个tweak 就是.xm文件.hook掉MessageService的onRevokeMsg:方法(最新版微信自己使用hopper分析找到onRevokeMsg:方法,类好像换掉了)
代码如下:

  %config(generator=internal)

    // You don't need to #include , it will be done automatically, as will
    // the generation of a class list and an automatic constructor.

#import 
   %hook MessageService

  - (void)onRevokeMsg:(id)agr
  {
        return;
  }

// Always make sure you clean up after yourself; Not doing so could have grave consequences!
%end
%ctor {
        NSLog(@"!!!!!!---success---!!!!!!!");
  }

2.一个脚本保存为insertTweak.sh文件

# 
#获取找到APP
path=`ls | grep *.app | head -1`
#找到tweak
tweak=`ls | grep *.xm | head -1`
temp='tempssxxxx'
name=${path%.app}

app_executable_backup_path="./${path}/Contents/MacOS/${name}_backup"

#使用theos 的logos.pl转换,前面路径看自己theos的路径
/opt/theos/bin/logos.pl "./${tweak}" > "./${temp}.mm"

#clang编译生成动态库
clang -shared -undefined dynamic_lookup -o "./${path}/Contents/MacOS/lib.dylib" "./${temp}.mm"

#使用optool的就打开这个,关闭insert_dylib
#optool install -c load -p @executable_path/lib.dylib -t "./${path}/Contents/MacOS/${name}"

#//先复制一次备份
cp "./${path}/Contents/MacOS/${name}" "$app_executable_backup_path"

#使用insert_dylib 注入生成的动态库,找到自己的insert_dylib
/Users/lxmacmini/Desktop/demo/ok/insert_dylib --all-yes @executable_path/lib.dylib "$app_executable_backup_path" "./${path}/Contents/MacOS/${name}"
  1. 新建一个文件夹把,WeChat.app tweak.xm insertTweak.sh 放到一个文件夹下面.打开终端cd到文件夹下面执行脚本
. insertTweak.sh

4.看到生成一个tempssxxxx.mm文件,基本就ok了,打开微信登录,撤回消息试试
5.拖到应用程序里面 enjoy!

你可能感兴趣的:(简单实现Mac版微信防撤回)