zoukankan      html  css  js  c++  java
  • Android模拟器检测常用方法

    Android开发过程中,防作弊一直是老生常谈的问题,而模拟器的检测往往是防作弊中的重要一环,接下来有关于模拟器的检测方法,和大家进行一个简单的分享。

    1.传统的检测方法。

    传统的检测方法主要是对模拟器的IMSI、IDS、默认文件等几个方面进行检测。

    (1)默认号码:

    [java] view plain copy
     
    1. private static String[] known_numbers = {"15555215554", "15555215556",  
    2.             "15555215558", "15555215560", "15555215562", "15555215564",  
    3.             "15555215566", "15555215568", "15555215570", "15555215572",  
    4.             "15555215574", "15555215576", "15555215578", "15555215580",  
    5.             "15555215582", "15555215584"};  

    (2)默认ID:

    [java] view plain copy
     
    1. private static String[] known_device_ids = {"000000000000000"};  

    (3)默认IMSI:

    [java] view plain copy
     
    1. private static String[] known_imsi_ids = {"310260000000000"};  

    (4)默认文件路径:

    [java] view plain copy
     
    1. private static String[] known_files = {  
    2.             "/system/lib/libc_malloc_debug_qemu.so",  
    3.             "/sys/qemu_trace",  
    4.             "/system/bin/qemu-props"};  

    在得知了这些信息后,只需在运行时进行检测,如果检测结果和默认值吻合,那么检测设备便是模拟器。不过随着防反作弊技术的迭代,现在很多模拟器都可以改变这些值来逃避检测,所以上述传统方法在很多时候未曾达到开发者的预期效果。

    2.基于模拟器cpu信息的检测。

    成功率相较于传统方法,有了更高的成功率。

    cpu信息检测主要是在cpu信息看看是否包含intel、amd等字段,很多模拟器目前对于cpu信息还无法进行模拟。

    (1)读取cpu信息:

    [html] view plain copy
     
    1. public static String readCpuInfo() {  
    2.        String result = "";  
    3.        try {  
    4.            String[] args = {"/system/bin/cat", "/proc/cpuinfo"};  
    5.            ProcessBuilder cmd = new ProcessBuilder(args);  
    6.   
    7.            Process process = cmd.start();  
    8.            StringBuffer sb = new StringBuffer();  
    9.            String readLine = "";  
    10.            BufferedReader responseReader = new BufferedReader(new InputStreamReader(process.getInputStream(), "utf-8"));  
    11.            while ((readLine = responseReader.readLine()) != null) {  
    12.                sb.append(readLine);  
    13.            }  
    14.            responseReader.close();  
    15.            result = sb.toString().toLowerCase();  
    16.        } catch (IOException ex) {  
    17.        }  
    18.        return result;  
    19.    }  

    (2)进行判定:

    [java] view plain copy
     
    1. String cpuInfo = readCpuInfo();  
    2. if ((cpuInfo.contains("intel") || cpuInfo.contains("amd"))) {return true;}  

    类似的还有

    [java] view plain copy
     
    1. String[] blockList = "google_sdk,sdk,sdk_x86,vbox86p".split(",");  

    原理相同。

    3.关键路径检测特定模拟器检测

    前面2个方法在很大程度上已经可以鉴定出很多模拟器了,但是对于某些在反防作弊上同样热爱的模拟器,需要特定的检测方法。

    bluestacks成功躲避了前两种检测方法,所以在这里给予其VIP的待遇。

    以下是总结出来的一些bluestacks的关键路径:

    [java] view plain copy
     
    1. private static String[] known_bluestacks = {"/data/app/com.bluestacks.appmart-1.apk", "/data/app/com.bluestacks.BstCommandProcessor-1.apk",  
    2.            "/data/app/com.bluestacks.help-1.apk", "/data/app/com.bluestacks.home-1.apk", "/data/app/com.bluestacks.s2p-1.apk",  
    3.            "/data/app/com.bluestacks.searchapp-1.apk", "/data/bluestacks.prop", "/data/data/com.androVM.vmconfig",  
    4.            "/data/data/com.bluestacks.accelerometerui", "/data/data/com.bluestacks.appfinder", "/data/data/com.bluestacks.appmart",  
    5.            "/data/data/com.bluestacks.appsettings", "/data/data/com.bluestacks.BstCommandProcessor", "/data/data/com.bluestacks.bstfolder",  
    6.            "/data/data/com.bluestacks.help", "/data/data/com.bluestacks.home", "/data/data/com.bluestacks.s2p", "/data/data/com.bluestacks.searchapp",  
    7.            "/data/data/com.bluestacks.settings", "/data/data/com.bluestacks.setup", "/data/data/com.bluestacks.spotlight", "/mnt/prebundledapps/bluestacks.prop.orig"  
    8.    };  


    检测方法:

    [java] view plain copy
     
    1. public static boolean checkBlueStacksFiles() {  
    2.         for (int i = 0; i < known_bluestacks.length; i++) {  
    3.             String file_name = known_bluestacks[i];  
    4.             File qemu_file = new File(file_name);  
    5.             if (qemu_file.exists()) {  
    6.                 FkLog.e("Result : Find BlueStacks Files!");  
    7.                 return true;  
    8.             }  
    9.         }  
    10.         FkLog.e("Result : Not Find BlueStacks Files!");  
    11.         return false;  
    12.     }  

    这种基于关键路径的检测,便可以成功的检测出bluestacks。

    4.模拟器检测新思路

    模拟器检测与模拟器反检测都在不断的更新迭代中,无法确保哪一种方法会永垂不朽,在这里分享下新的思路。

    电池信息检测

    可以从电池的温度和电量等信息入手,检测温度在使用过程中是否一直保持不变、或者是电量一直是固定值并且不是百分之百等等。

    亲测可以鉴别出genymotion、bluestacks等主流模拟器。


    5.写在最后

    其实很多时候在检测模拟器的过程中,都不是只使用某一种固定的方法,一来需要具体问题具体分析,二来也需要用多种方法来综合检测。言而总之,有了十八般武艺才能见招拆招。

    ps:如有错误或需要补充的地方,请各位多多指正~

      http://blog.csdn.net/sinat_33150417/article/details/51320228

    齊帥
  • 相关阅读:
    Java一棵树
    Mac常用设置备忘
    全球测速工具
    mac常用软件
    APP https抓包
    spring无法启动常见原因及排查方法
    Java_cpu飙升排查
    charles_https_通过模拟器安装APP然后抓包
    源码探究Java_HashMap
    The server encountered an internal error that prevented it from fulfilling this request.(JsonMappingException: Conflicting getter definitions)
  • 原文地址:https://www.cnblogs.com/qishuai/p/5756209.html
Copyright © 2011-2022 走看看