简体   繁体   English

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

[英]Get fileSize of info.plist to prevent piracy

I'm trying to put anti-piracy code in my app. 我正试图在我的应用程序中加入反盗版代码。 The previous answer to this (which I can't link to because of my member status - sucks) can be easily countered, since the "SignerIdentity" string can be looked for and replaced in the binary using a hex editor. 由于可以使用十六进制编辑器在二进制文件中查找和替换“SignerIdentity”字符串,因此可以轻松地解决之前对此的回答(由于我的成员状态而无法链接)。

Instead, checking the fileSize of the info.plist file and comparing it to a reference value sounds more solid (since the info.plist is getting modified here and there when cracking the app). 相反,检查info.plist文件的fileSize并将其与参考值进行比较听起来更加可靠(因为在破解应用程序时,info.plist在这里和那里被修改)。 How would I do that? 我该怎么办? I tried the following but it logs 0. 我尝试了以下但它记录0。

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

You might prevent the noobish crackers from finding references to "SignerIdentity" in your code by applying ROT13 or a similar simple obscuring algorithm http://en.wikipedia.org/wiki/ROT13 您可以通过应用ROT13或类似的简单模糊算法来阻止noobish破解者在您的代码中找到对“SignerIdentity”的引用http://en.wikipedia.org/wiki/ROT13

After applying ROT13, "SignerIdentity" would become "FvtareVqragvgl". 应用ROT13后,“SignerIdentity”将变为“FvtareVqragvgl”。

Anyway, the answer to your question (how you get the size of the Info.plist file): 无论如何,你的问题的答案(如何获得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]);
    }           
}

Also keep in mind that the size (in bytes) of the Info.plist in your Xcode project directory and the Info.plist inside the bundle may differ. 另请注意,Xcode项目目录中Info.plist的大小(以字节为单位)和bundle中的Info.plist可能会有所不同。 You probably want to build the game once, then look at the size of <your app bundle.app>/Info.plist and then update your antipiracy code. 您可能想要构建一次游戏,然后查看<your app bundle.app>/Info.plist的大小,然后更新您的反盗版代码。

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

that code has still many giveaways: 该代码还有很多赠品:

the string Info.plist is easy to find. 字符串Info.plist很容易找到。 NSFileSize is also very suspicious.... NSFileSize也很可疑......

As said here Determining if an iPhone is Jail broken Programmatically it looks like some of the most recent cracked apps installed via install0us don't have their info.plist modified. 正如在这里所说的那样,通过install0us安装一些最新破解的应用程序, 确定iPhone是否已经被Jail破坏了,并没有修改它们的info.plist。 (at least the info.plist does not contain any signeridentity key). (至少info.plist不包含任何signeridentity键)。 How could we detect the crack in such a case ? 在这种情况下我们怎么能检测到裂缝?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM