Saturday, May 28, 2016

[Q] Need help bypassing Root-Check with Native Code, Some Source Code Available

I have an Amazon app for doing contract deliveries for them, I need it to work on my rooted device. I'm pretty sure I've exhausted all other means of hiding root, as they are using native code (I think) to make one of their root checks.

They are implementing RootBeer to do their root-check. I have used APKTools to inspect the Amazon apk, coupled with reading through the source code for RootBeer I feel like I am just around the corner from getting this thing cracked.

UserAlertManager.smali has this line in it:
Code:

invoke-static {}, Lcom/scottyab/rootbeer/RootBeer;->checkForRootNative()Z
RootBeer.java has this:
Code:

/**
    * Native checks are often harder to cloak/trick so here we call through to our native root checker
    * @return true if we found su | false if not
    */
 public boolean checkForRootNative() {

        String binaryName = "su";
        String[] paths = new String[Const.suPaths.length];
        for (int i = 0; i < paths.length; i++) {
            paths[i] = Const.suPaths[i]+binaryName;
        }

        RootBeerNative rootBeerNative = new RootBeerNative();
        rootBeerNative.setLogDebugMessages(true);
        return rootBeerNative.checkForRoot(paths) > 0;
    }

And rootBeerNative is:

Code:

package com.scottyab.rootbeer;

/**
 * Created by mat on 19/06/15.
 */
public class RootBeerNative {

    /**
    * Loads the C/C++ libraries statically
    */
    static {
        System.loadLibrary("tool-checker");
    }

    public native int checkForRoot(Object[] pathArray);
    public native int setLogDebugMessages(boolean logDebugMessages);

}


And below is about where I am at:

Code:

package com.deleonemail.fixdet;

import android.util.Log;
import de.robv.android.xposed.XC_MethodReplacement;
import de.robv.android.xposed.XC_MethodHook;
import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;

public class stopdet implements IXposedHookLoadPackage {
    public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {

        if (!lpparam.packageName.equals("com.amazon.rabbit"))
        return;

        findAndHookMethod("com.amazon.rabbit.android.presentation.alert.useralert.UserAlertManager", lpparam.classLoader, "checkForRootNative", new XC_MethodHook() {
            @Override
            protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                Log.v("rootbeer","grabbed UAM");
                param.setResult(false);
            }
        });
        //XposedBridge.log("we are in RootBeer!");
        //param.setResult(false);
    }
}

Any help getting this thing working right would be amazing!


from xda-developers http://ift.tt/1TPrS6U
via IFTTT

No comments:

Post a Comment