Skip to content

Instantly share code, notes, and snippets.

@massimilianochiodi
Created April 15, 2022 08:41
Show Gist options
  • Save massimilianochiodi/642f2e3fa0c97ecfd5672839bffe2f0d to your computer and use it in GitHub Desktop.
Save massimilianochiodi/642f2e3fa0c97ecfd5672839bffe2f0d to your computer and use it in GitHub Desktop.
Simple verify if phone is rooted ( java )
public static boolean findBinary(String binaryName) {
boolean found = false;
String[] places = { "/sbin/", "/system/bin/", "/system/xbin/",
"/data/local/xbin/", "/data/local/bin/",
"/system/sd/xbin/", "/system/bin/failsafe/", "/data/local/" };
for (String where : places) {
if (new File(where + binaryName).exists()) {
found = true;
break;
}
}
return found;
}
private static boolean isRooted() {
return findBinary("su");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment