luoyesiqiu / dpt-shell

An android Dex protects shell implementation
MIT License
519 stars 190 forks source link

适配android5 api22出现的问题 #9

Closed AdenTk closed 11 months ago

AdenTk commented 2 years ago

dpt-android5.zip

环境:
Nexus5
android5.1.1
api22

执行出错,日志上看着是CodeItem已经回填成功,但是出现了NullPointerException

dpt-android5.zip:
1、android5.patch 我适配android5 修改的代码,包括添加了LoadMethod_L函数
2、error.log错误日志。

希望大神有空帮忙看下
luoyesiqiu commented 2 years ago

应该是没填完,代码就执行了

AdenTk commented 2 years ago

我有试过在填充后,把begin指针对应的size大小的dex文件保存到私有目录,使用jadx打开dex,发现抽取后的方法是有被填充回去的。

luoyesiqiu commented 2 years ago

那把base.odex文件删掉试试

AdenTk commented 2 years ago

删除了/data/dalvik-cache/arm目录下的odex文件,确实可以正常运行,请问有什么措施可以不让他走odex呢?

luoyesiqiu commented 2 years ago

试试hook execv,看有没有hook到dex2oat的执行

AdenTk commented 2 years ago

使用以下代码进行hook execv未发现他走dex2oat的过程

static void* (*oriexecve_addr)(const char *__file, char *const *__argv, char *const *__envp);

static void* (*oriexecv_addr)(const char *__path, char *const *__argv);

void* execve_addr22(const char *__file, char *const *__argv, char *const *__envp) {
    DLOGD("process:%d,enter execve:%s", getpid(), __file);
    if (strstr(__file, "dex2oat")) {
        return NULL;
    } else {
        return oriexecve_addr(__file, __argv, __envp);
    }
}

void* execv_addr22(const char *__path, char *const *__argv) {
    DLOGD("process:%d,enter execv:%s", getpid(), __path);
    if (strstr(__path, "dex2oat")) {
        return NULL;
    } else {
        return oriexecv_addr(__path, __argv);
    }
}

void hook_exec(){
    void *execv_addr = DobbySymbolResolver(GetLibcPath(), "execv");

    DobbyHook(execv_addr, (void *) execv_addr22,
              (void **) &oriexecv_addr);

    void *execve_addr = DobbySymbolResolver(GetLibcPath(), "execve");

    DobbyHook(execve_addr, (void *) execve_addr22,
              (void **) &oriexecve_addr);
}
blueb0ne commented 1 year ago

这个问题后来有解决吗?

luoyesiqiu commented 11 months ago

当前方式自己解决