zoukankan      html  css  js  c++  java
  • iPhone是否越狱的检测方法

    今天项目中要用到检查iPhone是否越狱的方法。

    Umeng统计的Mobclick.h里面已经包含了越狱检测的代码,可以直接使用

    /*方法名:
     *        isJailbroken
     *介绍:
     *        类方法,判断设备是否越狱,判断方法根据 apt和Cydia.app的path来判断
     *参数说明:
     *        无
     *        
     *
     */
    
    #pragma mark utils api
    // 类方法,判断当前设备是否已经越狱
    + (BOOL)isJailbroken;
    // 类方法,判断你的App是否被破解
    + (BOOL)isPirated;

    apt和Cydia的方式来进行判断的,没看见源码

    然后再介绍两种方法来查看是否已经越狱,知其然知其所以然、、、

    1. apt
    - (BOOL) hasAPT
    {
    return [[NSFileManager defaultManager] fileExistsAtPath:@"/private/var/lib/apt/"];
    }

    2. system
    - (BOOL) successCallSystem
    {
    return (system("ls") == 0) ? YES : NO;
    }

    3.

      static const char* jailbreak_apps[] =

        {
            "/Applications/Cydia.app",
            "/Applications/limera1n.app",
            "/Applications/greenpois0n.app",
            "/Applications/blackra1n.app",
            "/Applications/blacksn0w.app",
            "/Applications/redsn0w.app",
            "/Applications/Absinthe.app",
            NULL,
        };
         
        - (BOOL) isJailBroken
        {
            // Now check for known jailbreak apps. If we encounter one, the device is jailbroken.
            for (int i = 0; jailbreak_apps[i] != NULL; ++i)
            {
                if ([[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithUTF8String:jailbreak_apps[i]]])
                {
                    //NSLog(@"isjailbroken: %s", jailbreak_apps[i]);
                    return YES;
                }
            }
             
            // TODO: Add more checks? This is an arms-race we're bound to lose.
             
            return NO;
        }

     

    @interface UIDevice (Helper)  
    - (BOOL)isJailbroken;  
    @end

    @implementation UIDevice (Helper)  
    - (BOOL)isJailbroken {  
      BOOL jailbroken = NO;  
      NSString *cydiaPath = @"/Applications/Cydia.app";  
      NSString *aptPath = @"/private/var/lib/apt/";  
      if ([[NSFileManager defaultManager] fileExistsAtPath:cydiaPath]) {  
        jailbroken = YES;  
      }  
      if ([[NSFileManager defaultManager] fileExistsAtPath:aptPath]) {  
        jailbroken = YES;  
      }  
      return jailbroken;  
    }  
    @end

    仅供参考、、、

     

  • 相关阅读:
    09、自学——Linux的学习进度与任务【目录文件的操作】
    08、自学——Linux的学习进度与任务【文件管理类命令—操作】
    07、自学——Linux的学习进度与任务【文件管理类命令—查看】
    06、自学——Linux的学习进度与任务【FHS】
    05、自学——Linux的学习进度与任务【shell中bash的特性】
    04、自学——Linux的学习进度与任务【时间日期管理类的命令】
    vue中computed、methods、watched比较
    vue中props组件传值
    vue中component组件使用——模块化开发和全局组件
    vue项目启动配置
  • 原文地址:https://www.cnblogs.com/easonoutlook/p/2665169.html
Copyright © 2011-2022 走看看