Android反调试之 AntiEmulator 检测安卓模拟器
2016-05-19 17:26
573 查看
转自:http://0nly3nd.sinaapp.com/?p=368
代码demo:
Java
代码demo:
Java
检查模拟器系统的一些信息
代码demo:
Java
代码demo:
Java
我自己模拟器上的测试结果:
本文出自 0n1y3nd's Blog,转载时请注明出处及相应链接。
本文永久链接: http://0nly3nd.sinaapp.com/?p=368
八种方法检测是否存在模拟器
检查特定的几个关键点0×1
检测“/dev/socket/qemud”,“/dev/qemu_pipe”这两个通道代码demo:
Java
123456789101112131415161718 | private static String[] known_pipes = { "/dev/socket/qemud", "/dev/qemu_pipe" };public boolean checkPipes(){ for (int i = 0; i < known_pipes.length; i++) { String pipes = known_pipes[i]; File qemu_socket = new File(pipes); if (qemu_socket.exists()) { Log.v("Result:", "Find pipes!"); return true; } } Log.v("Result:", "Not Find pipes!"); return false;} |
0×2
// 检测驱动文件内容// 读取文件内容,然后检查已知QEmu的驱动程序的列表代码demo:Java1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | private static String[] known_qemu_drivers = { "goldfish" }; public static Boolean CheckQEmuDriverFile() { File driver_file = new File("/proc/tty/drivers"); if (driver_file.exists() && driver_file.canRead()) { byte[] data = new byte[(int) driver_file.length()]; try { InputStream inStream = new FileInputStream(driver_file); inStream.read(data); inStream.close(); } catch (FileNotFoundException e) { // TODO 自动生成的 catch 块 e.printStackTrace(); } catch (IOException e) { // TODO 自动生成的 catch 块 e.printStackTrace(); } String driver_data = new String(data); for (String known_qemu_driver : FindEmulatorDemo.known_qemu_drivers) { if (driver_data.indexOf(known_qemu_driver) != -1) { Log.v("Result:", "Find known_qemu_drivers!"); return true; } } } Log.v("Result:", "Not Find known_qemu_drivers!"); return false; } |
0×3
//检测模拟器上特有的几个文件代码demo:
Java
1234567891011121314151617 | private static String[] known_files = { "/system/lib/libc_malloc_debug_qemu.so", "/sys/qemu_trace", "/system/bin/qemu-props"};public static Boolean CheckEmulatorFiles() { for (int i = 0; i < known_files.length; i++) { String file_name = known_files[i]; File qemu_file = new File(file_name); if (qemu_file.exists()) { Log.v("Result:", "Find Emulator Files!"); return true; } } Log.v("Result:", "Not Find Emulator Files!"); return false;} |
0×4
// 检测模拟器默认的电话号码代码demo:Java1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | private static String[] known_numbers = { "15555215554", "15555215556", "15555215558", "15555215560", "15555215562", "15555215564", "15555215566", "15555215568", "15555215570", "15555215572", "15555215574", "15555215576", "15555215578", "15555215580", "15555215582", "15555215584", }; public static Boolean CheckPhoneNumber(Context context) { TelephonyManager telephonyManager = (TelephonyManager) context .getSystemService(Context.TELEPHONY_SERVICE); String phonenumber = telephonyManager.getLine1Number(); for (String number : known_numbers) { if (number.equalsIgnoreCase(phonenumber)) { Log.v("Result:", "Find PhoneNumber!"); return true; } } Log.v("Result:", "Not Find PhoneNumber!"); return false; } |
0×5
//检测设备IDS 是不是 “000000000000000”代码demo:
Java
123456789101112131415161718 | private static String[] known_device_ids = { "000000000000000" // 默认ID}; public static Boolean CheckDeviceIDS(Context context) { TelephonyManager telephonyManager = (TelephonyManager) context .getSystemService(Context.TELEPHONY_SERVICE); String device_ids = telephonyManager.getDeviceId(); for (String know_deviceid : known_device_ids) { if (know_deviceid.equalsIgnoreCase(device_ids)) { Log.v("Result:", "Find ids: 000000000000000!"); return true; } } Log.v("Result:", "Not Find ids: 000000000000000!"); return false;} |
0×6
// 检测imsi id是不是“310260000000000”代码demo:Java1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | private static String[] known_imsi_ids = { "310260000000000" // 默认的 imsi id }; public static Boolean CheckImsiIDS(Context context){ TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); String imsi_ids = telephonyManager.getSubscriberId(); for (String know_imsi : known_imsi_ids) { if (know_imsi.equalsIgnoreCase(imsi_ids)) { Log.v("Result:", "Find imsi ids: 310260000000000!"); return true; } } Log.v("Result:", "Not Find imsi ids: 310260000000000!"); return false; } |
0×7
//检测手机上的一些硬件信息代码demo:
Java
12345678910111213141516171819 | public static Boolean CheckEmulatorBuild(Context context){ String BOARD = android.os.Build.BOARD; String BOOTLOADER = android.os.Build.BOOTLOADER; String BRAND = android.os.Build.BRAND; String DEVICE = android.os.Build.DEVICE; String HARDWARE = android.os.Build.HARDWARE; String MODEL = android.os.Build.MODEL; String PRODUCT = android.os.Build.PRODUCT; if (BOARD == "unknown" || BOOTLOADER == "unknown" || BRAND == "generic" || DEVICE == "generic" || MODEL == "sdk" || PRODUCT == "sdk" || HARDWARE == "goldfish") { Log.v("Result:", "Find Emulator by EmulatorBuild!"); return true; } Log.v("Result:", "Not Find Emulator by EmulatorBuild!"); return false;} |
0×8
//检测手机运营商家代码demo:Java1 2 3 4 5 6 7 8 9 10 11 | public static boolean CheckOperatorNameAndroid(Context context) { String szOperatorName = ((TelephonyManager) context.getSystemService("phone")).getNetworkOperatorName(); if (szOperatorName.toLowerCase().equals("android") == true) { Log.v("Result:", "Find Emulator by OperatorName!"); return true; } Log.v("Result:", "Not Find Emulator by OperatorName!"); return false; } |
本文出自 0n1y3nd's Blog,转载时请注明出处及相应链接。
本文永久链接: http://0nly3nd.sinaapp.com/?p=368
相关文章推荐
- Android Button text自动变成大写
- android中利用webview调用网页上的js代码 Java代码调用js并传递参数
- 修改WIFI热点的默认名称
- Android RecyclerView添加头部和底部的方法
- Android之Adapter用法总结
- Android 关闭Log日志
- Android学习笔记三十一:Java异常处理中try,catch,finally的各种组合用法
- Android audio transmit with Base64 based on XMPP
- Android 录像保存后在文件管理或相册里不显示问题
- android中CheckBox自定义样式
- Android View体系(十)自定义组合控件
- Android全局获取Context
- AndroidStudio插件GsonFormat
- Android 自定义一款炫酷的加载控件
- Android自定义控件三部曲文章索引
- Android视频播放器横竖屏自动切换
- Android中的Drawable使用
- Android一键换肤功能:一种简单的实现
- Android Studio 运行java程序
- Android一键换肤功能:一种简单的实现