获取info.plist的fileSize以防止盗版

sam*_*tte 8 iphone plist piracy-protection nsbundle ios

我正试图在我的应用程序中加入反盗版代码.由于可以使用十六进制编辑器在二进制文件中查找和替换"SignerIdentity"字符串,因此可以轻松地解决之前对此的回答(由于我的成员状态而无法链接).

相反,检查info.plist文件的fileSize并将其与参考值进行比较听起来更加可靠(因为在破解应用程序时,info.plist在这里和那里被修改).我该怎么办?我尝试了以下但它记录0.

NSBundle *bundle = [NSBundle mainBundle];
NSDictionary *mainDictionary = [bundle infoDictionary];
NSLog(@"%d", [mainDictionary fileSize]);
Run Code Online (Sandbox Code Playgroud)

Jul*_*rgé 7

您可以通过应用ROT13或类似的简单模糊算法来阻止noobish破解者在您的代码中找到对"SignerIdentity"的引用 http://en.wikipedia.org/wiki/ROT13

应用ROT13后,"SignerIdentity"将变为"FvtareVqragvgl".

无论如何,你的问题的答案(如何获得Info.plist文件的大小):

NSBundle *bundle = [NSBundle mainBundle];
NSString* bundlePath = [bundle bundlePath];

NSFileManager *fileManager = [NSFileManager defaultManager];

NSString* path = [NSString stringWithFormat:@"%@/Info.plist", bundlePath ];

NSDictionary *fileAttributes = [fileManager attributesOfItemAtPath:path 
                                                             error:NULL];

if (fileAttributes != nil) {
    NSNumber *fileSize;

    if (fileSize = [fileAttributes objectForKey:NSFileSize]) {
        NSLog(@"File size: %qi\n", [fileSize unsignedLongLongValue]);
    }           
}
Run Code Online (Sandbox Code Playgroud)

还要记住,Info.plistXcode项目目录和Info.plistbundle内部的大小(以字节为单位)可能不同.您可能想要构建一次游戏,然后查看大小,<your app bundle.app>/Info.plist然后更新您的反盗版代码.


Ale*_*x S 5

我从来没有为iPhone编程,但是你不能只是拿一个该文件的哈希值并将它与一个引用进行比较,可能会使哈希值变得干净,以防止有人只是将引用哈希值改为新的哈希值?