-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathdlopen-replace.js
More file actions
32 lines (27 loc) · 1008 Bytes
/
dlopen-replace.js
File metadata and controls
32 lines (27 loc) · 1008 Bytes
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
/**
* 替换模板库的加载
*/
const TARGET_LIB_NAME = "libmsaoaidsec.so";
const REPLACE_LIB_NAME = "libdummy.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 && libName.indexOf(TARGET_LIB_NAME) >= 0) {
console.log(`[+] ${funcName} onEnter: ${libName}`);
// 替换为加载 REPLACE_LIB_NAME
let newLib = Memory.allocUtf8String(REPLACE_LIB_NAME);
args[0] = newLib;
console.log(`[+] ${funcName}: 替换 ${libName} -> ${REPLACE_LIB_NAME}`);
}
},
onLeave: function (retval) {
}
});
}
});
}
hook_dlopen();