0

I'm trying to reverse an apk, overload some function and rebuild/sign it.

I should have done everything in the correct way; the only thing I edited is a function that check if the device is rooted. The function is isRooted and it calls other 3 functions:

  public static boolean isRooted()
  {
    return (checkRootMethod1()) || (checkRootMethod2()) || (checkRootMethod3());
  }

I tried to change the "smali-version" of this function in that way:

.method public static isRooted()Z
    .locals 1

    .prologue
    .line 15
    invoke-static {}, Lcom/name1/name2/CtrlDevice;->checkRootMethod1()Z

    move-result v0

    if-nez v0, :cond_0

    invoke-static {}, Lcom/name1/name2/CtrlDevice;->checkRootMethod2()Z

    move-result v0

    if-nez v0, :cond_0

    invoke-static {}, Lcom/name1/name2/CtrlDevice;->checkRootMethod3()Z

    move-result v0

    if-nez v0, :cond_0

    const/4 v0, 0x0

    :goto_0
    return v0

    :cond_0
    const/4 v0, 0x0

    goto :goto_0
.end method

The only difference from the original version is that the cond_0 was

:cond_0
const/4 v0, 0x1

After that I built an APK with apktool and I signed it with jarsigner and everything seems to be ok, but when I install the app on my device and I run it, after the splash it crashes.

I know that the question is really generic and I don't want a direct solution to this problem but I would like to know if is possible to implement something like a check that prevent to run the app after something has changed. Is possible something like that? How can I skip this check?

  • This doesn't even have to be a tamper check. Imagine a global variable that gets set to 1, 2 or 3 respectively by the first checkRootMethod that succeeds. Later, your program runs one of various runAsRootMethods depending on that variable, and since the variable never got initialized, the program crashes. – Guntram Blohm Aug 3 '16 at 20:57
  • 1
    An obvious suggestion - check logs for the cause of this crash. – Vitaly Osipov Aug 4 '16 at 6:56
1

Yes it is possible to have anti-tampering checks, and I have seen apps with them. That being said, you should eliminate the simplest causes first.

Did you check logcat? Most likely you accidentally screwed up the smali or otherwise messed up the apk. You should be able to see why the app crashed by checking logcat.

Another thing you should check is whether the app works if you simply resign it with no code changes.

Anyway, if it turns out that the app actually does have anti-tampering checks, you just have to reverse engineer it and disable the checks. There obviously isn't any one size fits all advice here, since anything you do is specific to the particular checks implemented.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.