保护应用程序免于绕过根检测(Frida Server)

Protect the app from bypassing the root detection (Frida Server)

我看到 post 关于使用 frida 服务器绕过 android 应用程序的根检测。当我按照这些步骤操作时,根检测不起作用。任何人都有使用 Frida server/any other

保护根检测不被绕过的想法

Check for root in a shared library and launch 一个 activity 说法,the device is rooted 从共享库本身清除返回堆栈。 本机二进制文件很难进行逆向工程(它们需要函数名称才能在 Frida 上进行操作)。

您还可以阻止 frida attaching 访问您的应用。 从 frida docs 我们可以看到 frida 使用了 ptrace

Frida needs in a first step to inject an agent in the targeted >application so that it is in the memory space of the process.

On Android and Linux such injection is done with ptrace by attaching or spawning a process and then injecting the agent. Once the agent is injected, it communicates with its server through a pipe.

当使用ptrace系统调用附加到进程时,被调试进程的状态文件中的"TracerPid"字段显示附加进程的PID。 "TracerPid" 的默认值为 0(没有附加进程)。因此,在该字段中找到除 0 以外的任何内容都是调试或其他 ptrace 恶作剧的标志。 以下实现来自 Tim Strazzere 的 Anti-Emulator 项目:

#include <jni.h>
#include <unistd.h>
#include <sys/ptrace.h>
#include <sys/wait.h>
#include <pthread.h>

static int child_pid;

void *monitor_pid() {

    int status;

    waitpid(child_pid, &status, 0);

    /* Child status should never change. */

    _exit(0); // Commit seppuku

}

void anti_debug() {

    child_pid = fork();

    if (child_pid == 0)
    {
        int ppid = getppid();
        int status;

        if (ptrace(PTRACE_ATTACH, ppid, NULL, NULL) == 0)
        {
            waitpid(ppid, &status, 0);

            ptrace(PTRACE_CONT, ppid, NULL, NULL);

            while (waitpid(ppid, &status, 0)) {

                if (WIFSTOPPED(status)) {
                    ptrace(PTRACE_CONT, ppid, NULL, NULL);
                } else {
                    // Process has exited
                    _exit(0);
                }
            }
        }

    } else {
        pthread_t t;

        /* Start the monitoring thread */
        pthread_create(&t, NULL, monitor_pid, (void *)NULL);
    }
}

JNIEXPORT void JNICALL
Java_sg_vantagepoint_antidebug_MainActivity_antidebug(JNIEnv *env, jobject instance) {

    anti_debug();
}

请参考此 guide 以了解有利位置的反调试技巧。 本指南中有一个特定的 section 解决了 frida

还有https://github.com/b-mueller/frida-detection-demo

否则,您可以使用 Appdome (IPaaS) 的服务 block frida 附加到您的应用程序