防止你的iPhone程序遭盗版(入门篇)

原文地址 http://b.imi.im/?p=356

首先简单介绍一下原理:

现在大多数的破解苹果验证安装app的办法都会动一个文件, 就是在.app文件夹下的”Info.plist”, 也就是那个程序信息文件.

代码很简单, 不再详细解释什么意思了

1. 检查Info.plist 是否存在 SignerIdentity这个键名(Key).
未破解的程序是不会有这个键名的, 苹果没给你加, 你自己没有加, 如果有, 那是哪儿来的呢?? 嘻嘻….

if ([[[NSBundle mainBundle] infoDictionary] objectForKey: @”SignerIdentity”] != nil) {

// 这就是被破解过的app

}

2. 检查3个文件是否存在

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

BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:(@”%@/_CodeSignature”, bundlePath)];

if (!fileExists) {

// 这就是被破解过的app

}

BOOL fileExists2 = [[NSFileManager defaultManager] fileExistsAtPath:(@”%@/CodeResources”, bundlePath)];

if (!fileExists2) {

/// 这就是被破解过的app

}

BOOL fileExists3 = [[NSFileManager defaultManager] fileExistsAtPath:(@”%@/ResourceRules.plist”, bundlePath)];

if (!fileExists3) {

// 这就是被破解过的app

}

 

3. 对比文件修改时间是否一致, 看看你的程序是不是被二进制编辑器修改过了

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

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

NSString* path2 = [NSString stringWithFormat:@"%@/程序名字", bundlePath];

NSDate* infoModifiedDate = [[[NSFileManager defaultManager] fileAttributesAtPath:path traverseLink:YES] fileModificationDate];

NSDate* infoModifiedDate2 = [[[NSFileManager defaultManager] fileAttributesAtPath:path2 traverseLink:YES] fileModificationDate];

NSDate* pkgInfoModifiedDate = [[[NSFileManager defaultManager] fileAttributesAtPath:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@”PkgInfo”] traverseLink:YES] fileModificationDate];

if( > [pkgInfoModifiedDate timeIntervalSinceReferenceDate]) {

//Pirated

}

if( > [pkgInfoModifiedDate timeIntervalSinceReferenceDate]) {

//Pirated

}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值