保护iOS应用程序免受运行时挂钩

时间:2017-04-20 10:39:06

标签: ios objective-c iphone jailbreak objective-c-runtime

在设备中运行时,iOS应用程序会附加到许多运行时库。我们如何保护我们的iOS应用程序免受任何其他调试程序的攻击。 与使用GDB一样,我们可以入侵应用程序进程并操纵运行时。有没有办法可以停止使用任何设置或代码? 或者有没有办法检查是否有任何其他运行时库附加到进程? 在这种情况下,我们可以使用相应的应用程序吗?

1 个答案:

答案 0 :(得分:0)

我们可以检查Info.plist文件和Appname的修改日期,并将其与软件包修改日期进行比较。如果发现未命中匹配,我们可以断定应用二进制文件已被修改。

//Check date of modifications in files (if different - app cracked)
NSString* path = [NSString stringWithFormat:@"%@/Info.plist", bundlePath];
NSString* path2 = [NSString stringWithFormat:@"%@/AppName", bundlePath];
NSDate* infoModifiedDate = [[manager attributesOfFileSystemForPath:path error:nil] fileModificationDate];
NSDate* infoModifiedDate2 = [[manager attributesOfFileSystemForPath:path2 error:nil]  fileModificationDate];
NSDate* pkgInfoModifiedDate = [[manager attributesOfFileSystemForPath:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"PkgInfo"] error:nil] fileModificationDate];
if([infoModifiedDate timeIntervalSinceReferenceDate] > [pkgInfoModifiedDate timeIntervalSinceReferenceDate]) {
    return YES;
}
if([infoModifiedDate2 timeIntervalSinceReferenceDate] > [pkgInfoModifiedDate timeIntervalSinceReferenceDate]) {
    return YES;
}
相关问题