frida - 如何使用 Frida 挂钩 os_log
问题描述
如标题所述,如何使用 Frida 挂钩 os_log?在下面尝试,不工作。
Interceptor.attach(Module.findExportByName("libSystem.B.dylib", "os_log"), {
onEnter: function (args) {
console.log(args[0] + args[1]);
}
});
解决方案
- 启用所有日志
var m = 'libsystem_trace.dylib';
// bool os_log_type_enabled(os_log_t oslog, os_log_type_t type);
var isEnabledFunc = Module.findExportByName(m, 'os_log_type_enabled');
// _os_log_impl(void *dso, os_log_t log, os_log_type_t type, const char *format, uint8_t *buf, unsigned int size);
var logFunc = Module.findExportByName(m, '_os_log_impl');
Interceptor.attach(isEnabledFunc, {
onLeave: function (ret) {
// console.log('log_enabled', ret);
ret.replace(0x1);
}
});
Interceptor.attach(logFunc, {
onEnter: function (a) {
var type = a[2]; // https://github.com/darlinghq/darling/blob/master/src/libc/os/log.h#L105
var format = a[3];
if (type != 0x2) {
console.log(JSON.stringify({
type: type,
format: format.readCString(),
//buf: a[4].readPointer().readCString()
}, null, 2));
}
}
})
推荐阅读
- python - 按日期重采样,如何在总和列上写入条件
- django-users - 如何在 Django 用户模型中添加选项
- git - 使用 jenkins 管道自动创建 git 仓库
- flutter - 可以在自定义字段中配置 textController
- python - 如何处理大规模网页抓取?
- powershell - Pester:在内容丰富的 -ForEach 数据驱动测试中使用变量
- text-parsing - 根据 >>>> 分隔符创建单独的文本文件,然后根据标题解析每个文件
- game-maker-studio-2 - 相机夹问题(GameMaker Studio 2)
- reactjs - 反应语音到文本和文本到语音
- apache-spark - spark中的row_number和orderby窗口函数窄变换等效