Skip to content

Commit

Permalink
Update RootCloak against RootBeer checks
Browse files Browse the repository at this point in the history
- Remove tool-checker library hook as it cause crash.
- Add hook for RootBeerNative.checkForRoot() native method.
- Add hook for exec 'getprop' command.
- Update hook for SystemProperties.get("ro.build.selinux").
  • Loading branch information
prattpratt committed Nov 25, 2016
1 parent bb2faa9 commit 37d0355
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/src/main/java/com/devadvance/rootcloak2/DefaultLists.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class DefaultLists {
"root", "busybox", "titanium",
".tmpsu", "su", "rootcloak2"};

public static final String[] DEFAULT_COMMAND_LIST = new String[]{"su", "which", "busybox", "pm", "am", "sh", "ps"};
public static final String[] DEFAULT_COMMAND_LIST = new String[]{"su", "which", "busybox", "pm", "am", "sh", "ps", "getprop"};

public static final String[] DEFAULT_LIBNAME_LIST = new String[]{"tool-checker"}; // RootBearNative
public static final String[] DEFAULT_LIBNAME_LIST = new String[]{}; // off
}
23 changes: 19 additions & 4 deletions app/src/main/java/com/devadvance/rootcloak2/RootCloak.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;
import de.robv.android.xposed.callbacks.XCallback;


import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;
import static de.robv.android.xposed.XposedHelpers.findConstructorExact;

Expand Down Expand Up @@ -101,12 +100,12 @@ private void initOther(final LoadPackageParam lpparam) {
}
}

// Tell the app that SELinux is enforcing, even if it is not.
// Tell the app that SELinux is disabled
findAndHookMethod("android.os.SystemProperties", lpparam.classLoader, "get", String.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(XC_MethodHook.MethodHookParam param) throws Throwable {
if (((String) param.args[0]).equals("ro.build.selinux")) {
param.setResult("1");
param.setResult("");
if (debugPref) {
XposedBridge.log("SELinux is enforced.");
}
Expand All @@ -128,6 +127,20 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
}
}
});

// RootBear checkForRoot hook
try {
findAndHookMethod("com.scottyab.rootbeer.RootBeerNative", lpparam.classLoader, "checkForRoot",
Object[].class,
new XC_MethodHook() {
@Override
public void beforeHookedMethod(MethodHookParam param) throws Throwable {
param.setResult(0);
}
});
} catch (XposedHelpers.ClassNotFoundError e) {
e.printStackTrace();
}
}

/**
Expand Down Expand Up @@ -248,7 +261,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable { // Ho
}

List<ApplicationInfo> packages = (List<ApplicationInfo>) param.getResult(); // Get the results from the method call
Iterator<ApplicationInfo> iter = packages.iterator();
Iterator<ApplicationInfo> iter = packages.iterator();
ApplicationInfo tempAppInfo;
String tempPackageName;

Expand Down Expand Up @@ -519,6 +532,8 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
param.setThrowable(new IOException());
} else if (commandSet.contains("sh") && (firstParam.equals("sh") || firstParam.endsWith("/sh"))) {
param.setThrowable(new IOException());
} else if (commandSet.contains("getprop") && firstParam.equals("getprop")) {
param.setResult(Runtime.getRuntime().exec("echo"));
} else {
param.setThrowable(new IOException());
}
Expand Down

0 comments on commit 37d0355

Please sign in to comment.