Last active
March 27, 2017 07:20
-
-
Save chuehnone/96eebdb9174a13cb7cd20b30548c07ec to your computer and use it in GitHub Desktop.
Android defend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 檢查Java程式碼是否可以被debug的方法 | |
public boolean isApplicationDebuggable(String paramString) { | |
return (0x2 & this.context.getPackageManager().getApplicationInfo(this.context.getPackageName(), 128).flags) == 2; | |
} | |
// 檢查App是否安裝在模擬器內的方法 | |
public boolean IsInstallEmulator() { | |
try { | |
if(!Build.FINGERPRINT.startsWith("generic") && !Build.FINGERPRINT.startsWith("unknown") && !Build.MODEL.contains("google_sdk") && !Build.MODEL.contains("Emulator") && !Build.MODEL.contains("Android SDK built for x86") && !Build.MANUFACTURER.contains("Genymotion")) { | |
if((Build.BRAND.startsWith("generic")) && (Build.DEVICE.startsWith("generic"))) { | |
return true; | |
} | |
if("google_sdk".equals(Build.PRODUCT)) { | |
return true; | |
} | |
return false; | |
} | |
return true; | |
} catch(Exception v0) { | |
return false; | |
} | |
return false; | |
} | |
// 檢查App是否安裝在Root手機的方法 | |
public boolean IsRootDevice() { | |
try { | |
String[] directory = new String[8]; | |
directory[0] = "/sbin/"; | |
directory[1] = "/system/bin/"; | |
directory[2] = "/system/xbin/"; | |
directory[3] = "/data/local/xbin/"; | |
directory[4] = "/data/local/bin/"; | |
directory[5] = "/system/sd/xbin/"; | |
directory[6] = "/system/bin/failsafe/"; | |
directory[7] = "/data/local/"; | |
for(int index=0; index<directory.length; index++) { | |
if(new File(String.valueOf(directory[index]) + "su").exists()) { | |
return true; | |
} | |
} | |
return false; | |
} catch(Exception v0) { | |
return false; | |
} | |
} | |
// 檢查App是否從Google Play商店安裝的方法 | |
public boolean IsInstallFromGooglePlay() { | |
return ( "com.android.vending".equals(this.context.getPackageManager().getInstallerPackageName(this.context.getPackageName())) ); | |
} | |
// 檢查App是否正有deubgger連接的方法,Android API | |
static boolean isDebuggerConnected() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment