TikChat v1.0.1版本的 MD5 值为:6387a5d2555771afeaa25f490c6460b7
以下内容为反编译后的 EmuDetector.java 源代码,内容仅作参考
package org.telegram.messenger;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Environment;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import androidx.core.content.ContextCompat;
import com.umeng.commonsdk.statistics.SdkVersion;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
public class EmuDetector {
private static final String IP = "10.0.2.15";
private static final int MIN_PROPERTIES_THRESHOLD = 5;
@SuppressLint({"StaticFieldLeak"})
private static EmuDetector mEmulatorDetector;
private boolean detectResult;
private boolean detected;
private final Context mContext;
private List<String> mListPackageName;
private static final String[] PHONE_NUMBERS = {"15555215554", "15555215556", "15555215558", "15555215560", "15555215562", "15555215564", "15555215566", "15555215568", "15555215570", "15555215572", "15555215574", "15555215576", "15555215578", "15555215580", "15555215582", "15555215584"};
private static final String[] DEVICE_IDS = {"000000000000000", "e21833235b6eef10", "012345678912345"};
private static final String[] IMSI_IDS = {"310260000000000"};
private static final String[] GENY_FILES = {"/dev/socket/genyd", "/dev/socket/baseband_genyd"};
private static final String[] QEMU_DRIVERS = {"goldfish"};
private static final String[] PIPES = {"/dev/socket/qemud", "/dev/qemu_pipe"};
private static final String[] X86_FILES = {"ueventd.android_x86.rc", "x86.prop", "ueventd.ttVM_x86.rc", "init.ttVM_x86.rc", "fstab.ttVM_x86", "fstab.vbox86", "init.vbox86.rc", "ueventd.vbox86.rc"};
private static final String[] ANDY_FILES = {"fstab.andy", "ueventd.andy.rc"};
private static final String[] NOX_FILES = {"fstab.nox", "init.nox.rc", "ueventd.nox.rc", "/BigNoxGameHD", "/YSLauncher"};
private static final String[] BLUE_FILES = {"/Android/data/com.bluestacks.home", "/Android/data/com.bluestacks.settings"};
private static final Property[] PROPERTIES = {new Property("init.svc.qemud", null), new Property("init.svc.qemu-props", null), new Property("qemu.hw.mainkeys", null), new Property("qemu.sf.fake_camera", null), new Property("qemu.sf.lcd_density", null), new Property("ro.bootloader", "unknown"), new Property("ro.bootmode", "unknown"), new Property("ro.hardware", "goldfish"), new Property("ro.kernel.android.qemud", null), new Property("ro.kernel.qemu.gles", null), new Property("ro.kernel.qemu", SdkVersion.MINI_VERSION), new Property("ro.product.device", "generic"), new Property("ro.product.model", "sdk"), new Property("ro.product.name", "sdk"), new Property("ro.serialno", null)};
private boolean isTelephony = false;
private boolean isCheckPackage = true;
public enum EmulatorTypes {
GENY,
ANDY,
NOX,
BLUE,
PIPES,
X86
}
public interface OnEmulatorDetectorListener {
void onResult(boolean z);
}
private boolean checkDeviceId() {
return false;
}
private boolean checkImsi() {
return false;
}
private boolean checkPhoneNumber() {
return false;
}
public static class Property {
public String name;
public String seek_value;
public Property(String str, String str2) {
this.name = str;
this.seek_value = str2;
}
}
public static EmuDetector with(Context context) {
if (context == null) {
throw new IllegalArgumentException("Context must not be null.");
}
if (mEmulatorDetector == null) {
mEmulatorDetector = new EmuDetector(context.getApplicationContext());
}
return mEmulatorDetector;
}
private EmuDetector(Context context) {
ArrayList arrayList = new ArrayList();
this.mListPackageName = arrayList;
this.mContext = context;
arrayList.add("com.google.android.launcher.layouts.genymotion");
this.mListPackageName.add("com.bluestacks");
this.mListPackageName.add("com.bignox.app");
this.mListPackageName.add("com.vphone.launcher");
}
public boolean isCheckTelephony() {
return this.isTelephony;
}
public boolean isCheckPackage() {
return this.isCheckPackage;
}
public EmuDetector setCheckTelephony(boolean z) {
this.isTelephony = z;
return this;
}
public EmuDetector setCheckPackage(boolean z) {
this.isCheckPackage = z;
return this;
}
public EmuDetector addPackageName(String str) {
this.mListPackageName.add(str);
return this;
}
public EmuDetector addPackageName(List<String> list) {
this.mListPackageName.addAll(list);
return this;
}
public boolean detect() {
if (this.detected) {
return this.detectResult;
}
try {
this.detected = true;
if (!this.detectResult) {
this.detectResult = checkBasic();
}
if (!this.detectResult) {
this.detectResult = checkAdvanced();
}
if (!this.detectResult) {
this.detectResult = checkPackageName();
}
if (!this.detectResult) {
this.detectResult = EmuInputDevicesDetector.detect();
}
return this.detectResult;
} catch (Exception unused) {
return false;
}
}
private boolean checkBasic() {
boolean z;
boolean z2 = false;
if (!Build.BOARD.toLowerCase().contains("nox") && !Build.BOOTLOADER.toLowerCase().contains("nox") && !Build.FINGERPRINT.startsWith("generic")) {
String str = Build.MODEL;
if (!str.toLowerCase().contains("google_sdk") && !str.toLowerCase().contains("droid4x") && !str.toLowerCase().contains("emulator") && !str.contains("Android SDK built for x86") && !Build.MANUFACTURER.toLowerCase().contains("genymotion")) {
String str2 = Build.HARDWARE;
if (!str2.toLowerCase().contains("goldfish") && !str2.toLowerCase().contains("vbox86") && !str2.toLowerCase().contains("android_x86") && !str2.toLowerCase().contains("nox")) {
String str3 = Build.PRODUCT;
if (!str3.equals("sdk") && !str3.equals("google_sdk") && !str3.equals("sdk_x86") && !str3.equals("vbox86p") && !str3.toLowerCase().contains("nox") && !Build.SERIAL.toLowerCase().contains("nox")) {
z = false;
if (z) {
if (Build.BRAND.startsWith("generic") && Build.DEVICE.startsWith("generic")) {
z2 = true;
}
boolean z3 = z | z2;
if (z3) {
return true;
}
return z3 | "google_sdk".equals(Build.PRODUCT);
}
return true;
}
}
}
}
z = true;
if (z) {
}
}
private boolean checkAdvanced() {
return checkTelephony() || checkFiles(GENY_FILES, EmulatorTypes.GENY) || checkFiles(ANDY_FILES, EmulatorTypes.ANDY) || checkFiles(NOX_FILES, EmulatorTypes.NOX) || checkFiles(BLUE_FILES, EmulatorTypes.BLUE) || checkQEmuDrivers() || checkFiles(PIPES, EmulatorTypes.PIPES) || checkIp() || (checkQEmuProps() && checkFiles(X86_FILES, EmulatorTypes.X86));
}
private boolean checkPackageName() {
if (this.isCheckPackage && !this.mListPackageName.isEmpty()) {
PackageManager packageManager = this.mContext.getPackageManager();
for (String str : this.mListPackageName) {
Intent launchIntentForPackage = packageManager.getLaunchIntentForPackage(str);
if (launchIntentForPackage != null && !packageManager.queryIntentActivities(launchIntentForPackage, 65536).isEmpty()) {
return true;
}
}
}
return false;
}
private boolean checkTelephony() {
return ContextCompat.checkSelfPermission(this.mContext, "android.permission.READ_PHONE_STATE") == 0 && this.isTelephony && isSupportTelePhony() && (checkPhoneNumber() || checkDeviceId() || checkImsi() || checkOperatorNameAndroid());
}
private boolean checkOperatorNameAndroid() {
return ((TelephonyManager) this.mContext.getSystemService("phone")).getNetworkOperatorName().equalsIgnoreCase("android");
}
private boolean checkQEmuDrivers() {
File[] fileArr = {new File("/proc/tty/drivers"), new File("/proc/cpuinfo")};
for (int i = 0; i < 2; i++) {
File file = fileArr[i];
if (file.exists() && file.canRead()) {
byte[] bArr = new byte[1024];
try {
FileInputStream fileInputStream = new FileInputStream(file);
fileInputStream.read(bArr);
fileInputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
String str = new String(bArr);
for (String str2 : QEMU_DRIVERS) {
if (str.contains(str2)) {
return true;
}
}
continue;
}
}
return false;
}
private boolean checkFiles(String[] strArr, EmulatorTypes emulatorTypes) {
File file;
for (String str : strArr) {
if (ContextCompat.checkSelfPermission(this.mContext, "android.permission.READ_EXTERNAL_STORAGE") == 0) {
if ((str.contains("/") && emulatorTypes == EmulatorTypes.NOX) || emulatorTypes == EmulatorTypes.BLUE) {
file = new File(Environment.getExternalStorageDirectory() + str);
} else {
file = new File(str);
}
} else {
file = new File(str);
}
if (file.exists()) {
return true;
}
}
return false;
}
private boolean checkQEmuProps() {
Property[] propertyArr;
int i = 0;
for (Property property : PROPERTIES) {
String prop = getProp(this.mContext, property.name);
String str = property.seek_value;
if (str == null && prop != null) {
i++;
}
if (str != null && prop.contains(str)) {
i++;
}
}
return i >= 5;
}
private boolean checkIp() {
String[] split;
if (ContextCompat.checkSelfPermission(this.mContext, "android.permission.INTERNET") == 0) {
String[] strArr = {"/system/bin/netcfg"};
StringBuilder sb = new StringBuilder();
try {
ProcessBuilder processBuilder = new ProcessBuilder(strArr);
processBuilder.directory(new File("/system/bin/"));
processBuilder.redirectErrorStream(true);
InputStream inputStream = processBuilder.start().getInputStream();
byte[] bArr = new byte[1024];
while (inputStream.read(bArr) != -1) {
sb.append(new String(bArr));
}
inputStream.close();
} catch (Exception unused) {
}
String sb2 = sb.toString();
if (TextUtils.isEmpty(sb2)) {
return false;
}
for (String str : sb2.split("\n")) {
if ((str.contains("wlan0") || str.contains("tunl0") || str.contains("eth0")) && str.contains(IP)) {
return true;
}
}
return false;
}
return false;
}
private String getProp(Context context, String str) {
try {
Class<?> loadClass = context.getClassLoader().loadClass("android.os.SystemProperties");
return (String) loadClass.getMethod("get", String.class).invoke(loadClass, str);
} catch (Exception unused) {
return null;
}
}
private boolean isSupportTelePhony() {
return this.mContext.getPackageManager().hasSystemFeature("android.hardware.telephony");
}
}