├── MakePackageInstall ├── Makefile ├── README.md ├── Tweak.xm ├── control └── iOSRELottery.plist /MakePackageInstall: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd `dirname $0` 3 | make clean 4 | make package install 5 | rm *.deb 6 | exit 0 7 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | THEOS_DEVICE_IP = 192.168.1.100 2 | 3 | ARCHS = armv7 armv7s arm64 4 | TARGET = iphone:latest:5.0 5 | 6 | include theos/makefiles/common.mk 7 | 8 | TWEAK_NAME = iOSRELottery 9 | iOSRELottery_FILES = Tweak.xm 10 | 11 | include $(THEOS_MAKE_PATH)/tweak.mk 12 | 13 | after-install:: 14 | install.exec "killall -9 Weibo" 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | iosrelottery 2 | ============ 3 | 4 | @iOS应用逆向工程 抽奖插件 5 | 6 | 把theos的alias拷贝至此目录下,修改Makefile里的IP地址,然后双击MakePackageInstall即可完成安装 :) 7 | -------------------------------------------------------------------------------- /Tweak.xm: -------------------------------------------------------------------------------- 1 | @interface WBContact : NSObject 2 | @property(retain, nonatomic) NSString *screenName; 3 | @property(readonly, nonatomic) BOOL isFollower; 4 | @end 5 | 6 | @interface WBUser : WBContact 7 | @property(nonatomic) unsigned int gender; // 1代表程序猿,0代表程序媛 8 | @end 9 | 10 | @interface WBTimelineItem : NSObject 11 | @property(retain, nonatomic) NSString *text; 12 | @property(retain, nonatomic) WBUser *user; 13 | @end 14 | 15 | @interface WBUniversalStatus : WBTimelineItem 16 | @end 17 | 18 | @interface WBStatus : WBUniversalStatus 19 | @end 20 | 21 | @interface WBStatusBusinessViewController : UIViewController 22 | { 23 | NSMutableArray *list; 24 | } 25 | @property(nonatomic) BOOL hasMore; 26 | - (void)loadMoreData; 27 | @end 28 | 29 | @interface WBRepostListViewController : WBStatusBusinessViewController 30 | @end 31 | 32 | %hook WBRepostListViewController 33 | %new 34 | - (void)iOSRELoadMoreReposts:(NSTimer *)refreshTimer 35 | { 36 | if ([self hasMore]) [self loadMoreData]; 37 | else 38 | { 39 | [refreshTimer invalidate]; 40 | 41 | // 开始抽奖倒计时 :) 42 | [NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(iOSRELottery:) userInfo:nil repeats:YES]; 43 | } 44 | } 45 | 46 | %new 47 | - (void)iOSRELottery:(NSTimer *)lotteryTimer 48 | { 49 | // 设定抽奖截止时间 50 | NSDateComponents *components = [[NSDateComponents alloc] init]; 51 | [components setYear:2014]; 52 | [components setMonth:2]; 53 | [components setDay:17]; 54 | [components setHour:12]; 55 | [components setMinute:0]; 56 | [components setSecond:0]; 57 | NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; 58 | NSDate *deadline = [gregorian dateFromComponents:components]; 59 | [components release]; 60 | [gregorian release]; 61 | 62 | // 获取当前时间 63 | NSDate *now = [NSDate date]; 64 | 65 | // 截止时间到! 66 | if ([now compare:deadline] == NSOrderedDescending) 67 | { 68 | // 停止抽奖倒计时 :( 69 | [lotteryTimer invalidate]; 70 | 71 | // 获取所有转发 72 | NSMutableArray *list = MSHookIvar(self, "list"); 73 | if ([list count] == 0) 74 | { 75 | NSLog(@"iOSRE: 人气太低,活动取消 :("); 76 | return; 77 | } 78 | 79 | NSLog(@"iOSRE: 经iOSRELottery统计,参与转发抽奖的一共有%lu位朋友。感谢大家的支持!下面开始开奖喽!", (unsigned long)[list count]); 80 | 81 | NSMutableArray *deduplicateArray = [NSMutableArray arrayWithCapacity:5]; 82 | 83 | // 抽出5名获奖者 84 | for (int i = 0; i < 5; i++) 85 | { 86 | // 生成随机数 87 | NSUInteger winnerIndex = (NSUInteger)arc4random_uniform([list count]); 88 | 89 | // 确保随机数没出现过 90 | if ([deduplicateArray containsObject:[NSNumber numberWithUnsignedLong:(unsigned long)winnerIndex]]) 91 | { 92 | i--; 93 | continue; 94 | } 95 | else [deduplicateArray addObject:[NSNumber numberWithUnsignedLong:(unsigned long)winnerIndex]]; 96 | 97 | // 获取转发者名字 98 | WBStatus *status = [list objectAtIndex:winnerIndex]; 99 | WBUser *user = [status user]; 100 | NSString *userName = [user screenName]; 101 | 102 | if ([userName isEqualToString:@"hangcom2010"] || [userName isEqualToString:@"iOS应用逆向工程"] || [userName isEqualToString:@"Me"] || [userName isEqualToString:@"我"]) 103 | { 104 | NSLog(@"iOSRE: 裁判不准参与比赛啊!"); 105 | i--; 106 | continue; 107 | } 108 | 109 | // 获取微博内容 110 | NSString *weiboText = [status text]; 111 | if ([weiboText rangeOfString:@"//@"].location != NSNotFound) weiboText = [weiboText substringToIndex:[weiboText rangeOfString:@"//@"].location]; 112 | 113 | // 关注@iOS应用逆向工程 114 | if (![user isFollower]) 115 | { 116 | NSLog(@"iOSRE: @%@,你没有关注@iOS应用逆向工程 啊,可惜~", userName); 117 | i--; 118 | continue; 119 | } 120 | 121 | // 爱特3人以上 122 | NSError *error = nil; 123 | NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"^.*@.*@.*@.*$" options:NSRegularExpressionCaseInsensitive error:&error]; 124 | if (error) 125 | { 126 | NSLog(@"iOSRE: 正则表达式出错了,错误是%@", [error localizedDescription]); 127 | i--; 128 | continue; 129 | } 130 | 131 | NSUInteger numberOfMatches = [regex numberOfMatchesInString:weiboText options:0 range:NSMakeRange(0, [weiboText length])]; 132 | if (numberOfMatches == 0) 133 | { 134 | NSLog(@"iOSRE: @%@,你没有爱特够3个人啊,可惜~", userName); 135 | i--; 136 | continue; 137 | } 138 | 139 | NSLog(@"iOSRE: 第%d位中奖的朋友是“@%@”,%@的转发内容是“%@”。%@将获得《iOS应用逆向工程》一本,恭喜%@!", i + 1, userName, [user gender] == 1 ? @"他" : @"她", weiboText, [user gender] == 1 ? @"他" : @"她", [user gender] == 1 ? @"他" : @"她"); 140 | } 141 | 142 | NSLog(@"iOSRE: 5位朋友已经全数抽出,感谢大家热情参与!iOSRE团队后续还会有更多动作,誓为提高中国iOS开发者的整体技术水平贡献自己的微薄之力,敬请期待!谢谢!"); 143 | } 144 | } 145 | 146 | - (void)viewDidLoad // 点进一条微博,此函数得到调用 147 | { 148 | %orig; 149 | 150 | // 加载所有转发 151 | [NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(iOSRELoadMoreReposts:) userInfo:nil repeats:YES]; 152 | } 153 | %end 154 | -------------------------------------------------------------------------------- /control: -------------------------------------------------------------------------------- 1 | Package: com.iosre.iosrelottery 2 | Name: iOSRELottery 3 | Depends: mobilesubstrate, firmware (>= 5.0) 4 | Version: 1.0 5 | Architecture: iphoneos-arm 6 | Description: iOSRE Lottery! 7 | Maintainer: iOSRE 8 | Author: iOSRE 9 | Homepage: http://iosre.com 10 | Section: Tweaks 11 | -------------------------------------------------------------------------------- /iOSRELottery.plist: -------------------------------------------------------------------------------- 1 | { 2 | Filter = { 3 | Bundles = ( 4 | "com.sina.weibo", 5 | ); 6 | }; 7 | } --------------------------------------------------------------------------------