bytedance / bytedance/bhook

Android 12 hook 后 cfi_check 崩溃显著增加

Open
#98 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
C
Stars
2.6k
Forks
399
PR merge metrics
No merged PRs in 30d

Description

### bytehook Version

1.0.10

### Android OS Version

12

### Android ABIs

armeabi-v7a

### Device Manufacturers and Models

定制安卓设备

### Describe the Bug

![image](https://github.com/bytedance/bhook/assets/14327171/c5d1eed5-d227-44ca-91c0-c46270ebdb5c)
目前遇到的情况是,启用hook后,极易出现 cfi_check 崩溃,关闭后则几乎不会出现 cfi_check 崩溃。希望获得大佬的指定和帮助。

hook代码如下,对libc的socket接口进行了hook。其他一切配置都是按照例子里面的调用方法。
有一点疑惑的点:调用hook的时机不是在 Application.onCreate. 而是在App启动后的一段时间才hook的,和例子有些不同,不知道这样调用会有什么影响。
```
static bool allow_filter(const char *caller_path_name, void *arg) {
(void)arg;

if (NULL != strstr(caller_path_name, "libc.so")) return false;
if (NULL != strstr(caller_path_name, "libbase.so")) return false;
if (NULL != strstr(caller_path_name, "liblog.so")) return false;
if (NULL != strstr(caller_path_name, "libunwindstack.so")) return false;
if (NULL != strstr(caller_path_name, "libutils.so")) return false;
// ......

return true;
}

if (!sock_sendto_stub) {
sock_sendto_stub = bytehook_hook_partial(allow_filter, NULL, "libc.so", "sendto" , sock_sendto_proxy_auto, sock_sendto_hooked_callback, NULL);
}
if (!sock_recvfrom_stub) {
sock_recvfrom_stub = bytehook_hook_partial(allow_filter, NULL, "libc.so", "recvfrom" , sock_recvfrom_proxy_auto, sock_recvfrom_hooked_callback, NULL);
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.