本文僅供學(xué)習(xí)交流就轧,請(qǐng)勿用于其他用途险掀。
2017年年關(guān)將近沪袭,在此祝大家搶到的紅包多多。
微信紅包做了一些參數(shù)的變化樟氢,增加了timingIdentifier 來(lái)防止作弊冈绊,再打開(kāi)紅包前需要先獲取此參數(shù)作為搶紅包的必要參數(shù)。
大家可以增加其他功能比如延時(shí)嗡害,還有UI 的制作焚碌,以及重簽名安裝到未越獄的機(jī)器等,盡可能發(fā)揮您的才智霸妹。
請(qǐng)參考下面的代碼:
git地址WeChatTweak
id redPacketParams = nil;
id logicMgr = nil;
static NSMutableArray *timingIdentifierArray = nil;
%hook CMessageMgr
- (void)AsyncOnAddMsg:(NSString *)msg MsgWrap:(id)wrap
{
%log;
%orig;
if(timingIdentifierArray==nil) timingIdentifierArray = [[NSMutableArray alloc] init];
id content = [wrap performSelector:@selector(m_nsContent)];
int type = ((int (*)(id, SEL))objc_msgSend)(wrap,@selector(m_uiMessageType));
if(type!=49)return;
if([content rangeOfString:@"wxpay://"].location == NSNotFound) return;
id nativeUrl = [[wrap performSelector:@selector(m_oWCPayInfoItem)] performSelector:@selector(m_c2cNativeUrl)];
id paramsUrl = [nativeUrl substringFromIndex:[@"wxpay://c2cbizmessagehandler/hongbao/receivehongbao?" length]];
NSDictionary *params = [%c(WCBizUtil) performSelector:@selector(dictionaryWithDecodedComponets:separator:) withObject:paramsUrl withObject:@"&"];
id agreeDuty = @"0";
id channelId = @"1";
id inWay = @"0";
id url = nativeUrl;
id sendId = params[@"sendid"];
//將紅包需要的參數(shù)放入到 requestParams中
NSMutableDictionary *requestParams = [@{} mutableCopy];
[requestParams setValue:sendId forKey:@"sendId"];
[requestParams setValue:agreeDuty forKey:@"agreeDuty"];
[requestParams setValue:channelId forKey:@"channelId"];
[requestParams setValue:inWay forKey:@"inWay"];
[requestParams setValue:url forKey:@"nativeUrl"];
[requestParams setValue:@"1" forKey:@"msgType"];
id serviceCenter = [%c(MMServiceCenter) performSelector:@selector(defaultCenter)];
logicMgr =[serviceCenter performSelector:@selector(getService:) withObject:%c(WCRedEnvelopesLogicMgr)];
//發(fā)送請(qǐng)求獲取 timingIdentifier
[logicMgr performSelector:@selector(ReceiverQueryRedEnvelopesRequest:) withObject:requestParams];
redPacketParams = requestParams;
id contactManager = [[%c(MMServiceCenter) performSelector:@selector(defaultCenter)] performSelector:@selector(getService:) withObject:%c(CContactMgr)];
id selfContact = [contactManager performSelector:@selector(getSelfContact)];
id sessionUserName = [wrap performSelector:@selector(m_nsFromUsr)];
id headImg = [selfContact performSelector:@selector(m_nsHeadImgUrl)];
id nickName = [selfContact performSelector:@selector(getContactDisplayName)];
[redPacketParams setValue:sessionUserName forKey:@"sessionUserName"];
[redPacketParams setValue:headImg forKey:@"headImg"];
[redPacketParams setValue:nickName forKey:@"nickName"];
}
%end
%hook WCRedEnvelopesLogicMgr
- (void)OnWCToHongbaoCommonResponse:(id)arg1 Request:(id)arg2
{
%log;
%orig;
//獲取 timingIdentifier 參數(shù)
id reponseString = [[NSString alloc] initWithData:[[arg1 performSelector:@selector(retText)] performSelector:@selector(buffer)] encoding:NSUTF8StringEncoding];
NSDictionary *reponse = [reponseString performSelector:@selector(JSONDictionary)];
id timingIdentifier = reponse[@"timingIdentifier"];
//搶過(guò)的紅包就不再去搶了
if (timingIdentifier&&![timingIdentifierArray containsObject:timingIdentifier]) {
[redPacketParams setValue:timingIdentifier forKey:@"timingIdentifier"];
[logicMgr performSelector:@selector(OpenRedEnvelopesRequest:) withObject:redPacketParams];
[timingIdentifierArray addObject:timingIdentifier];
}
}
%end