在对二进制文件进行一些静态分析后,很明显他们没有使用 PKPushRegistry (VOIP)、未记录的 NSNotificationCenter 调用或 SBAlertItem。
花了一点时间才找到它,但他们实际上是使用 CFUserNotification 来发出警报的。对于 Mac,该类是 documented,但对于 iOS 是私有的。
我通过这样做找到了用法:
nm -u ~/Downloads/Payload/UberDriver.app/UberDriver | grep CFUserNotification
输出是:
_CFUserNotificationCancel
_CFUserNotificationCreate
_CFUserNotificationCreateRunLoopSource
_kCFUserNotificationAlertHeaderKey
_kCFUserNotificationAlertMessageKey
_kCFUserNotificationAlertTopMostKey
_kCFUserNotificationAlternateButtonTitleKey
_kCFUserNotificationDefaultButtonTitleKey
_kCFUserNotificationSoundURLKey
如果我对 PKPushRegistry 或 SBAlertItem 进行 grep,则两者均不返回任何结果。
可以通过将this file 导入您的项目来使用该类。
更新
我有“工作”代码,但是它立即调用回调函数(responseFlags 设置为kCFUserNotificationCancelResponse)而不显示警报..
我使用与 Uber 应用程序相同的键和调用(将下面的代码与上面列出的代码进行比较),所以一定有一些额外的东西。会继续寻找。
#import "CFUserNotification.h"
@interface AppDelegate ()
@property (nonatomic) CFRunLoopSourceRef runLoopSource;
@property (nonatomic) CFUserNotificationRef notification;
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
SInt32 error;
NSDictionary *keys = @{(__bridge NSString*)kCFUserNotificationAlertHeaderKey: @"Hello",
(__bridge NSString*)kCFUserNotificationAlertMessageKey: @"World",
(__bridge NSString*)kCFUserNotificationAlertTopMostKey: @YES,
(__bridge NSString*)kCFUserNotificationDefaultButtonTitleKey: @"asdf",
(__bridge NSString*)kCFUserNotificationAlternateButtonTitleKey: @"asdf",
};
self.notification = CFUserNotificationCreate(NULL, 10, kCFUserNotificationPlainAlertLevel, &error, (__bridge CFDictionaryRef)keys);
self.runLoopSource = CFUserNotificationCreateRunLoopSource(NULL, self.notification, NotificationCallback, 0);
CFRunLoopAddSource(CFRunLoopGetMain(), self.runLoopSource, kCFRunLoopCommonModes);
return YES;
}
void NotificationCallback(CFUserNotificationRef userNotification, CFOptionFlags responseFlags) {
NSLog(@"got response: %lu", responseFlags);
}