iOS应用在设备上运行时会连接到许多运行时库。我们如何保护iOS应用程序免受任何其他调试器攻击应用程序进程的影响呢? 例如使用GDB,我们可以黑入应用程序进程并操作运行时。有没有一种方法可以通过设置或代码防止这种情况发生? 或者,有没有一种方法可以检查是否有任何其他运行时库连接到该进程中? 我们能否在这种情况下退出应用程序?
iOS应用在设备上运行时会连接到许多运行时库。我们如何保护iOS应用程序免受任何其他调试器攻击应用程序进程的影响呢? 例如使用GDB,我们可以黑入应用程序进程并操作运行时。有没有一种方法可以通过设置或代码防止这种情况发生? 或者,有没有一种方法可以检查是否有任何其他运行时库连接到该进程中? 我们能否在这种情况下退出应用程序?
let amIDebugged: Bool = IOSSecuritySuite.amIDebugged()
如果你想自己编写代码,这可能会为你节省一些行数。
//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;
}