IOS越狱如何拦截短信/短信 [英] IOS Jailbreak How do intercept SMS / Text Messages

查看:619
本文介绍了IOS越狱如何拦截短信/短信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试编写一个拦截文本消息的应用程序,并根据该消息的内容做出反应。
我试图挂钩到 _receivedMessage:(struct __CKSMSRecord *)消息替换:(BOOL)替换CKSMSService类中的方法,但这似乎根本没有被调用。

I'm currently trying to write an application that intercepts text messages and reacts depending on the content of that message. I tried to hook into _receivedMessage:(struct __CKSMSRecord *)message replace:(BOOL)replace method in the CKSMSService class but this seems not do get called at all.

有人可以告诉我我要挂钩的功能/类别吗?我需要在文本消息显示并存储到数据库之前拦截它。我正在使用IOS 5.0.1。

Could someone please tell me what function/class i have to hook in? I need to intercept the text message before it gets displayed and stored into the database. I'm on IOS 5.0.1.

真的很感激任何帮助。

Any help is truly appreciated.

推荐答案

此代码段应截取短信 - 您可以将其扩展为其他类型的通知。也适用于iOS 5.0.1。但是不适用于iMessages。链接CoreTelephony框架(那里有一堆私有标题你可以转类)

This code snippet should intercept SMS messages- You can extend it for other kinds of notifications. Will work on iOS 5.0.1 as well. Does not work with iMessages though. Link with CoreTelephony framework (there are bunch of private headers there which you'd can class-dump)

#include <dlfcn.h>

#define CORETELPATH "/System/Library/PrivateFrameworks/CoreTelephony.framework/CoreTelephony"
id(*CTTelephonyCenterGetDefault)();

void (*CTTelephonyCenterAddObserver) (id,id,CFNotificationCallback,NSString*,void*,int);


static void telephonyEventCallback(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo)
{
    NSString *notifyname=(NSString *)name;
    if ([notifyname isEqualToString:@"kCTMessageReceivedNotification"])//received SMS
    {
        NSLog(@" SMS Notification Received :kCTMessageReceivedNotification");
        // Do blocking here. 
    }
}

-(void) registerCallback {

 void *handle = dlopen(CORETELPATH, RTLD_LAZY);
    CTTelephonyCenterGetDefault = dlsym(handle, "CTTelephonyCenterGetDefault");
    CTTelephonyCenterAddObserver = dlsym(handle,"CTTelephonyCenterAddObserver");
    dlclose(handle);
    id ct = CTTelephonyCenterGetDefault();

    CTTelephonyCenterAddObserver(
                                 ct, 
                                 NULL, 
                                 telephonyEventCallback,
                                 NULL,
                                 NULL,
                                 CFNotificationSuspensionBehaviorDeliverImmediately);
}

这篇关于IOS越狱如何拦截短信/短信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