ジェイルブレイクされた iPhone は、MobileSubstrate を使用することで、iOS のいくつかの基本的な API を汚染するので、私の神経質になります。
http://www.iphonedevwiki.net/index.php/MobileSubstrate
UDID は半自動で便利なので、多くのアプリがデバイスやユーザーを認証する手段として使用していると思いますが、この問題に注意する必要があります。UDID Faker というアプリがあり、実行時に他人の UDID を簡単に偽装できます。
http://www.iphone-network.net/how-to-fake-udid-on-ios-4/
そのソースコードは次のとおりです。
//
// UDIDFaker.m
// UDIDFaker
//
#include "substrate.h"
#define ALog(...) NSLog(@"*** udidfaker: %@", [NSString stringWithFormat:__VA_ARGS__]);
#define kConfigPath @"/var/mobile/Library/Preferences/com.Reilly.UDIDFaker.plist"
@protocol Hook
- (NSString *)orig_uniqueIdentifier;
@end
NSString *fakeUDID = nil;
static NSString *$UIDevice$uniqueIdentifier(UIDevice<Hook> *self, SEL sel) {
if(fakeUDID != nil) {
ALog(@"fakeUDID %@", fakeUDID);
/* if it's a set value, make sure it's sane, and return it; else return the default one */
return ([fakeUDID length] == 40) ? fakeUDID : [self orig_uniqueIdentifier];
}
/* ... if it doesn't then return the original UDID */
else {
return [self orig_uniqueIdentifier];
}
}
__attribute__((constructor)) static void udidfakerInitialize() {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSString *appsBundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];
ALog(@"Loading UDID Faker into %@", appsBundleIdentifier);
NSDictionary *config = [NSDictionary dictionaryWithContentsOfFile: kConfigPath];
fakeUDID = [config objectForKey: appsBundleIdentifier];
[fakeUDID retain];
if(fakeUDID != nil) {
ALog(@"Hooking UDID Faker into %@", appsBundleIdentifier);
MSHookMessage(objc_getClass("UIDevice"), @selector(uniqueIdentifier), (IMP)&$UIDevice$uniqueIdentifier, "orig_");
}
[pool release];
}
ご覧のとおり、UIDevice クラスの uniqueIdentifier メソッドは、すべてのアプリで fakeUDID を返すようになりました。
Skype やその他のアプリがこの種の汚染を検出しているようですが、その方法がわかりません。
私がやりたかったのは、起動時に汚染された UIDevice が検出された場合、警告して終了します(0)。
アイデア?