diff --git a/android/src/main/java/com/gantix/JailMonkey/Rooted/GreaterThan23.java b/android/src/main/java/com/gantix/JailMonkey/Rooted/GreaterThan23.java index 1d1408a..e630ad6 100644 --- a/android/src/main/java/com/gantix/JailMonkey/Rooted/GreaterThan23.java +++ b/android/src/main/java/com/gantix/JailMonkey/Rooted/GreaterThan23.java @@ -8,7 +8,7 @@ public class GreaterThan23 implements CheckApiVersion { @Override public boolean checkRooted() { - return checkRootMethod1() || checkRootMethod2(); + return checkRootMethod1() || checkRootMethod2() || checkUserIdAndExecuteSu() || checkFolderAccess() || checkInstalls(); } private boolean checkRootMethod1() { @@ -31,7 +31,16 @@ private boolean checkRootMethod1() { private boolean checkRootMethod2() { Process process = null; try { - process = Runtime.getRuntime().exec(new String[] { "/system/xbin/which", "su" }); + final String whichPathOld = "system/xbin/which"; + final String whichPathNew = "system/bin/which"; + + if (new File(whichPathOld).exists()) { + process = Runtime.getRuntime().exec(new String[]{whichPathOld, "su"}); + } else if (new File(whichPathNew).exists()) { + process = Runtime.getRuntime().exec(new String[]{whichPathNew, "su"}); + } else { + process = Runtime.getRuntime().exec(new String[]{"which", "su"}); + } BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream())); if (in.readLine() != null) return true; return false; @@ -41,4 +50,62 @@ private boolean checkRootMethod2() { if (process != null) process.destroy(); } } + + private boolean checkUserIdAndExecuteSu() { + Process process = null; + + try { + process = Runtime.getRuntime().exec("id"); + BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream())); + if (in.readLine().contains("uid=0")) return true; + + // Android Will throw exception if permission denied when user try to invoke Su + process = Runtime.getRuntime().exec("su"); + return true; + } catch (Throwable t) { + return false; + } finally { + if (process != null) process.destroy(); + } + } + + private boolean checkFolderAccess() { + String[] paths = {"/data"}; + for (String path : paths) { + if (new File(path).canRead()) return true; + } + return false; + } + + private boolean checkInstalls() { + Process process = null; + String[] installs = { + "magisk", + "com.noshufou.androd.au", + "com.thirdparty.superuser", + "eu.chainfire.supersu", + "com.koushikdutta.superuser", + "com.zachspong.temprootromovejb", + "com.ramdroid.appquarantine", + "com.devadvance.rootcloak", + "com.devadvance.rootcloakplus", + }; + + try { + process = Runtime.getRuntime().exec("pm list packages"); + BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream())); + String line = in.readLine(); + while (line != null) { + for (String keyWord : installs) { + if (line.contains(keyWord)) { + return true; + } + } + line = in.readLine(); + } + } catch (Throwable e) { + return false; + } + return false; + } }