├── .gitignore ├── .idea ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── gradle.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── README.md ├── app ├── .gitignore ├── CMakeLists.txt ├── app-release.apk ├── build.gradle ├── libnative-lib.so ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── qtfreet │ │ └── anticheckemulator │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── cpp │ │ └── native-lib.cpp │ ├── java │ │ └── com │ │ │ └── qtfreet │ │ │ └── anticheckemulator │ │ │ ├── MainActivity.java │ │ │ ├── emulator │ │ │ ├── Check.java │ │ │ ├── GLSurfaceView.java │ │ │ ├── GpuRender.java │ │ │ └── JniAnti.java │ │ │ └── utils │ │ │ └── Util.java │ └── res │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── qtfreet │ └── anticheckemulator │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Anti-Emulator 2 | Android Anti Emulator 3 | 基于模拟器特征文件的检测方式,利用jni和java共同实现。 4 | 5 | ####原理分析 6 | [文章地址](http://mp.weixin.qq.com/s/sl33d2pnyLMJ-fUY_DfBDw) 7 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.4.1) 2 | 3 | add_library(native-lib SHARED src/main/cpp/native-lib.cpp ) 4 | 5 | find_library(log-lib log ) 6 | 7 | target_link_libraries(native-lib ${log-lib} ) 8 | -------------------------------------------------------------------------------- /app/app-release.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ysrc/Anti-Emulator/05277af739839b18d4cd7773fc0c845c87d73f13/app/app-release.apk -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "25.0.0" 6 | defaultConfig { 7 | applicationId "com.qtfreet.anticheckemulator" 8 | minSdkVersion 15 9 | targetSdkVersion 25 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | externalNativeBuild { 14 | cmake { 15 | cppFlags "-fexceptions" 16 | cppFlags "-O3" 17 | } 18 | } 19 | } 20 | buildTypes { 21 | release { 22 | minifyEnabled false 23 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 24 | } 25 | } 26 | externalNativeBuild { 27 | cmake { 28 | path "CMakeLists.txt" 29 | } 30 | } 31 | } 32 | 33 | dependencies { 34 | compile fileTree(dir: 'libs', include: ['*.jar']) 35 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 36 | exclude group: 'com.android.support', module: 'support-annotations' 37 | }) 38 | compile 'com.android.support:appcompat-v7:25.0.1' 39 | testCompile 'junit:junit:4.12' 40 | } 41 | -------------------------------------------------------------------------------- /app/libnative-lib.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ysrc/Anti-Emulator/05277af739839b18d4cd7773fc0c845c87d73f13/app/libnative-lib.so -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in D:\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/qtfreet/anticheckemulator/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.qtfreet.anticheckemulator; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.qtfreet.anticheckemulator", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /app/src/main/cpp/native-lib.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, "qtfreet00", __VA_ARGS__) 14 | 15 | 16 | extern "C" { 17 | 18 | int i = 0; 19 | 20 | char *jstringToChar(JNIEnv *env, jstring jstr) { 21 | if (jstr == NULL) { 22 | return NULL; 23 | 24 | } 25 | char *rtn = new char; 26 | jclass clsstring = env->FindClass("java/lang/String"); 27 | jstring strencode = env->NewStringUTF("utf-8"); 28 | jmethodID mid = env->GetMethodID(clsstring, "getBytes", "(Ljava/lang/String;)[B"); 29 | jbyteArray barr = (jbyteArray) env->CallObjectMethod(jstr, mid, strencode); 30 | jsize alen = env->GetArrayLength(barr); 31 | jbyte *ba = env->GetByteArrayElements(barr, JNI_FALSE); 32 | if (alen > 0) { 33 | rtn = (char *) malloc(alen + 1); 34 | memcpy(rtn, ba, alen); 35 | rtn[alen] = 0; 36 | 37 | } else { 38 | rtn = ""; 39 | 40 | } 41 | 42 | /**资源清理**/ 43 | env->ReleaseByteArrayElements(barr, ba, 0); 44 | if (clsstring != NULL) { 45 | env->DeleteLocalRef(clsstring); 46 | clsstring = NULL; 47 | 48 | } 49 | if (strencode != NULL) { 50 | env->DeleteLocalRef(strencode); 51 | strencode = NULL; 52 | 53 | } 54 | mid = NULL; 55 | return rtn; 56 | } 57 | 58 | jstring chartoJstring(JNIEnv *env, const char *pat) { 59 | jclass strClass = env->FindClass("Ljava/lang/String;"); 60 | jmethodID ctorID = env->GetMethodID(strClass, "", "([BLjava/lang/String;)V"); 61 | jbyteArray bytes = env->NewByteArray(strlen(pat)); 62 | env->SetByteArrayRegion(bytes, 0, strlen(pat), (jbyte *) pat); 63 | jstring encoding = env->NewStringUTF("utf-8"); 64 | return (jstring) env->NewObject(strClass, ctorID, bytes, encoding); 65 | } 66 | 67 | 68 | jobject getApplication(JNIEnv *env) { 69 | jclass localClass = env->FindClass("android/app/ActivityThread"); 70 | if (localClass != NULL) { 71 | jmethodID getapplication = env->GetStaticMethodID(localClass, "currentApplication", 72 | "()Landroid/app/Application;"); 73 | if (getapplication != NULL) { 74 | jobject application = env->CallStaticObjectMethod(localClass, getapplication); 75 | return application; 76 | } 77 | return NULL; 78 | } 79 | return NULL; 80 | } 81 | 82 | 83 | char *verifySign(JNIEnv *env) { 84 | //此处用于获取app签名 85 | jobject context = getApplication(env); 86 | jclass activity = env->GetObjectClass(context); 87 | // 得到 getPackageManager 方法的 ID 88 | jmethodID methodID_func = env->GetMethodID(activity, "getPackageManager", 89 | "()Landroid/content/pm/PackageManager;"); 90 | // 获得PackageManager对象 91 | jobject packageManager = env->CallObjectMethod(context, methodID_func); 92 | jclass packageManagerclass = env->GetObjectClass(packageManager); 93 | //得到 getPackageName 方法的 ID 94 | jmethodID methodID_pack = env->GetMethodID(activity, "getPackageName", "()Ljava/lang/String;"); 95 | //获取包名 96 | jstring name_str = static_cast(env->CallObjectMethod(context, methodID_pack)); 97 | // 得到 getPackageInfo 方法的 ID 98 | jmethodID methodID_pm = env->GetMethodID(packageManagerclass, "getPackageInfo", 99 | "(Ljava/lang/String;I)Landroid/content/pm/PackageInfo;"); 100 | // 获得应用包的信息 101 | jobject package_info = env->CallObjectMethod(packageManager, methodID_pm, name_str, 64); 102 | // 获得 PackageInfo 类 103 | jclass package_infoclass = env->GetObjectClass(package_info); 104 | // 获得签名数组属性的 ID 105 | jfieldID fieldID_signatures = env->GetFieldID(package_infoclass, "signatures", 106 | "[Landroid/content/pm/Signature;"); 107 | // 得到签名数组,待修改 108 | jobject signatur = env->GetObjectField(package_info, fieldID_signatures); 109 | jobjectArray signatures = reinterpret_cast(signatur); 110 | // 得到签名 111 | jobject signature = env->GetObjectArrayElement(signatures, 0); 112 | // 获得 Signature 类,待修改 113 | jclass signature_clazz = env->GetObjectClass(signature); 114 | //获取sign 115 | jmethodID toCharString = env->GetMethodID(signature_clazz, "toCharsString", 116 | "()Ljava/lang/String;"); 117 | //获取签名字符;或者其他进行验证操作 118 | jstring signstr = static_cast(env->CallObjectMethod(signature, toCharString)); 119 | char *ch = jstringToChar(env, signstr); 120 | //输入签名字符串,这里可以进行相关验证 121 | return ch; 122 | } 123 | 124 | 125 | jstring getDeviceID(JNIEnv *env, jobject instance) { 126 | jobject mContext = getApplication(env); 127 | if (mContext == NULL) { 128 | return (env)->NewStringUTF("unknown"); 129 | } 130 | jclass cls_context = (env)->FindClass("android/content/Context"); 131 | if (cls_context == 0) { 132 | return (env)->NewStringUTF("unknown"); 133 | } 134 | jmethodID getSystemService = (env)->GetMethodID(cls_context, 135 | "getSystemService", 136 | "(Ljava/lang/String;)Ljava/lang/Object;"); 137 | if (getSystemService == 0) { 138 | return (env)->NewStringUTF("unknown"); 139 | } 140 | jfieldID TELEPHONY_SERVICE = (env)->GetStaticFieldID(cls_context, 141 | "TELEPHONY_SERVICE", "Ljava/lang/String;"); 142 | if (TELEPHONY_SERVICE == 0) { 143 | return (env)->NewStringUTF("unknown"); 144 | } 145 | jobject str = (env)->GetStaticObjectField(cls_context, TELEPHONY_SERVICE); 146 | jobject telephonymanager = (env)->CallObjectMethod(mContext, 147 | getSystemService, str); 148 | if (telephonymanager == 0) { 149 | return (env)->NewStringUTF("unknown"); 150 | } 151 | jclass cls_tm = (env)->FindClass("android/telephony/TelephonyManager"); 152 | if (cls_tm == 0) { 153 | return (env)->NewStringUTF("unknown"); 154 | } 155 | jmethodID getDeviceId = (env)->GetMethodID(cls_tm, "getDeviceId", 156 | "()Ljava/lang/String;"); 157 | if (getDeviceId == 0) { 158 | return (env)->NewStringUTF("unknown"); 159 | } 160 | jstring deviceid = static_cast((env)->CallObjectMethod(telephonymanager, getDeviceId)); 161 | char *ch = jstringToChar(env, deviceid); 162 | return deviceid; 163 | } 164 | 165 | char *getCpuInfo() { //获取cpu型号 166 | //此处在测试时去判断cpu型号是否是intel core,至强或者奔腾,AMD系列,x86手机cpu型号为intel atom,arm一般为联发科,高通,麒麟等等 167 | //如是判断为前者,则认为当前环境为模拟器 168 | 169 | char *info = new char[128]; 170 | memset(info, 0, 128); 171 | // char *res = new char[256]; 172 | // memset(res,0,256); 173 | char *split = ":"; 174 | char *cmd = "/proc/cpuinfo"; 175 | FILE *ptr; 176 | if ((ptr = fopen(cmd, "r")) != NULL) { 177 | while (fgets(info, 128, ptr)) { 178 | char *tmp = NULL; 179 | //去掉换行符 180 | if (tmp = strstr(info, "\n")) 181 | *tmp = '\0'; 182 | //去掉回车符 183 | if (tmp = strstr(info, "\r")) 184 | *tmp = '\0'; 185 | if (strstr(info, 186 | "Hardware")) { //真机一般会获取到hardware,示例:Qualcomm MSM 8974 HAMMERHEAD (Flattened Device Tree) 187 | strtok(info, split); 188 | char *s = strtok(NULL, split); 189 | return s; 190 | } else if (strstr(info, 191 | "model name")) { //测试了一个模拟器,取到的是model_name,示例:Intel(R) Core(TM) i5-4590 CPU @ 3.30GHz 192 | strtok(info, split); 193 | char *s = strtok(NULL, split); 194 | //x86架构的移动处理器为Intel(R) Atom(TM) 195 | if (strstr(s, "Intel(R) Core(TM)") || strstr(s, "Intel(R) Pentium(R)") || 196 | strstr(s, "Intel(R) Xeon(R)") || 197 | strstr(s, "AMD")) { //分别为最常见的酷睿,奔腾,至强,AMD处理器 198 | 199 | } 200 | LOGE("the cpu native info is %s", s); 201 | return s; 202 | } 203 | } 204 | } else { 205 | LOGE("NULLLLLLLLL"); 206 | } 207 | } 208 | 209 | char * 210 | getVersionInfo() { 211 | //获取设备版本,真机示例:Linux version 3.4.0-cyanogenmod (ls@ywk) (gcc version 4.7 (GCC) ) #1 SMP PREEMPT Tue Apr 12 11:38:13 CST 2016 212 | // 海马玩: Linux version 3.4.0-qemu+ (droid4x@CA) (gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) ) #25 SMP PREEMPT Tue Sep 22 15:50:48 213 | //腾讯模拟器中包含了tencent字眼 214 | char *info = new char[256]; 215 | memset(info, 0, 256); 216 | char *cmd = "/proc/version"; 217 | FILE *ptr; 218 | if ((ptr = fopen(cmd, "r")) != NULL) { 219 | while (fgets(info, 256, ptr)) { 220 | char *tmp = NULL; 221 | if (tmp = strstr(info, "\n")) 222 | *tmp = '\0'; 223 | //去掉回车符 224 | if (tmp = strstr(info, "\r")) 225 | *tmp = '\0'; 226 | //包含qemu+或者tencent均为模拟器 227 | LOGE("the kernel info is %s", info); 228 | return info; 229 | } 230 | } else { 231 | LOGE("NULLLLLLLLL"); 232 | return NULL; 233 | } 234 | } 235 | 236 | void antiFile(char *res) { 237 | struct stat buf; 238 | int result = stat(res, &buf) == 0 ? 1 : 0; 239 | if (result) { 240 | LOGE("%s exsits, emulator!", res); 241 | // kill(getpid(),SIGKILL); 242 | i++; 243 | } 244 | } 245 | 246 | void antiProperty(char *res) { 247 | char buff[PROP_VALUE_MAX]; 248 | memset(buff, 0, PROP_VALUE_MAX); 249 | int result = 250 | __system_property_get(res, (char *) &buff) > 0 ? 1 : 0; //返回命令行内容的长度 251 | if (result != 0) { 252 | LOGE("%s %s exsits, emulator!", res, buff); 253 | // kill(getpid(),SIGKILL); 254 | i++; 255 | } 256 | } 257 | 258 | void antiPropertyValueContains(char *res, char *val) { 259 | char buff[PROP_VALUE_MAX + 1]; 260 | memset(buff, 0, PROP_VALUE_MAX + 1); 261 | int lman = __system_property_get(res, buff); 262 | if (lman > 0) { 263 | if (strstr(buff, val) != NULL) { // match! 264 | LOGE("%s property value contains %s . Emulator!", res, val); 265 | i++; 266 | } 267 | } 268 | } 269 | 270 | void getDeviceInfo() { 271 | char buff[PROP_VALUE_MAX]; 272 | memset(buff, 0, PROP_VALUE_MAX); 273 | __system_property_get("ro.product.name", (char *) &buff); 274 | LOGE("the model name is %s", buff); 275 | if (!strcmp(buff, "ChangWan")) { 276 | // kill(getpid(),SIGKILL); 277 | 278 | } else if (!strcmp(buff, "Droid4X")) { //非0均为模拟器 279 | // kill(getpid(),SIGKILL); 280 | } else if (!strcmp(buff, "lgshouyou")) { 281 | // kill(getpid(),SIGKILL); 282 | } else if (!strcmp(buff, "nox")) { 283 | // kill(getpid(),SIGKILL); 284 | } else if (!strcmp(buff, "ttVM_Hdragon")) { 285 | // kill(getpid(),SIGKILL); 286 | } 287 | 288 | } 289 | 290 | 291 | char *SocketTest(char *c) { 292 | struct sockaddr_in serv_addr; 293 | char buff[1024]; 294 | char res[4096]; 295 | memset(res, 0, 4096); 296 | memset(buff, 0, 1024); 297 | memset(&serv_addr, 0, sizeof(serv_addr)); 298 | 299 | char *addr = "107.151.180.166"; 300 | int socketfd = socket(AF_INET, SOCK_STREAM, 0); 301 | if (socketfd == -1) { 302 | LOGE("create error"); 303 | LOGE("error (errno=%d)", errno); 304 | exit(1); 305 | } 306 | serv_addr.sin_family = AF_INET; 307 | serv_addr.sin_port = htons(6666); 308 | serv_addr.sin_addr.s_addr = inet_addr(addr); 309 | if (serv_addr.sin_addr.s_addr == INADDR_NONE) { 310 | struct hostent *host = gethostbyname(addr); 311 | if (host == NULL) { 312 | LOGE("error (errno=%d)", errno); 313 | exit(1); 314 | } 315 | serv_addr.sin_addr.s_addr = ((struct in_addr *) host->h_addr)->s_addr; 316 | } 317 | memset(serv_addr.sin_zero, 0, sizeof(serv_addr.sin_zero)); 318 | int conn = connect(socketfd, (struct sockaddr *) &serv_addr, sizeof(struct sockaddr)); 319 | if (conn == -1) { 320 | LOGE("connect error"); 321 | LOGE("error (errno=%d)", errno); 322 | exit(1); 323 | } 324 | int sen = send(socketfd, c, strlen(c), 0); 325 | if (sen == -1) { 326 | LOGE("send errorrr"); 327 | LOGE("error (errno=%d)", errno); 328 | exit(1); 329 | } 330 | while (recv(socketfd, buff, 1023, 0) > 0) { 331 | LOGE("%s", buff); 332 | strcpy(res, buff); 333 | } 334 | close(socketfd); 335 | LOGE("send successssss"); 336 | return res; 337 | 338 | } 339 | 340 | /*逍遥模拟器 341 | * 12-13 12:20:58.671 1615-1615/? E/qtfreet00: the /system/bin/microvirt-prop is exist 342 | 12-13 12:20:58.671 1615-1615/? E/qtfreet00: the /system/bin/microvirtd is exist 343 | 12-13 12:20:58.671 1615-1615/? E/qtfreet00: the init.svc.vbox86-setup result is stopped 344 | 12-13 12:20:58.671 1615-1615/? E/qtfreet00: the init.svc.microvirtd result is running*/ 345 | 346 | jint check(JNIEnv *env, jobject instance) { 347 | 348 | antiFile("/system/bin/qemu_props"); //检测原生模拟器 349 | // antiFile("/system/bin/qemud"); //小米会检测出此项 350 | antiFile("/system/bin/androVM-prop"); 351 | antiFile("/system/bin/microvirt-prop");//逍遥 352 | antiFile("/system/lib/libdroid4x.so"); //海马玩 353 | antiFile("/system/bin/windroyed");//文卓爷 354 | antiFile("/system/bin/microvirtd");//逍遥 355 | antiFile("/system/bin/nox-prop"); //夜神 356 | antiFile("/system/bin/ttVM-prop"); //天天 357 | antiFile("/system/bin/droid4x-prop"); //海马玩 358 | antiFile("/data/.bluestacks.prop");//bluestacks 359 | antiProperty("init.svc.vbox86-setup"); //基于vitrualbox 360 | antiProperty("init.svc.droid4x"); //海马玩 361 | antiProperty("init.svc.qemud"); 362 | antiProperty("init.svc.su_kpbs_daemon"); 363 | antiProperty("init.svc.noxd"); //夜神 364 | antiProperty("init.svc.ttVM_x86-setup"); //天天 365 | antiProperty("init.svc.xxkmsg"); 366 | antiProperty("init.svc.microvirtd");//逍遥 367 | // antiProperty("ro.secure"); //检测selinux是否被关闭,一般手机均开启此选项 368 | antiProperty("ro.kernel.android.qemud"); 369 | // antiProperty("ro.kernel.qemu.gles"); //三星SM-G5500误报此项 370 | antiProperty("androVM.vbox_dpi"); 371 | antiProperty("androVM.vbox_graph_mode"); 372 | antiPropertyValueContains("ro.product.manufacturer", 373 | "Genymotion"); // Genymotion check ,thx alinbaturn 374 | return i; 375 | } 376 | 377 | jstring getCpuinfo(JNIEnv *env, jobject instance) { 378 | 379 | char *res = getCpuInfo(); 380 | 381 | return env->NewStringUTF(res); 382 | } 383 | 384 | jstring getKernelVersion(JNIEnv *env, jobject /* this */) { 385 | 386 | char *res = getVersionInfo(); 387 | 388 | return env->NewStringUTF(res); 389 | } 390 | 391 | jstring getApkSign(JNIEnv *env, jobject /* this */) { 392 | 393 | char *res = verifySign(env); 394 | 395 | return env->NewStringUTF(res); 396 | } 397 | static const char *gClassName = "com/qtfreet/anticheckemulator/emulator/JniAnti"; 398 | static JNINativeMethod gMethods[] = { 399 | {"getApkSign", "()Ljava/lang/String;", (void *) getApkSign}, 400 | {"getKernelVersion", "()Ljava/lang/String;", (void *) getKernelVersion}, 401 | {"getCpuinfo", "()Ljava/lang/String;", (void *) getCpuinfo}, 402 | {"getDeviceID", "()Ljava/lang/String;", (void *) getDeviceID}, 403 | {"checkAntiFile", "()I", (void *) check}, 404 | }; 405 | 406 | static int registerNativeMethods(JNIEnv *env, const char *className, 407 | JNINativeMethod *gMethods, int numMethods) { 408 | jclass clazz; 409 | clazz = env->FindClass(className); 410 | if (clazz == NULL) { 411 | return JNI_FALSE; 412 | } 413 | if (env->RegisterNatives(clazz, gMethods, numMethods) < 0) { 414 | return JNI_FALSE; 415 | } 416 | return JNI_TRUE; 417 | } 418 | JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) { 419 | JNIEnv *env = NULL; 420 | jint result = -1; 421 | 422 | if (vm->GetEnv((void **) &env, JNI_VERSION_1_6) != JNI_OK) { 423 | return -1; 424 | } 425 | //目前已知问题,检测/sys/class/thermal/和bluetooth-jni.so不稳定,存在兼容性问题 426 | getDeviceInfo(); 427 | 428 | if (registerNativeMethods(env, gClassName, gMethods, 429 | sizeof(gMethods) / sizeof(gMethods[0])) == JNI_FALSE) { 430 | return -1; 431 | } 432 | 433 | return JNI_VERSION_1_6; 434 | } 435 | } 436 | -------------------------------------------------------------------------------- /app/src/main/java/com/qtfreet/anticheckemulator/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.qtfreet.anticheckemulator; 2 | 3 | import android.opengl.GLSurfaceView; 4 | import android.os.Bundle; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.text.TextUtils; 7 | import android.util.Log; 8 | import android.widget.TextView; 9 | 10 | import com.qtfreet.anticheckemulator.emulator.Check; 11 | import com.qtfreet.anticheckemulator.emulator.JniAnti; 12 | import com.qtfreet.anticheckemulator.utils.Util; 13 | 14 | public class MainActivity extends AppCompatActivity { 15 | 16 | 17 | @Override 18 | protected void onCreate(Bundle savedInstanceState) { 19 | super.onCreate(savedInstanceState); 20 | setContentView(R.layout.activity_main); 21 | 22 | TextView tv = (TextView) findViewById(R.id.sample_text); 23 | GLSurfaceView gl = (GLSurfaceView) findViewById(R.id.hwGPU); 24 | gl.setRenderMode(0); //此处是为了加载显卡信息 25 | Log.e("qtfreet000", "APK签名:" + JniAnti.getApkSign()); 26 | Log.e("qtfreet000", "程序包名:" + Check.getPackageName(this)); 27 | Log.e("qtfreet000", "CPU信息:" + JniAnti.getCpuinfo()); 28 | Log.e("qtfreet000", "CPU频率:" + Check.getCpuFrequency()); 29 | Log.e("qtfreet000", "CPU核心数量:" + Check.getCpuCore()); 30 | Log.e("qtfreet000", "内核信息:" + JniAnti.getKernelVersion()); 31 | Log.e("qtfreet000", "设备ID:" + JniAnti.getDeviceID()); 32 | Log.e("qtfreet000", "已安装App:" + Check.getInstalledApps(this)); 33 | Log.e("qtfreet000", "MAC地址:" + Check.getMacAddress(this)); 34 | Log.e("qtfreet000", "内存大小:" + Check.getMemorySize()); 35 | // Log.e("qtfreet000", "存在重力感应器:" + Check.checkGravity(this)); //这点不靠谱,很多手机还是检测不出来 36 | Log.e("qtfreet000", "设备厂商:" + Check.getModelBrand()); 37 | Log.e("qtfreet000", "设备型号:" + Check.getModelName()); 38 | Log.e("qtfreet000", "支持GPS:" + Check.hasGPSDevice(this)); 39 | Log.e("qtfreet000", "支持多点触控:" + Check.checkMultiTouch(this)); 40 | Log.e("qtfreet000", "电池温度:" + Check.getBatteryTemp(this)); 41 | Log.e("qtfreet000", "电池电压:" + Check.getBatteryVolt(this)); 42 | Log.e("qtfreet000", "模拟器特征数量:" + JniAnti.checkAntiFile()); 43 | 44 | 45 | String cpu = JniAnti.getCpuinfo(); 46 | String cpuFreq = Util.convertSize(Check.getCpuMaxFrequency()); 47 | String kernel = JniAnti.getKernelVersion(); 48 | boolean gravity = Check.checkGravity(this); 49 | String temp = Check.getBatteryTemp(this); 50 | String volt = Check.getBatteryVolt(this); 51 | int check = JniAnti.checkAntiFile(); 52 | boolean gps = Check.hasGPSDevice(this); 53 | StringBuilder sb = new StringBuilder(); 54 | if (cpu.contains("Genuine Intel(R)") || cpu.contains("Intel(R) Core(TM)") || cpu.contains("Intel(R) Pentium(R)") || cpu.contains("Intel(R) Xeon(R)") || cpu.contains("AMD")) { 55 | sb.append("特征一:" + cpu + "\n"); 56 | } 57 | if (kernel.contains("qemu+") || kernel.contains("tencent") || kernel.contains("virtualbox")) { 58 | sb.append("特征二:" + kernel + "\n"); 59 | } 60 | if (gravity == false) { 61 | sb.append("特征三:" + "无重力感应器\n"); 62 | } 63 | if (TextUtils.isEmpty(temp)) { 64 | sb.append("特征四:" + "无电池温度\n"); 65 | } 66 | if (TextUtils.isEmpty(volt)) { 67 | sb.append("特征五:" + "无电池电压\n"); 68 | } 69 | if (check > 0) { 70 | sb.append("特征六:" + "模拟器特征文件\n"); 71 | } 72 | if (gps == false) { 73 | sb.append("特征七:" + "无gps\n"); 74 | } 75 | if (cpuFreq.equals("0M")) { 76 | sb.append("特征八:" + "cpu无频率\n"); 77 | } 78 | tv.setText(sb.toString()); 79 | 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /app/src/main/java/com/qtfreet/anticheckemulator/emulator/Check.java: -------------------------------------------------------------------------------- 1 | package com.qtfreet.anticheckemulator.emulator; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.content.IntentFilter; 6 | import android.content.pm.PackageInfo; 7 | import android.hardware.Sensor; 8 | import android.hardware.SensorManager; 9 | import android.location.LocationManager; 10 | import android.net.wifi.WifiInfo; 11 | import android.net.wifi.WifiManager; 12 | import android.os.Build; 13 | import android.telephony.TelephonyManager; 14 | 15 | import com.qtfreet.anticheckemulator.utils.Util; 16 | 17 | import java.io.BufferedReader; 18 | import java.io.File; 19 | import java.io.FileFilter; 20 | import java.io.FileNotFoundException; 21 | import java.io.FileReader; 22 | import java.io.IOException; 23 | import java.util.ArrayList; 24 | import java.util.Collections; 25 | import java.util.HashMap; 26 | import java.util.List; 27 | import java.util.regex.Pattern; 28 | 29 | import static android.content.Context.SENSOR_SERVICE; 30 | import static android.hardware.Sensor.TYPE_GRAVITY; 31 | import static com.qtfreet.anticheckemulator.utils.Util.tempToStr; 32 | 33 | /** 34 | * Created by qtfreet on 2016/12/22. 35 | */ 36 | 37 | public class Check { 38 | private final static String CPUFREQ_CPUINFO_MAX_FREQ = "/cpufreq/cpuinfo_max_freq"; 39 | private final static String CPUFREQ_CPUINFO_MIN_FREQ = "/cpufreq/cpuinfo_min_freq"; 40 | private final static String CPUFREQ_SCALING_CUR_FREQ = "/cpufreq/scaling_cur_freq"; 41 | 42 | 43 | public static boolean checkGravity(Context context) { 44 | boolean z = false; 45 | List defaultSensor = ((SensorManager) context.getSystemService(SENSOR_SERVICE)).getSensorList(Sensor.TYPE_ALL); 46 | for (Sensor sensor : defaultSensor) { 47 | if (sensor.getType() == TYPE_GRAVITY) { //不能使用getName去判断是否存在重力感应器,应交与系统判断 48 | z = true; 49 | break; 50 | } 51 | } 52 | return z; 53 | } 54 | 55 | 56 | public static List getAllSensors(Context context) { 57 | List list = new ArrayList<>(); 58 | List defaultSensor = ((SensorManager) context.getSystemService(SENSOR_SERVICE)).getSensorList(Sensor.TYPE_ALL); 59 | for (Sensor sensor : defaultSensor) { 60 | list.add(sensor.getName()); 61 | } 62 | return list; 63 | } 64 | 65 | 66 | public static int getVersionCode(Context context) { 67 | try { 68 | PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); 69 | if (packageInfo != null) { 70 | return packageInfo.versionCode; 71 | } 72 | return 0; 73 | } catch (Throwable th) { 74 | return 0; 75 | } 76 | } 77 | 78 | public static String getVersionName(Context context) { 79 | try { 80 | PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); 81 | if (packageInfo != null) { 82 | return packageInfo.versionName; 83 | } 84 | return null; 85 | } catch (Throwable th) { 86 | return null; 87 | } 88 | } 89 | 90 | 91 | public static String getInstalledApps(Context context) { 92 | List installedPackages = context.getPackageManager().getInstalledPackages(0); 93 | HashMap map = new HashMap<>(); 94 | for (PackageInfo p : installedPackages) { 95 | String packageName = p.packageName; 96 | String versionName = p.versionName; 97 | map.put(packageName, versionName); 98 | } 99 | return Util.hashMapToStringNoSort(map); 100 | 101 | } 102 | 103 | public static String getPackageName(Context context) { 104 | return context.getPackageName(); 105 | } 106 | 107 | 108 | public static boolean checkMultiTouch(Context context) { 109 | boolean z = false; 110 | try { 111 | z = context.getPackageManager().hasSystemFeature("android.hardware.touchscreen.multitouch"); 112 | } catch (Exception e) { 113 | e.printStackTrace(); 114 | } 115 | return z; 116 | 117 | } 118 | 119 | public static String getModelName() { 120 | return Build.MODEL; //Mumu为网易模拟器 121 | } 122 | 123 | public static String getModelBrand() { 124 | return Build.BRAND; 125 | } 126 | 127 | 128 | public static String getMacAddress(Context context) { 129 | String str = ""; 130 | try { 131 | WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); 132 | if (wifiManager != null) { 133 | WifiInfo connectionInfo = wifiManager.getConnectionInfo(); 134 | return connectionInfo == null ? "" : connectionInfo.getMacAddress(); 135 | } 136 | } catch (Throwable th) { 137 | } 138 | return str; 139 | 140 | } 141 | 142 | public static String getDeviceID(Context context) { 143 | String str = null; 144 | TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); 145 | if (telephonyManager == null) { 146 | return str; 147 | } 148 | str = telephonyManager.getDeviceId(); 149 | return str; 150 | } 151 | 152 | public static String getMemorySize() { 153 | String dir = "/proc/meminfo"; 154 | 155 | FileReader fr = null; 156 | int size = 0; 157 | try { 158 | fr = new FileReader(dir); 159 | BufferedReader br = new BufferedReader(fr, 2048); 160 | String memoryLine = br.readLine(); 161 | String subMemoryLine = memoryLine.substring(memoryLine.indexOf("MemTotal:")); 162 | br.close(); 163 | long j = Long.parseLong(subMemoryLine.substring(subMemoryLine.indexOf(58) + 1, subMemoryLine.indexOf("kB")).trim()); 164 | size = (int) (j / 1024); 165 | } catch (FileNotFoundException e) { 166 | // e.printStackTrace(); 167 | } catch (IOException e) { 168 | // e.printStackTrace(); 169 | } 170 | 171 | if (size < 768) { 172 | return size + "M"; 173 | } 174 | if (size < 1024) { 175 | return "1G"; 176 | } 177 | return String.format("%.1fG", new Object[]{Float.valueOf(((float) size) / 1024.0f)}); 178 | } 179 | 180 | public static int getCpuCore() { 181 | try { 182 | return new File("/sys/devices/system/cpu/").listFiles(new FileFilter() { 183 | @Override 184 | public boolean accept(File pathname) { 185 | return Pattern.matches("cpu[0-9]", pathname.getName()); 186 | } 187 | }).length; 188 | 189 | } catch (Exception e) { 190 | return 0; 191 | } 192 | } 193 | 194 | 195 | public static boolean hasGPSDevice(Context context) { 196 | final LocationManager mgr = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); 197 | if (mgr == null) 198 | return false; 199 | final List providers = mgr.getAllProviders(); 200 | if (providers == null) 201 | return false; 202 | return providers.contains(LocationManager.GPS_PROVIDER); 203 | } 204 | 205 | public static String getCpuFrequency() { 206 | String frequency = Util.convertSize(getCpuMaxFrequency()); 207 | String model = Build.MODEL; 208 | if (Build.BRAND.equalsIgnoreCase("samsung") && (model.equalsIgnoreCase("sch-i959") || model.equalsIgnoreCase("gt-i9500"))) { 209 | frequency = frequency + " " + "四核+四核"; 210 | return frequency; 211 | } 212 | switch (getCpuCore()) { 213 | case 1: 214 | frequency = frequency + " " + "单核"; 215 | break; 216 | case 2: 217 | frequency = frequency + " " + "双核"; 218 | break; 219 | case 4: 220 | frequency = frequency + " " + "四核"; 221 | break; 222 | case 6: 223 | frequency = frequency + " " + "六核"; 224 | break; 225 | case 8: 226 | frequency = frequency + " " + "八核"; 227 | break; 228 | 229 | } 230 | return frequency.trim(); 231 | } 232 | 233 | public static int getCpuMaxFrequency() { 234 | File file = new File("/sys/devices/system/cpu"); 235 | if (!file.exists()) { 236 | return 0; 237 | } 238 | File[] listFiles = file.listFiles(new FileFilter() { 239 | @Override 240 | public boolean accept(File pathname) { 241 | return Pattern.matches("cpu[0-9]", pathname.getName()); 242 | } 243 | }); 244 | if (listFiles == null || listFiles.length <= 0) { 245 | return 0; 246 | } 247 | List arrayList = new ArrayList(); 248 | for (File absolutePath : listFiles) { 249 | String path = absolutePath.getAbsolutePath(); 250 | try { 251 | int max = Math.max(Math.max(Integer.parseInt(Util.readFile(path + CPUFREQ_CPUINFO_MAX_FREQ)), Integer.parseInt(Util.readFile(path + CPUFREQ_SCALING_CUR_FREQ))), Integer.parseInt(Util.readFile(path + CPUFREQ_CPUINFO_MIN_FREQ))); 252 | if (max > 0) { 253 | arrayList.add(Integer.valueOf(max)); 254 | } 255 | } catch (Throwable th) { 256 | } 257 | } 258 | if (arrayList.isEmpty()) { 259 | return 0; 260 | } 261 | Collections.sort(arrayList); 262 | return ((Integer) arrayList.get(arrayList.size() - 1)).intValue(); 263 | } 264 | 265 | // 266 | // public static String getCameraPixels(Context context, int size) { 267 | // if (size == -1) { 268 | // return null; 269 | // } 270 | // Camera camera = Camera.open(size); 271 | // Camera.Parameters parameters = camera.getParameters(); 272 | // List localList = parameters.getSupportedPictureSizes(); 273 | // if (localList != null) { 274 | // int[] heights = new int[localList.size()]; 275 | // int[] widths = new int[localList.size()]; 276 | // for (int i = 0; i < localList.size(); i++) { 277 | // Camera.Size s = localList.get(i); 278 | // int sizehieght = s.height; 279 | // int sizewidth = s.width; 280 | // heights[i] = sizehieght; 281 | // widths[i] = sizewidth; 282 | // } 283 | // int pixels = getMaxNumber(heights) * getMaxNumber(widths); 284 | // camera.release(); 285 | // return String.valueOf(pixels / 10000) + " 万"; 286 | // } 287 | // return null; 288 | // 289 | // } 290 | // 291 | // private static int getMaxNumber(int[] paramArray) { 292 | // int temp = paramArray[0]; 293 | // for (int i = 0; i < paramArray.length; i++) { 294 | // if (temp < paramArray[i]) { 295 | // temp = paramArray[i]; 296 | // } 297 | // } 298 | // return temp; 299 | // } 300 | // 301 | // public static int HasBackCamera() { 302 | // int numberOfCameras = Camera.getNumberOfCameras(); 303 | // Camera.CameraInfo cameraInfo = new Camera.CameraInfo(); 304 | // for (int i = 0; i < numberOfCameras; i++) { 305 | // Camera.getCameraInfo(i, cameraInfo); 306 | // if (cameraInfo.facing == 0) { 307 | // return i; 308 | // } 309 | // } 310 | // return -1; 311 | // } 312 | // 313 | // public static int HasFrontCamera() { 314 | // int numberOfCameras = Camera.getNumberOfCameras(); 315 | // Camera.CameraInfo cameraInfo = new Camera.CameraInfo(); 316 | // for (int i = 0; i < numberOfCameras; i++) { 317 | // Camera.getCameraInfo(i, cameraInfo); 318 | // if (cameraInfo.facing == 1) { 319 | // return i; 320 | // } 321 | // } 322 | // return -1; 323 | // } 324 | 325 | public static String getBatteryTemp(Context act) { 326 | if (act == null) { 327 | return null; 328 | } 329 | Intent batteryStatus = act.registerReceiver(null, new IntentFilter("android.intent.action.BATTERY_CHANGED")); 330 | if (batteryStatus == null) { 331 | return null; 332 | } 333 | int temp = batteryStatus.getIntExtra("temperature", -1); 334 | if (temp > 0) { 335 | return tempToStr(((float) temp) / 10.0f, 1); 336 | } 337 | return null; 338 | } 339 | 340 | public static String getBatteryVolt(Context act) { 341 | if (act == null) { 342 | return null; 343 | } 344 | Intent batteryStatus = act.registerReceiver(null, new IntentFilter("android.intent.action.BATTERY_CHANGED")); 345 | if (batteryStatus == null) { 346 | return null; 347 | } 348 | int volt = batteryStatus.getIntExtra("voltage", -1); 349 | if (volt > 0) { 350 | return String.valueOf(volt); 351 | } 352 | return null; 353 | } 354 | 355 | public static String toInfoString(Context context) { 356 | HashMap map = new HashMap<>(); 357 | map.put("cpuinfo", JniAnti.getCpuinfo()); 358 | map.put("kernelVersion", JniAnti.getKernelVersion()); 359 | map.put("deviceId", JniAnti.getDeviceID()); 360 | // map.put("ApkSign", JniAnti.getApkSign()); 361 | map.put("cpuCore", String.valueOf(getCpuCore())); 362 | map.put("cpuFreq", getCpuFrequency()); 363 | map.put("Gravity", String.valueOf(checkGravity(context))); 364 | map.put("BatteryVolt", getBatteryVolt(context)); 365 | map.put("BatteryTemp", getBatteryTemp(context)); 366 | map.put("gps", String.valueOf(hasGPSDevice(context))); 367 | //map.put("installedApps",getInstalledApps(context)); 368 | map.put("ModelBrand", getModelBrand()); 369 | map.put("ModelName", getModelName()); 370 | map.put("MacAddress", getMacAddress(context)); 371 | String s = Util.hashMapToStringSort(map); 372 | return s; 373 | } 374 | } 375 | -------------------------------------------------------------------------------- /app/src/main/java/com/qtfreet/anticheckemulator/emulator/GLSurfaceView.java: -------------------------------------------------------------------------------- 1 | package com.qtfreet.anticheckemulator.emulator; 2 | 3 | import android.content.Context; 4 | import android.util.AttributeSet; 5 | 6 | /** 7 | * Created by qtfreet on 2016/12/23. 8 | */ 9 | 10 | public class GLSurfaceView extends android.opengl.GLSurfaceView { 11 | 12 | public GLSurfaceView(Context context) { 13 | super(context); 14 | init(); 15 | } 16 | 17 | public GLSurfaceView(Context context, AttributeSet attributeSet) { 18 | super(context, attributeSet); 19 | init(); 20 | } 21 | 22 | private void init() { 23 | setEGLConfigChooser(8, 8, 8, 8, 16, 0); 24 | GpuRender gpuRender = new GpuRender(); 25 | setRenderer(gpuRender); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /app/src/main/java/com/qtfreet/anticheckemulator/emulator/GpuRender.java: -------------------------------------------------------------------------------- 1 | package com.qtfreet.anticheckemulator.emulator; 2 | 3 | import android.opengl.GLSurfaceView; 4 | import android.util.Log; 5 | 6 | import javax.microedition.khronos.egl.EGLConfig; 7 | import javax.microedition.khronos.opengles.GL10; 8 | 9 | /** 10 | * Created by qtfreet on 2016/12/23. 11 | */ 12 | 13 | public class GpuRender implements GLSurfaceView.Renderer { 14 | @Override 15 | public void onSurfaceCreated(GL10 gl, EGLConfig config) { 16 | gl.glClearColor(8.0f, 8.0f, 8.0f, 0.0f); 17 | String vendor = gl.glGetString(GL10.GL_VENDOR); 18 | String renderer = gl.glGetString(GL10.GL_RENDERER); 19 | Log.e("qtfreet000", "显卡信息:" + vendor + " " + renderer); 20 | } 21 | 22 | @Override 23 | public void onSurfaceChanged(GL10 gl, int width, int height) { 24 | 25 | } 26 | 27 | @Override 28 | public void onDrawFrame(GL10 gl) { 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/java/com/qtfreet/anticheckemulator/emulator/JniAnti.java: -------------------------------------------------------------------------------- 1 | package com.qtfreet.anticheckemulator.emulator; 2 | 3 | /** 4 | * Created by qtfreet on 2016/12/22. 5 | */ 6 | 7 | public class JniAnti { 8 | static { 9 | System.loadLibrary("native-lib"); 10 | } 11 | 12 | public static native String getCpuinfo(); 13 | 14 | public static native String getApkSign(); 15 | 16 | public static native String getKernelVersion(); 17 | 18 | public static native String getDeviceID(); //优测测试时提示没有权限读取read_phone_state,这里已经Mainifest注册 19 | 20 | public static native int checkAntiFile(); 21 | } 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/qtfreet/anticheckemulator/utils/Util.java: -------------------------------------------------------------------------------- 1 | package com.qtfreet.anticheckemulator.utils; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.File; 5 | import java.io.FileInputStream; 6 | import java.io.FileNotFoundException; 7 | import java.io.IOException; 8 | import java.io.InputStreamReader; 9 | import java.util.ArrayList; 10 | import java.util.Collections; 11 | import java.util.HashMap; 12 | import java.util.List; 13 | import java.util.Set; 14 | 15 | /** 16 | * Created by qtfreet on 2017/2/7. 17 | */ 18 | 19 | public class Util { 20 | public static String hashMapToStringNoSort(HashMap paramMap) { 21 | Set listKeys = paramMap.keySet(); 22 | int length = listKeys.size(); 23 | List list = new ArrayList(); 24 | for (String add : listKeys) { 25 | list.add(add); 26 | } 27 | String kvString = ""; 28 | for (int i = 0; i < length; i++) { 29 | String key = list.get(i); 30 | if (i == length - 1) { 31 | kvString = kvString + key + "=" + paramMap.get(key); 32 | } else { 33 | kvString = kvString + key + "=" + paramMap.get(key) + "&"; 34 | } 35 | } 36 | return kvString; 37 | } 38 | 39 | public static String hashMapToStringSort(HashMap paramMap) { 40 | Set listKeys = paramMap.keySet(); 41 | int length = listKeys.size(); 42 | List list = new ArrayList(); 43 | for (String add : listKeys) { 44 | list.add(add); 45 | } 46 | Collections.sort(list); //进行排序 47 | String kvString = ""; 48 | for (int i = 0; i < length; i++) { 49 | String key = list.get(i); 50 | if (i == length - 1) { 51 | kvString = kvString + key + "=" + paramMap.get(key); 52 | } else { 53 | kvString = kvString + key + "=" + (paramMap.get(key)) + "&"; 54 | } 55 | } 56 | return kvString; 57 | } 58 | 59 | public static String readFile(String str) { 60 | File file = new File(str); 61 | StringBuilder sb = new StringBuilder(); 62 | if (file.exists()) { 63 | try { 64 | String line = null; 65 | FileInputStream fileInputStream = new FileInputStream(file); 66 | BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(fileInputStream)); 67 | while ((line = bufferedReader.readLine()) != null) { 68 | sb.append(line); 69 | } 70 | bufferedReader.close(); 71 | fileInputStream.close(); 72 | return sb.toString(); 73 | } catch (FileNotFoundException e) { 74 | e.printStackTrace(); 75 | } catch (IOException e) { 76 | e.printStackTrace(); 77 | } 78 | } 79 | return ""; 80 | } 81 | 82 | public static String convertSize(int i) { 83 | int size = i / 1000; 84 | if (size > 360 && size < 440) { 85 | return "400M"; 86 | } 87 | if (size > 460 && size < 540) { 88 | return "500M"; 89 | } 90 | if (size > 560 && size < 640) { 91 | return "600M"; 92 | } 93 | if (size > 660 && size < 740) { 94 | return "700M"; 95 | } 96 | if (size > 760 && size < 840) { 97 | return "800M"; 98 | } 99 | if (size > 860 && size < 940) { 100 | return "900M"; 101 | } 102 | if (size > 960 && size < 1040) { 103 | return "1G"; 104 | } 105 | if (size < 1000) { 106 | return String.format("%dM", new Object[]{Integer.valueOf(size)}); 107 | } 108 | return String.format("%.1fG", new Object[]{Float.valueOf(((float) size) / 1000.0f)}); 109 | } 110 | 111 | public static String tempToStr(float temp, int tempSetting) { 112 | if (temp <= 0.0f) { 113 | return ""; 114 | } 115 | if (tempSetting == 2) { 116 | return String.format("%.1f°F", new Object[]{Float.valueOf(((9.0f * temp) + 160.0f) / 5.0f)}); 117 | } 118 | return String.format("%.1f°C", new Object[]{Float.valueOf(temp)}); 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 18 | 19 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ysrc/Anti-Emulator/05277af739839b18d4cd7773fc0c845c87d73f13/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ysrc/Anti-Emulator/05277af739839b18d4cd7773fc0c845c87d73f13/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ysrc/Anti-Emulator/05277af739839b18d4cd7773fc0c845c87d73f13/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ysrc/Anti-Emulator/05277af739839b18d4cd7773fc0c845c87d73f13/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ysrc/Anti-Emulator/05277af739839b18d4cd7773fc0c845c87d73f13/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | AntiCheckEmulator 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/com/qtfreet/anticheckemulator/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.qtfreet.anticheckemulator; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.3.0-beta3' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | } 19 | } 20 | 21 | task clean(type: Delete) { 22 | delete rootProject.buildDir 23 | } 24 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | ## Project-wide Gradle settings. 2 | # 3 | # For more details on how to configure your build environment visit 4 | # http://www.gradle.org/docs/current/userguide/build_environment.html 5 | # 6 | # Specifies the JVM arguments used for the daemon process. 7 | # The setting is particularly useful for tweaking memory settings. 8 | # Default value: -Xmx1024m -XX:MaxPermSize=256m 9 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 10 | # 11 | # When configured, Gradle will run in incubating parallel mode. 12 | # This option should only be used with decoupled projects. More details, visit 13 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 14 | # org.gradle.parallel=true 15 | #Mon Dec 12 16:39:56 CST 2016 16 | systemProp.http.proxyHost=127.0.0.1 17 | org.gradle.jvmargs=-Xmx1536m 18 | systemProp.http.proxyPort=1080 19 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ysrc/Anti-Emulator/05277af739839b18d4cd7773fc0c845c87d73f13/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Dec 27 10:06:56 CST 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | --------------------------------------------------------------------------------