ios-微信自动抢红包插件

以前分享过如何搭建theos开发环境ios

此次分享下用theos开发一个微信自动抢红包的插件git

微信相关类参考来自http://bbs.iosre.com/ ,你们也能够本身结合静态动态分析来找到微信关于红包的几个类github

---------------------------------------又是凌乱分割线----------------------------------------微信

大概思路:在微信聊天界面中BaseMsgContentViewController,发现有红包出现WCPayC2CMessageNodeView,自动模拟点击事件onClick,弹出红包详情页WCRedEnvelopesReceiveHomeView,自动获取红包OnOpenRedEnvelopesspa

问题来了:.net

问题1:怎么知道红包何时出现呢?插件

答:经过勾取(- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath) 方法,当红包出现的时候会经过reloadData刷出红包,ios开发都懂的,这是必走的过程。经过获取cell中contentView的subViews找到WCPayC2CMessageNodeView就是说明有红包的出现code

问题2:如何过滤掉已经抢过的红包orm

答:其实最好的办法就是能记录下打开过的红包id,可是从上面几个类的分析中没有分析出红包id的位置,你们能够看看这个红包详情页WCRedEnvelopesReceiveHomeView的data类型,红包id确定在data里面,只是什么结构须要继续分析下blog

-(id)initWithFrame:(CGRect)frame andData:(id)data delegate:(id)delegate;
-(void)refreshViewWithData:(id)data;

我目前的作法是比较low,就是只查看最后一个cell的类型,若是是红包就打开,打开后会有打开提示语放到tableView的最后,因此不会重复打个一个cell

问题3:为何要一直打开聊天界面才能自动抢红包,在首页不行吗?可能多个群在一块儿抢红包呢?

答:固然能够在首页作到直接抢红包了,只是须要分析底层消息体获取解析的代码,难度可能比界面分析要难不少。

固然,大神年年有,今年特别多,看这个 https://github.com/buginux/WeChatRedEnvelop 

------------------------------------------凌乱的分割线---------------------------------------------

我自问自答也是够了,上代码让你们看看吧

%hook BaseMsgContentViewController

%new
- (id)someValue {
	return objc_getAssociatedObject(self, @selector(someValue));
}
 
%new
- (void)setSomeValue:(id)value {
	objc_setAssociatedObject(self, @selector(someValue), value, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

%end

%hook BaseMsgContentViewController

- (id)tableView:(id)arg1 cellForRowAtIndexPath:(id)arg2
{
	UITableViewCell *cell = %orig(arg1,arg2);
	NSIndexPath *indexpath = arg2;
 	NSString *value = [self performSelector:@selector(someValue)];
  	if(indexpath.row + 1 == [value integerValue])
  	{
  		for (id subView in cell.contentView.subviews)
  		{
  			if([NSStringFromClass([subView class]) isEqualToString:@"WCPayC2CMessageNodeView"])
    		{    	
	   			[subView performSelector:@selector(onClick)];
   			}
  		}
 	}
	return cell;
}

- (long long)tableView:(id)arg1 numberOfRowsInSection:(long long)arg2
{
	long long result = %orig(arg1,arg2);
	[self performSelector:@selector(setSomeValue:) withObject:[NSString stringWithFormat:@"%zd",result]];
	return result;
}

%end

%hook WCRedEnvelopesReceiveHomeView

- (void)refreshViewWithData:(id)arg1 {
	%orig;
	[self performSelector:@selector(OnOpenRedEnvelopes)];
	[self performSelector:@selector(OnCancelButtonDone)];
}
%end
相关文章
相关标签/搜索