Skip to content

Commit

Permalink
Merge pull request #57 from blackandwhiteforzj/feat-disable-dex2oat
Browse files Browse the repository at this point in the history
feat-disable-dex2oat:disable dex2oat
  • Loading branch information
luoyesiqiu authored Sep 1, 2024
2 parents 09f24ca + 0f99915 commit 940cef8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
23 changes: 23 additions & 0 deletions shell/src/main/cpp/dpt_hook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ int g_sdkLevel = 0;
void dpt_hook() {
bytehook_init(BYTEHOOK_MODE_AUTOMATIC,false);
g_sdkLevel = android_get_device_api_level();
hook_execve();
hook_mmap();
hook_DefineClass();
}
Expand Down Expand Up @@ -292,3 +293,25 @@ DPT_ENCRYPT void hook_mmap(){
DLOGD("mmap hook success!");
}
}
DPT_ENCRYPT int fake_execve(const char *pathname, char *const argv[], char *const envp[]) {
BYTEHOOK_STACK_SCOPE();
DLOGW("execve hooked: %s", pathname);
if (strstr(pathname, "dex2oat") != nullptr) {
DLOGW("execve blocked: %s", pathname);
errno = EACCES;
return -1;
}
return BYTEHOOK_CALL_PREV(fake_execve, pathname, argv, envp);
}
DPT_ENCRYPT void hook_execve(){
bytehook_stub_t stub = bytehook_hook_single(
getArtLibName(),
"libc.so",
"execve",
(void *) fake_execve,
nullptr,
nullptr);
if (stub != nullptr) {
DLOGD("execve hook success!");
}
}
1 change: 1 addition & 0 deletions shell/src/main/cpp/dpt_hook.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ static void* (*g_originDefineClassV21)(void* thiz,

void hook_DefineClass();
void hook_mmap();
void hook_execve();
#endif //DPT_DPT_HOOK_H

0 comments on commit 940cef8

Please sign in to comment.