-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathdlopen.js
More file actions
36 lines (32 loc) · 1.14 KB
/
dlopen.js
File metadata and controls
36 lines (32 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
* Frida Hook 脚本:监控目标动态库的加载
*
* 目标:
* - 监视 `dlopen` 和 `android_dlopen_ext` 函数的调用,以检测指定的动态库是否被加载。
* - 在库加载时打印日志,方便调试和分析。
*
* 说明:
* - `dlopen` 和 `android_dlopen_ext` 是 Android 用于加载动态库的常见 API。
* - `Interceptor.attach` 允许我们在函数进入 (`onEnter`) 和返回 (`onLeave`) 时执行自定义代码。
*/
// 目标动态库名称
const TARGET_LIB_NAME = "libmsaoaidsec.so";
function hook_dlopen() {
["android_dlopen_ext", "dlopen"].forEach(funcName => {
let addr = Module.findExportByName(null, funcName);
if (addr) {
Interceptor.attach(addr, {
onEnter(args) {
let libName = ptr(args[0]).readCString();
if (libName) {
console.log(`[+] ${funcName} onEnter: ${libName}`);
}
},
onLeave: function (retval) {
console.log(`[+] ${funcName} onLeave`);
}
});
}
});
}
hook_dlopen();