wohuole
(wohuole)
2014 年5 月 28 日 01:29
1
boss让我开发一个可以拦截短信的应用,搜索了很多资料,终于看到stackoverflow上有篇文章靠谱:http://stackoverflow.com/questions/16219799/block-sms-on-ios6 的第二种方法,
http://stackoverflow.com/questio … omming-sms-in-ios-7
无奈调试好久,都没有反映。求指导:
我的代码如下:
生成 .deb 文件后,通过 iFile 安装到iphone4s ios7.0.4中,
在mobileTerminal 中,launchuctl stop com.apple.imagent , 重启 com.apple.imagent.
发送短信测试。。。 没有任何反映。
求教:
1.%hook 与 %end 之间,如果想要打印日志,用NSLog();还是其他的方法?
2.为啥,我也重启了,代码问题应该也不大,为啥没反应,不能hook到这个方法呢?
谢谢!
已解决,先感谢snakeninny的耐心解答。
按照snakeninny所讲,我仔细检查了我的两个问题:
1.filter
2.reboot imagent
最后才发现我的问题所在,Filter 没有设置好!
之前一直在xcode下正儿八经的开发app,在修改plist文件的时候,直接打开 Support Files 修改下面d的plist 文件,形成了习惯。所以这次就是因为这个事情犯了低级错误。
真正应该修改的plist文件,应该是:工程下--》Package--》Library--》MobileSubstrate--》DynamicLibraries--》xx.plist。
打开可以看到,里面已经有个Filter了。。。。
真想骂自己!
一个人摸索开发的日子真不好过。像这样的东西,没有那一个教程里教你。。。。先哭一会儿。
再次感谢snakeninny!!!!后续,我做好其他拦截短信的方法后,我也会传上来,希望可以帮助到大家。
另外你loadServiceBundle中的%orig不能注释掉
wohuole
(wohuole)
2014 年5 月 29 日 01:16
4
我的plist文件如下:
<?xml version="1.0" encoding="UTF-8"?>
**BugFix**
**Major**
1
**Minor**
0
**PackageRevision**
1
**Stage**
**Filter**
**Bundles**
imagent //不确定这个这么做对不对
com.apple.imagent
{
Filter = {
Bundles = (
"com.apple.imagent",
);
};
}
把%orig放到最上面去,改成
- (void)loadServiceBundle
{
%orig;
if (xxx) MSHookMessageEx(xxx);
}
另外你要确定loadServiceBundle这个函数得到调用,用NSLog打印个东西看看有没有显示。再一个就是确认bundleIdentifier确实是com.apple.imservice.sms,因为SMSNinja的思路跟你的代码是一致的,但hook的函数有差别,不过单看你hook的函数名,应该也是可以的
wohuole
(wohuole)
2014 年5 月 29 日 01:53
9
在第二个帖子 for ios7 中,creker这么回答:
1.My solution works on iOS 7
2.Your bundle id is wrong, it should be com.apple.imservice.sms. --{ I’ve posted SMS service directory path (/System/Library/Messages/PlugIns/SMS.imservice/). }(这一句不明白,是需要copy什么东西么?求指导)--In there you can find Info.plist which contains bundle id of the plugin - com.apple.imservice.sms.
作者后面的回答:
:I found my problem. For hooking (void)loadServiceBundle, --{after copying the files }--(搞的我很困惑,是需要copy什么文件呢?求指点), you have to reboot the phone. I myself only respringed the iPhone so loadServiceBundle wasn’t ever called. After rebooting the iPhone, the tweak works perfectly! – user3519705
reboot是为了重启imagent,跟他提到的
launchctl unload /System/Library/LaunchDaemons/com.apple.imagent.plist
launchctl load /System/Library/LaunchDaemons/com.apple.imagent.plist
达到相同目的
wohuole
(wohuole)
2014 年5 月 29 日 03:46
11
非常感谢您的耐心回答。
我做了一下测试,分别去hook springboard 和 IMService
代码如下:
%hook SpringBoard
-(void)applicationDidFinishLaunching:(id)application {
%orig;
NSLog(@"test -- SpringBoard");// can find this one in syslog.
}
%end
%hook IMDService
-(void)loadServiceBundle{
%orig;
NSLog(@"test hook loadServiceBundle ok");//do not find in syslog
}
发现,springboard可以hook,而IMDService从来都没有hook到。应该是说明了,这个hook这个函数可能有问题,于是我将IMDService.h 下的所有的函数都试了一下,发现还是都不行。我的代码:
我所使用的:#import “IMDService.h” 是从IMDaemonCore.framework 中,用class-dump 导出来d的。
求指导,非常谢谢您。。
wohuole
(wohuole)
2014 年5 月 29 日 04:06
12
IMDService是imagent这个进程里的类,要hook这个进程,有2点需要注意,1是在filter里加上com.apple.imagent,2是tweak安装完成后要重启imagent(可通过reboot达到目的)。如果这2点没做到,那就是你的tweak有问题,先把自己的错误解决;如果这2点都做到了,loadServiceBundle的函数还是没有得到调用,那很可能是因为这个函数不是在imagent启动时得到调用的,你就要换个思路。按你的描述,如果IMDService.h下所有函数都没输出,那很有可能是那2点条件你没满足
IDA可以看到所有的ObjC方法和C函数,但没有class-dump那么直观。书里完整地阐述了从事iOS越狱开发所需要的基础知识和工具,对必须的理论全都做了详细描述,然后用例子强化记忆,知识体系的完整度是论坛和qq群无法比拟的
aspireios
(aspireios)
2014 年7 月 23 日 09:34
15
您好大大 我也要做短信拦截和发送 但是我看到官网上(http://iphonedevwiki.net/index.php/ChatKit.framework )的处理短信的进程是com.apple.MobileSMS啊 看到这个帖子有点晕 可以解答一下吗
MobileSMS只是展示给用户的一个壳,实际的功能主要是由imagent完成的。你可以把MobileSMS看作是用户态,imagent看作是内核态
aspireios
(aspireios)
2014 年7 月 24 日 01:39
17
喔喔 懂了 那MobileSMS还有去研究的必要么?怎么官网上读取和发送还是通过它?
从MobileSMS入手相对简单,直接调用MobileSMS的接口发送短信也没问题,相当于MobileSMS收到你的指令后在跟imagent通信而已。另外iphonedevwiki只是一个wiki,不是什么官网,里面的内容也只是网友贡献的,准确度不能保证
同感!:mad:楼主能发一份ios7能正确截取短信的代码给我不? 我也自己摸索了很久…郁闷中