別の方法は、エージェントがあなたのデバイスがルート化されていることを発見する方法を分析することです...
コードは次のとおりです。
/**
*Returns true if the OS build tags contains "test-keys"
*/
public boolean checkRootMethod1(){
String buildTags = android.os.Build.TAGS;
if (buildTags != null && buildTags.contains("test-keys")) {
Log.e("ROOT CHECKER", "ROOT METHOD 1");
return true;
}
return false;
}
/**
*Returns true if the device contains SuperUser.apk which is stored into the device in the rooting process
*/
public boolean checkRootMethod2(){
try {
File file = new File("/system/app/Superuser.apk");
if (file.exists()) {
Log.e("ROOT CHECKER", "ROOT METHOD 2");
return true;
}
} catch (Exception e) { }
return false;
}
/**
*Executes a shell command (superuser access with su binary) and returns true if the command succeeds
*/
public boolean checkRootMethod3() {
if (new ExecShell().executeCommand(ExecShell.SHELL_CMD.check_su_binary) != null){
Log.e("ROOT CHECKER", "ROOT METHOD 3");
return true;
}else{
return false;
}
}
したがって、3 つのチェックがあります。
- Android buildTags にチェーン「テストキー」があります!
- デバイスに Superuser.apk があります。
- スーパーユーザーアクセスでシェルコマンドを実行できるため、デバイスは本当にルート化されています!!!