From e22f37465ab602993613b4dc66be71c50379b42e Mon Sep 17 00:00:00 2001 From: hdsenevi Date: Fri, 4 Mar 2022 06:49:59 +1100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=20Adding=20additional=20android=20?= =?UTF-8?q?checks.=20User=20id=200=20can=20execute=20su,=20/data=20folder?= =?UTF-8?q?=20access=20and=20check=20for=20installs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../JailMonkey/Rooted/GreaterThan23.java | 71 ++++++++++++++++++- 1 file changed, 69 insertions(+), 2 deletions(-) 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; + } }