WeChatPlugin-iOS Mac OS 版微信小助手(远程控制、消息防撤回、自动回复、微信多开)
本篇主要实现在微信上自动添加好友,从而熟悉 iOS 逆向分析的过程。
iOS 工具大部分都需要在 ssh 环境中使用
// 1. 端口的转发,(手机22 端口转到Mac 2222 端口)
python tcprelay.py -t 22:2222
// 2. 再使用ssh连接至手机(举例 手机ip为 192.168.31.94)
ssh root@192.168.31.94 -p 2222
ps -e |grep WeChat
cycript -p WeChat
UIApp.keyWindow.recursiveDescription().toString()
class-dump
dump 出微信的 class 信息。
class-dump -H WeChat -o ~/Document/headers/ // 保存在 ~/Document/headers/ 目录中[SayHelloViewController OnSayHelloDataChange]
python tcprelay.py -t 1234:1234
debugserver *:1234 -a "WeChat"
内存地址 = 进程内存基地址 + 方法偏移地址
br s -a "0x000b2000 + 0x14a4824"
CMessageMgr MessageReturn: MessageInfo:Event:
if (((loc_1c099bc(r6, @selector(m_bSuspiciousUser)) & 0xff) != 0x0) && ((loc_1c099bc(r6, @selector(isMMContact)) & 0xff) == 0x0))
,看到了MMUIAlertView。推测是弹窗的 view ,推测如果是可疑的用户或者当前申请的好友已经是自己的好友,那就进行弹窗。而另一部分为verifyContactWithOpCode:opcode:,
推测该部分为添加好友的方法。verifyContactWithOpCode:opcode:方法。
主要的部分如下所示。 m_nsUsrName
m_uiScene
m_nsTicket
.然后通过添加到数组中,通过CContactVerifyLogic
对象的startWithVerifyContactWrap:opCode:parentView:fromChatRoom:
方法发送。 CContactVerifyLogic *verifyLogic = [[CContactVerifyLogic alloc] init];
CVerifyContactWrap *wrap = [[CVerifyContactWrap alloc] init];
[wrap setM_nsUsrName:contact.m_nsEncodeUserName];
[wrap setM_uiScene:contact.m_uiFriendScene];
[wrap setM_nsTicket:contact.m_nsTicket];
[wrap setM_nsChatRoomUserName:contact.m_nsChatRoomUserName];
wrap.m_oVerifyContact = contact;
AutoSetRemarkMgr *mgr = [[MMServiceCenter defaultCenter] getService:[AutoSetRemarkMgr class]];
id attr = [mgr GetStrangerAttribute:contact AttributeName:1001];
if([attr boolValue]) {
[wrap setM_uiWCFlag:(wrap.m_uiWCFlag | 1)];
}
[verifyLogic startWithVerifyContactWrap:[NSArray arrayWithObject:wrap] opCode:3 parentView:[UIView new] fromChatRoom:NO];
%hook CMessageMgr
- (void)MessageReturn:(unsigned int)arg1 MessageInfo:(NSDictionary *)info Event:(unsigned int)arg3 {
%orig;
if (arg1 == 332) { // 收到添加好友消息
NSString *keyStr = [info objectForKey:@"5"];
if ([keyStr isEqualToString:@"fmessage"]) {
NSArray *wrapArray = [info objectForKey:@"27"];
[self addAutoVerifyWithArray:wrapArray];
}
}
}
%new
- (void)addAutoVerifyWithArray:(NSArray *)ary {
[ary enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
CPushContact *contact = [%c(SayHelloDataLogic) getContactFrom:obj];
if (![contact isMyContact] && [contact.m_nsDes isEqualToString:autoVerifyKeyword]) {
CContactVerifyLogic *verifyLogic = [[%c(CContactVerifyLogic) alloc] init];
CVerifyContactWrap *wrap = [[%c(CVerifyContactWrap) alloc] init];
[wrap setM_nsUsrName:contact.m_nsEncodeUserName];
[wrap setM_uiScene:contact.m_uiFriendScene];
[wrap setM_nsTicket:contact.m_nsTicket];
[wrap setM_nsChatRoomUserName:contact.m_nsChatRoomUserName];
wrap.m_oVerifyContact = contact;
AutoSetRemarkMgr *mgr = [[%c(MMServiceCenter) defaultCenter] getService:%c(AutoSetRemarkMgr)];
id attr = [mgr GetStrangerAttribute:contact AttributeName:1001];
if([attr boolValue]) {
[wrap setM_uiWCFlag:(wrap.m_uiWCFlag | 1)];
}
[verifyLogic startWithVerifyContactWrap:[NSArray arrayWithObject:wrap] opCode:3 parentView:[UIView new] fromChatRoom:NO];
}
}];
}