首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >破解iOS 7中的短信截取

破解iOS 7中的短信截取
EN

Stack Overflow用户
提问于 2014-07-02 07:46:40
回答 1查看 577关注 0票数 0

我遵循了这个答案,Blocking incomming sms in ios 7。问题在于它阻塞了每条消息及其通知。其次,当我发送消息时,它会连续调用_processReceivedMessage_hooked方法,然后是这个号码+923139303006。

我使用的是OpenDev和Xcode 5,iOS 7.x。

代码语言:javascript
运行
复制
#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);
}
}

这是plist文件

代码语言:javascript
运行
复制
<?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>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-07-02 09:34:06

尝试取消注释if ([[bundle bundleIdentifier] isEqualToString:@"com.apple.imservice.sms"] && [bundle isLoaded])检查。

原因是loadServiceBundle被多次调用--有几个imagent插件。每次被称为钩子_processReceivedMessage:时,都会一次又一次地重写以前的钩子。因为所有这些都发生在单个代理进程中,所以原始的_processReceivedMessage:实现将丢失。因此,您递归地调用您的钩子函数。

您还使用了错误的NSBundle实例。[NSBundle mainBundle]返回您自己的包,即com.apple.imagent守护进程。您需要加载插件的NSBundle。我在我的answer中提到了这一点--你需要使用IMDService -(NSBundle*)bundle。在您的例子中,它将是[self bundle]

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24525639

复制
相关文章

相似问题

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