Ios7 越狱iOS 7中的短信拦截

Ios7 越狱iOS 7中的短信拦截,ios7,xcode5,jailbreak,cydia-substrate,Ios7,Xcode5,Jailbreak,Cydia Substrate,我遵循了这个答案。问题是它会阻止每条消息及其通知。其次,当我发送这个号码+923139303006以外的消息时,它会连续调用_processReceivedMessage_hooked方法 我将OpenDev与Xcode 5、iOS 7.x一起使用 #include <logos/logos.h> #import <substrate.h> #import <UIKit/UIKit.h> #import <Foundation/Foundation.h&

我遵循了这个答案。问题是它会阻止每条消息及其通知。其次,当我发送这个号码+923139303006以外的消息时,它会连续调用_processReceivedMessage_hooked方法

我将OpenDev与Xcode 5、iOS 7.x一起使用

#include <logos/logos.h>
#import <substrate.h>
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <libkern/OSAtomic.h>
#import "CoreTelephony.h"


id(*_processReceivedMessage_orig)(id, SEL, CTMessage*) = NULL;
id _processReceivedMessage_hooked(id self, SEL _cmd, CTMessage* msg);



@class IMDService; 
static void (*_logos_orig$_ungrouped$IMDService$loadServiceBundle)(IMDService*, SEL); static void _logos_method$_ungrouped$IMDService$loadServiceBundle(IMDService*, SEL); 



static void _logos_method$_ungrouped$IMDService$loadServiceBundle(IMDService* self, SEL _cmd) {

    _logos_orig$_ungrouped$IMDService$loadServiceBundle(self, _cmd);

    NSBundle *bundle =[NSBundle mainBundle];

     NSLog(@"bundle identifier %@ ***** ",[bundle bundleIdentifier]);

//    if ([[bundle bundleIdentifier] isEqualToString:@"com.apple.imservice.sms"] && [bundle isLoaded])
//    {  
        NSLog(@"Hoooking  ***** ");
        MSHookMessageEx(objc_getClass("SMSServiceSession"),
                        @selector(_processReceivedMessage:),
                        (IMP)_processReceivedMessage_hooked,
                        (IMP*)&_processReceivedMessage_orig);
//    }

}


id _processReceivedMessage_hooked(id self, SEL _cmd, CTMessage* msg)
{
    NSObject<CTMessageAddress>* phonenumber = [msg sender];
    NSString *senderNumber = (NSString*) [phonenumber canonicalFormat]; 

CTMessagePart *itmes = [[msg items] objectAtIndex:0];

NSString* msgtxt = [[NSString alloc] initWithData:itmes.data encoding:NSASCIIStringEncoding];


NSLog(@"message %@ ****",msgtxt);

    if ([senderNumber isEqualToString:@"+923139303006"])
        [[CTMessageCenter sharedMessageCenter] acknowledgeIncomingMessageWithId:[msg messageId]];
    else
         return _processReceivedMessage_orig(self, _cmd, msg);

}

