13

我正在开发一个需要监控对手行为的项目(移动应用程序)。所以,我的问题是如何让 iOS 应用程序防篡改?

例如

  • 每当任何对手试图篡改代码时,系统应提醒管理员这些操作
  • 并阻止那个对手
  • 如果用户尝试在有根设备上安装应用程序,则系统可以检测到。
  • 系统应该能够监控对手的行为。

我找到了类似 android 的解决方案ProGuardSafetyNet但没有找到任何适用于 iOS 的解决方案。

4

3 回答 3

9

我在我的一个项目中使用了这个JailBreak 检测

有了这个,你可以防止这种可能性。

    if ([DTTJailbreakDetection isJailbroken]) {

// your custom activity and business logic here
    }

此外,准确地说,您可以使用以下代码段

BOOL isJailbroken()
{
#if !(TARGET_IPHONE_SIMULATOR)

   if ([[NSFileManager defaultManager] fileExistsAtPath:@"/Applications/Cydia.app"] ||
       [[NSFileManager defaultManager] fileExistsAtPath:@"/Library/MobileSubstrate/MobileSubstrate.dylib"] ||
       [[NSFileManager defaultManager] fileExistsAtPath:@"/bin/bash"] ||
       [[NSFileManager defaultManager] fileExistsAtPath:@"/usr/sbin/sshd"] ||
       [[NSFileManager defaultManager] fileExistsAtPath:@"/etc/apt"] ||
       [[NSFileManager defaultManager] fileExistsAtPath:@"/private/var/lib/apt/"] ||
       [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"cydia://package/com.example.package"]])  {
         return YES;
   }

   FILE *f = NULL ;
   if ((f = fopen("/bin/bash", "r")) ||
      (f = fopen("/Applications/Cydia.app", "r")) ||
      (f = fopen("/Library/MobileSubstrate/MobileSubstrate.dylib", "r")) ||
      (f = fopen("/usr/sbin/sshd", "r")) ||
      (f = fopen("/etc/apt", "r")))  {
         fclose(f);
         return YES;
   }
   fclose(f);

   NSError *error;
   NSString *stringToBeWritten = @"This is a test.";
   [stringToBeWritten writeToFile:@"/private/jailbreak.txt" atomically:YES encoding:NSUTF8StringEncoding error:&error];
   [[NSFileManager defaultManager] removeItemAtPath:@"/private/jailbreak.txt" error:nil];
   if(error == nil)
   {
      return YES;
   }

#endif

   return NO;
}

此外, iOS 目标 C 中的混淆,您可以使用这个开源库方法和类

于 2016-12-02T10:59:05.123 回答
4

除了检测越狱设备和混淆代码(如@itechnician 所述),您还可以:

无论如何,在越狱设备上(甚至检查它是否越狱)时,所有这些都可以轻松绕过。最好的方法是使用包括混淆在内的多种技术,使篡改尽可能难(所以不值得)。但我不确定你是否可以制作完全防篡改的应用程序。

您可能会发现这些链接很有用:

https://www.coredump.gr/articles/ios-anti-debugging-protections-part-1/ https://www.raywenderlich.com/45645/ios-app-security-analysis-part-1 http:// /resources.infosecinstitute.com/ios-application-security-part-31-problem-using-third-party-libraries-securing-apps/

这本书有点老了,但还是有用的:http ://shop.oreilly.com/product/0636920023234.do

以下是开源 ObjC 混淆器/字符串加密器:

于 2016-12-07T07:48:04.193 回答
3

我认为你看起来像ixguard

于 2016-12-08T07:19:49.830 回答