【问题标题】:How to make iOS application tamper-evident?如何让 iOS 应用防篡改?
【发布时间】:2017-04-13 02:54:25
【问题描述】:

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

例如

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

我找到了适用于 Android 的解决方案,例如 ProGuardSafetyNet,但没有找到适用于 iOS 的任何解决方案。

【问题讨论】:

  • 通常我会考虑在文件上创建 MD5 校验和。然后您定期检查,看看它们是否发生了变化。由于IOS所有应用程序都是沙盒,我怀疑你可以访问任何文件(在你的应用程序之外)。
  • Pekka 웃 在 2016 年 12 月 1 日为您提供了一个热门类似问题的链接。第二天,即 2016 年 12 月 2 日,itechnician 复制粘贴了该类似问题的一年前的答案,但未授予作者 100 的奖励?

标签: ios security monitor tampering


【解决方案1】:

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

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

    if ([DTTJailbreakDetection isJailbroken]) {

// your custom activity and business logic here
    }

另外,确切地说,您可以使用以下snippet

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;
}

另外,Obfuscation 在 iOS - 目标 C 中你可以使用这个 open source-libraryMethods & Classes

【讨论】:

  • 任何支持DTTJailbreakDetection的官方文档?
  • 请查看github链接。我添加了
  • 请检查混淆参考以供您阅读。
【解决方案2】:

除了检测越狱设备和混淆代码(如@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 混淆器/字符串加密器:

【讨论】:

    【解决方案3】:

    我认为你看起来像 ixguard

    【讨论】:

    • 这是一项付费服务​​吗?我对一些开源解决方案更感兴趣。
    • 是的,这是一项付费服务​​。我认为没有一个开源解决方案可以完全满足您的需求。
    • 篡改和越狱检测现在还不是 iXGuard 的一部分。
    猜你喜欢
    • 2015-01-28
    • 1970-01-01
    • 2017-04-30
    • 1970-01-01
    • 1970-01-01
    • 2014-11-27
    • 2020-12-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多