首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用Frida挂接postNotificaiton

用Frida挂接postNotificaiton
EN

Stack Overflow用户
提问于 2020-08-28 17:29:29
回答 1查看 167关注 0票数 1

我正在尝试将postNotificationName函数与Frida挂钩。我称其为两个职能:

  • postNotificationName:(NSNotificationName)object:(id)userInfo:(NSDictionary)
  • postNotification:(NSNotification)对象

sO,当我使用frida跟踪函数时,我看到在后面的例子中有对postNotificationName的调用。我想知道postNotification是否打电话给postNotification,为什么会这样?

另外,

代码语言:javascript
复制
var newObject = ObjC.classes.NSNotification;
var myObj = newObject.alloc().initWithName_object_userInfo_('notificationName','nil','userInfo');
var hook = ObjC.classes.NSNotificationCenter["- postNotification:"];
Interceptor.attach(hook.implementation, {
    onEnter: function(args) {
        console.log("\n[*] Detected call to: " + NsNotificationCenter + " -> " + postNotification);
        console.log("\t[-] Argument Value: " + args[2]);
        args[2] = ptr(myObj)
        console.log("\t[-] New Argument Value: " + args[2])
    }

当注入使用Frida挂钩postNotification函数时工作。然而,

代码语言:javascript
复制
var nsName = ObjC.classes.NSString;
var notificationName= nsName.stringWithString_("Blah"); 
var hook = ObjC.classes.NSNotificationCenter["- postNotificationName:"];
Interceptor.attach(hook.implementation, {
    onEnter: function(args) {
        console.log("\n[*] Detected call to: " + NSNotificationCenter + " -> " + postNotificationName);
        console.log("\t[-] Argument Value: " + args[2]);
        args[2] = ptr(notifname)
        console.log("\t[-] New Argument Value for postNotificaitonName: " + args[2])
    }
});

不适用于postNotificationName:Object:userInfo。我猜问题在"var钩子= ObjC.classes.NSNotificationCenter"- postNotificationName:";“一行中。有人知道它有什么问题吗?如何使它工作?

谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-08-28 18:16:13

根据苹果文档,类NSNotificationCenter没有选择器"- postNotificationName:"

有两个具有该名称的选择器,但它们有其他参数:

  • "- postNotificationName:object:userInfo:"
  • "- postNotificationName:object:"

如果您想连接这些选择器中的任何一个,您必须使用完整的选择器字符串,如上面所述,用于挂钩:

代码语言:javascript
复制
var hook = ObjC.classes.NSNotificationCenter["- postNotificationName:object:userInfo:"];

代码语言:javascript
复制
var hook = ObjC.classes.NSNotificationCenter["- postNotificationName:object:"];
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63638460

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档