Hook微信 - 拦截新消息函数,获取消息内容
2016-09-10 本文已影响4672人
什么东东额
本文章学习自【iOS应用逆向工程(第2版)】沙梓社 吴航 著
微信私有API的获取方法可以从书中获得。
开始:
1. 已知微信新消息函数API

-(void)AsyncOnAddMsg:(id)msg MsgWrap:(id)wrap;
2. 新建Tweak工程
注意微信的BundleID 为 com.tencent.xin
建好的工程文件夹中分别修改 Makefile 和 tweak.xm 文件
Makefile
export THEOS = /opt/theos
export THEOS_DEVICE_IP = 设备IP
include $(THEOS)/makefiles/common.mk
TWEAK_NAME = xin
xin_FILES = Tweak.xm
xin_FRAMEWORKS = UIKit
include $(THEOS_MAKE_PATH)/tweak.mk
after-install::
install.exec "killall -9 SpringBoard"
tweak.xm
%hook CMessageMgr
- (void)AsyncOnAddMsg:(id)arg1 MsgWrap:(id)arg2 {
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"新消息" message:arg1 delegate:self cancelButtonTitle: arg2 otherButtonTitles:@"确定", nil];
[alert show];
}
%end
3. 通过openssh 安装在手机
测试截图忘了
在tweak.xm 中
将arg1 和 arg2 放入alert的 message 和 cancelButtonTitle
测试可以推测 :
arg1 是新消息类型
比如私聊打印出
wxid_uzmj63mhbh8b22
wxid_ssf365rdfnd421
比如群聊打印出
2810475734@chatroom