static __attribute__((constructor)) void _logosLocalInit() {
{
    Class _logos_class$_ungrouped$IMDService = objc_getClass("IMDService");
    MSHookMessageEx(_logos_class$_ungrouped$IMDService, @selector(loadServiceBundle), (IMP)&_logos_method$_ungrouped$IMDService$loadServiceBundle, (IMP*)&_logos_orig$_ungrouped$IMDService$loadServiceBundle);
}
}
#包括
#进口
#进口
#进口
#进口
#导入“CoreTephony.h”
id(*\u processReceivedMessage\u orig)(id、SEL、CTMessage*)=NULL;
id _processReceivedMessage_hooked(id self,SEL _cmd,CTMessage*msg);
@类imd服务;
静态无效(*\u logos\u orig$\u ungroup$IMDService$loadServiceBundle)(IMDService*,SEL);静态无效标识方法$\未分组$IMDService$loadServiceBundle(IMDService*,SEL);
静态无效\u logos\u方法$\u未分组$IMDService$loadServiceBundle(IMDService*self,SEL\u cmd){
_logo_orig$_ungroup$IMDService$loadServiceBundle(self,_cmd);
NSBundle*bundle=[NSBundle mainBundle];
NSLog(@“bundle identifier%@*****,[bundle bundleIdentifier]);
//如果([[bundle bundleIdentifier]IseQualtString:@“com.apple.imservice.sms”]&&[bundle isLoaded])
//    {  
NSLog(@“Hoooking*****”);
MSHookMessageEx(objc_getClass(“SMSServiceSession”),
@选择器(_processReceivedMessage:),
(IMP)\u进程已接收钩住的消息,
(IMP*)和_processReceivedMessage_orig);
//    }
}
id _processReceivedMessage_hooked(id self,SEL _cmd,CTMessage*msg)
{
NSObject*phonenumber=[msg sender];
NSString*senderNumber=(NSString*)[phonenumber规范格式];
CTMessagePart*itmes=[[msg items]objectAtIndex:0];
NSString*msgtxt=[[NSString alloc]initWithData:itmes.data encoding:NSASCIIStringEncoding];
NSLog(@“message%@****”,msgtxt);
如果([senderNumber isEqualToString:@“+923139303006”])
[[CTMessageCenter sharedMessageCenter]acknowledgeIncomingMessageWithId:[msg messageId]];
其他的
返回_processReceivedMessage_orig(self,_cmd,msg);
}
静态uuu属性uuu((构造函数))void u logosLocalInit(){
{
类(logos)类(Class$)未分组的$IMDService=objc(IMDService)getClass(以下简称“IMDService”);
MSHookMessageEx(_logos_class$_ungroup$IMDService,@selector(loadServiceBundle),(IMP)和_logos_method$_ungroup$IMDService$loadServiceBundle,(IMP*)和_logos_orig$_ungroup$IMDService$loadServiceBundle);
}
}
这是plist文件

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Filter</key>
    <dict>
        <key>Bundles</key>
        <array>
            <string>com.apple.imagent</string>
        </array>
    </dict>
</dict>
</plist>

滤器
捆
com.apple.imagent
如果([[bundle bundleIdentifier]isEqualToString:@“com.apple.imservice.sms”]&&[bundle isLoaded])检查,请尝试取消注释

原因是,
loadServiceBundle
被多次调用-有几个imagent插件。每次调用hook
\u processReceivedMessage:
时,都会反复重写以前的hook。因为这一切都发生在单个imagent进程内,所以原始的
\u processReceivedMessage:
实现将丢失。因此,递归调用钩子函数


您还使用了错误的NSBundle实例
[NSBundle mainBundle]
返回您自己的捆绑包,即
com.apple.imagent
daemon。您需要加载插件的NSBundle。我在我的-您需要使用
IMDService-(NSBundle*)捆绑包
中介绍了这一点。在您的情况下,如果([[bundle bundleIdentifier]IsequalString:@“com.apple.imservice.sms”]&&&[bundle isLoaded])
检查,则尝试取消注释
。原因是,
loadServiceBundle
被多次调用-有几个imagent插件。每次调用hook
processReceivedMessage
时,都会反复重写以前的hook。因为这一切都发生在单个imagent进程内,所以原始的
processReceivedMessage
实现将丢失。因此,您递归地调用钩住的函数。如果我注释掉这一行,processReceivedMessage永远不会钩住。它总是给这个日志“bundle identifier com.apple.imagent”,这是因为您使用了错误的NSBundle实例
[NSBundle mainBundle]
返回您自己的包,即com.apple.imagent守护进程。您需要加载插件的NSBundle。我在回答中提到了这一点-您需要使用
IMDService-(NSBundle*)bundle
。就您而言,这将是
[self bundle]
@creker非常感谢您。它起作用了perfectly@creker当收到的消息有特定文本时,如果我想注册位置管理器进行位置更新或类似的操作,该怎么办。