From 4bd9568675ed8012ff7edd16e9215242ce4c7b61 Mon Sep 17 00:00:00 2001 From: "yang.bai" Date: Wed, 29 May 2024 10:56:49 +0800 Subject: [PATCH] emulator enhances host recognition --- .../core/collectors/EmulatorCollector.kt | 107 +++++++++--------- 1 file changed, 55 insertions(+), 52 deletions(-) diff --git a/trustdevice/src/main/java/cn/tongdun/mobrisk/core/collectors/EmulatorCollector.kt b/trustdevice/src/main/java/cn/tongdun/mobrisk/core/collectors/EmulatorCollector.kt index 1f400ad..f70f5a4 100644 --- a/trustdevice/src/main/java/cn/tongdun/mobrisk/core/collectors/EmulatorCollector.kt +++ b/trustdevice/src/main/java/cn/tongdun/mobrisk/core/collectors/EmulatorCollector.kt @@ -41,63 +41,66 @@ class EmulatorCollector : EmulatorInterface { "x8.prop", "/system/lib/libc_malloc_debug_qemu.so" ) + private fun checkDevice(): Boolean = "nox" == Build.DEVICE - || "vbox86p" == Build.DEVICE - || "vbox86tp" == Build.DEVICE - || "appplayer" == Build.DEVICE - || "droid4x" == Build.DEVICE - || "vbox" == Build.DEVICE - || "virtual" == Build.DEVICE - || "andywin" == Build.DEVICE - || "andyosx" == Build.DEVICE - || "generic" == Build.DEVICE - || "generic_x86" == Build.DEVICE - || "emu64a" == Build.DEVICE - || Build.DEVICE.lowercase(Locale.getDefault()).contains("mumu") - || Build.DEVICE.lowercase(Locale.getDefault()).contains("zerofltezc") + || "vbox86p" == Build.DEVICE + || "vbox86tp" == Build.DEVICE + || "appplayer" == Build.DEVICE + || "droid4x" == Build.DEVICE + || "vbox" == Build.DEVICE + || "virtual" == Build.DEVICE + || "andywin" == Build.DEVICE + || "andyosx" == Build.DEVICE + || "generic" == Build.DEVICE + || "generic_x86" == Build.DEVICE + || "emu64a" == Build.DEVICE + || Build.DEVICE.lowercase(Locale.getDefault()).contains("mumu") + || Build.DEVICE.lowercase(Locale.getDefault()).contains("zerofltezc") private fun checkModel(): Boolean = "vmos" == Build.MODEL - || "duos" == Build.MODEL - || "amiduos" == Build.MODEL - || "noxw" == Build.MODEL - || "genymotion" == Build.MODEL - || "bluestacks" == Build.MODEL - || "tiantian" == Build.MODEL - || "windroy" == Build.MODEL - || Build.MODEL.contains("google_sdk") - || Build.MODEL.lowercase(Locale.getDefault()).contains("droid4x") - || Build.MODEL.contains("Emulator") - || Build.MODEL.contains("Android SDK built for x86") - || Build.MODEL.contains("Subsystem for Android(TM)") + || "duos" == Build.MODEL + || "amiduos" == Build.MODEL + || "noxw" == Build.MODEL + || "genymotion" == Build.MODEL + || "bluestacks" == Build.MODEL + || "tiantian" == Build.MODEL + || "windroy" == Build.MODEL + || Build.MODEL.contains("google_sdk") + || Build.MODEL.lowercase(Locale.getDefault()).contains("droid4x") + || Build.MODEL.contains("Emulator") + || Build.MODEL.contains("Android SDK built for x86") + || Build.MODEL.contains("Subsystem for Android(TM)") - private fun checkFingerprint(): Boolean = Build.FINGERPRINT.startsWith("generic") - || Build.FINGERPRINT.contains("vbox") + private fun checkFingerprint(): Boolean = Build.FINGERPRINT.startsWith("generic") + || Build.FINGERPRINT.contains("vbox") - private fun checkProduct(): Boolean = "sdk" == Build.PRODUCT - || "google_sdk" == Build.PRODUCT - || "sdk_x86" == Build.PRODUCT - || "vbox86p" == Build.PRODUCT - || "vbox86tp" == Build.PRODUCT - || "genymotion" == Build.PRODUCT - || "bluestacks" == Build.PRODUCT - || "droid4x" == Build.PRODUCT - || "ttvm_hdragon" == Build.PRODUCT - || "duos_native" == Build.PRODUCT - || "duos" == Build.PRODUCT - || "vbox" == Build.PRODUCT - || "android_x86" == Build.PRODUCT - || Build.PRODUCT.lowercase(Locale.getDefault()).contains("nox") + private fun checkProduct(): Boolean = "sdk" == Build.PRODUCT + || "google_sdk" == Build.PRODUCT + || "sdk_x86" == Build.PRODUCT + || "vbox86p" == Build.PRODUCT + || "vbox86tp" == Build.PRODUCT + || "genymotion" == Build.PRODUCT + || "bluestacks" == Build.PRODUCT + || "droid4x" == Build.PRODUCT + || "ttvm_hdragon" == Build.PRODUCT + || "duos_native" == Build.PRODUCT + || "duos" == Build.PRODUCT + || "vbox" == Build.PRODUCT + || "android_x86" == Build.PRODUCT + || Build.PRODUCT.lowercase(Locale.getDefault()).contains("nox") private fun checkHardware(): Boolean = "goldfish" == Build.HARDWARE || "vbox86" == Build.HARDWARE private fun checkOtherBuildInfo(): Boolean = Build.MANUFACTURER.contains("Genymotion") - || Build.BOARD.lowercase(Locale.getDefault()).contains("nox") - || Build.BOOTLOADER.lowercase(Locale.getDefault()).contains("nox") - || Build.HARDWARE.lowercase(Locale.getDefault()).contains("nox") - || Build.SERIAL.lowercase(Locale.getDefault()).contains("nox") - || Build.HOST.lowercase(Locale.getDefault()).startsWith("bliss-os") - || (Build.BRAND.startsWith("generic") && Build.DEVICE.startsWith("generic")) + || Build.BOARD.lowercase(Locale.getDefault()).contains("nox") + || Build.BOOTLOADER.lowercase(Locale.getDefault()).contains("nox") + || Build.HARDWARE.lowercase(Locale.getDefault()).contains("nox") + || Build.SERIAL.lowercase(Locale.getDefault()).contains("nox") + || Build.HOST.lowercase(Locale.getDefault()).startsWith("bliss-os") + || Build.HOST.lowercase(Locale.getDefault()).contentEquals("G1-SNIPER-B7") + || Build.HOST.lowercase(Locale.getDefault()).contentEquals("Build2") + || (Build.BRAND.startsWith("generic") && Build.DEVICE.startsWith("generic")) override fun detectEmulator(): Boolean { var isEmulator = checkBuildInfo() @@ -109,11 +112,11 @@ class EmulatorCollector : EmulatorInterface { private fun checkBuildInfo(): Boolean = checkDevice() || - checkModel() || - checkFingerprint() || - checkProduct() || - checkHardware() || - checkOtherBuildInfo() + checkModel() || + checkFingerprint() || + checkProduct() || + checkHardware() || + checkOtherBuildInfo() private fun checkFiles(): Boolean { for (filePtah in QEMU_FILES) {