MobileSubstrate
【MobileSubstrate】
Cydia Substrate (formerly called MobileSubstrate) is the de facto framework that allows 3rd-party developers to provide run-time patches (“Cydia Substrate extensions”) to system functions.
MobileSubstrate也叫CydiaSubstrate,是一个基础架构,允许第三方开发者为系统功能提供CydiaSubstrateExtension(也叫做tweaks)。
Cydia Substrate consists of 3 major components: MobileHooker, MobileLoader and safe mode.
CydiaSubstrate提供3个主要的组件:MobileHook,MobileLoader,safeMode。
【MobileHook】
MobileHooker is used to replace system functions. This process is known as hooking. There are 2 APIs that one would use:

MSHookMessage() will replace the implementation of the Objective-C message -[class selector] by replacement, and return the original implementation. To hook a class method, provide the meta class retrieved from objc_getMetaClass in the MSHookeMessage(Ex) call and see example note below. This dynamic replacement is in fact a feature of Objective-C, and can be done using method_setImplementation. MSHookMessage() is not thread-safe and has been deprecated in favor of MSHookMessageEx().
MSHookMessage()非纯种安全,已经被deprecated。
MSHookFunction() is like MSHookMessage() but is for C/C++ functions. The replacement must be done at assembly level. Conceptually, MSHookFunction() will write instructions that jumps to the replacement function, and allocate some bytes on a custom memory location, which has the original cut-out instructions and a jump to the rest of the hooked function. Since on iOS by default a memory page cannot be simultaneously writable and executable, a kernel patch must be applied for MSHookFunction() to work.
ios中黑夜一块内存不能同时具有写&执行的权限,需要打一个kernel patch才能使MSHookFunction()起作用。
【MSHook Example Code】
1、Using MSHookFunction:

2、Using MSHookMessageEx:

3、Note that if you are hooking a class method, you have to put a meta-class in the class argument, e.g.

【MobileLoader】
MobileLoader loads 3rd-party patching code into the running application.
MobileLoader will first load itself into the run application using DYLD_INSERT_LIBRARIES environment variable. Then it looks for all dynamic libraries in the directory /Library/MobileSubstrate/DynamicLibraries/, and dlopen them. An extension should use constructor code to perform any works, e.g.

【safe mode】
When a extension crashed the SpringBoard, MobileLoader will catch that and put the device into safe mode. In safe mode all 3rd-party extensions will be disabled.
The following signals will invoke safe mode:
- SIGTRAP
- SIGABRT
- SIGILL
- SIGBUS
- SIGSEGV
- SIGSYS
参考:http://iphonedevwiki.net/index.php/MobileSubstrate
MobileSubstrate的更多相关文章
- [原]MobileSubstrate 工作流程
[附-腾讯安全管家替换 MobileSubstrate 的流程] com.qq.mqqsecure.deb-postinst--->QSCommand--->QSTempRunner
- iOS逆向开发(4):注入目标函数 | fishhook | MobileSubstrate | MSHookFunction | iOSOpenDev
从获得APP的所有类声明,到锁定目标类与函数,现在是时候注入函数了. 所谓"注入函数",小程的意思是让APP执行到小程写的代码中,跟"钩子"的概念一致.小程把个 ...
- 【腾讯Bugly干货分享】移动App入侵与逆向破解技术-iOS篇
本文来自于腾讯bugly开发者社区,非经作者同意,请勿转载,原文地址:http://dev.qq.com/topic/577e0acc896e9ebb6865f321 如果您有耐心看完这篇文章,您将懂 ...
- IOS_ios逆向工程-静态分析
返回博客列表 原 ios逆向工程-静态分析 余成海 发布时间: 2014/11/03 19:17 阅读: 11201 收藏: 17 点赞: 5 评论: 6 最近在学习IOS逆向工程,查看网络上的资料也 ...
- (转)iOS安全 对本地文件的保护
开篇先扯几句题外话,许多朋友都问我怎么不写防啊,我确实有点犹豫.hackers总是想象如果自己是开发者会怎么写,然后才能找到入手点.同理,开发者们也要想象自己是hackers会怎么做,才能采取相应的防 ...
- Reveal分析IOS界面,plist文件读取
Reveal分析IOS界面,需要得到app的 softwareVersionBundleId上传到iphone中 , 而IOS8的iTunesMetadata.plist (设备路径/var/mobi ...
- iOS底层基础知识-文件目录结构
一:iOS沙盒知识 出于安全考虑,iOS系统把每个应用以及数据都放到一个沙盒(sandbox)里面,应用只能访问自己沙盒目录里面的文件.网络资源等(也有例外,比如系统通讯录.照相机.照片等能在用户授权 ...
- 用Reveal分析第三方App的UI
文章出自:听云博客 Reveal简介: 这是个神奇的工具,它能常透彻地分析个App的UI结构. 这个工具包括两部分,部分是在PC上运行的一个独立应用,即Reveal.app,另一部分代码在你要分析的某 ...
- 关于调试日志Log
__VA_ARGS__ 是一个可变参数的宏,这个可变参数的宏是新的C99规范中新增的,目前似乎只有gcc支持(VC6.0的编译器不支持).宏前面加上##的作用在于,当可变参数的个数为0时,这里的## ...
随机推荐
- [置顶]
个人博客上线!欢迎来访~ http://onlyloveyd.cn/
简介 Hexo + Github + 个人域名 构建静态博客系统. 构建方法 参考 https://yq.aliyun.com/articles/64953 个人博客网站 Cherish Androi ...
- 安装使用lynis扫描Linux的安全漏洞
Lynis是Linux平台上的一款安全漏洞扫描工具.它可以扫描系统的安全漏洞.收集系统信息.安装的软件信息.配置问题.没有设置密码的用户和防火墙等等. Lynis是流行可靠的安全扫描工具. 前不久,L ...
- 深入分析AIDL原理
深入分析AIDL原理 分类: Android2011-11-18 17:29 6522人阅读 评论(1) 收藏 举报 descriptorcallbackservicenullinterfaceser ...
- HihoCoder 1122二分图二 ---最大匹配之匈牙利算法
二分图二•二分图最大匹配之匈牙利算法 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 上一回我们已经将所有有问题的相亲情况表剔除了,那么接下来要做的就是安排相亲了.因为过 ...
- LeetCode Subarray Product Less Than K
原题链接在这里:https://leetcode.com/problems/subarray-product-less-than-k/description/ 题目: Your are given a ...
- Hive中使用Python实现Transform时遇到Broken pipe错误排查
Hive中有一表,列分隔符为冒号(:),有一列utime是Timestamp格式,需要转成Weekday存到新表. 利用Python写一个Pipeline的Transform,weekday.py的代 ...
- noip济南清北冲刺班DAY1
上午 T1 立方数 题目描述 LYK定义了一个数叫“立方数”,若一个数可以被写作是一个正整数的3次方,则这个数就是立方数,例如1,8,27就是最小的3个立方数. 现在给定一个数P,LYK想要知道这个数 ...
- Oracle的闪回特性之恢复truncate删除表的数据
Oracle的闪回特性之恢复truncate删除表的数据 SQL> show parameter flashback NAME T ...
- COGS 2259 异化多肽——生成函数+多项式求逆
题目:http://cogs.pro:8080/cogs/problem/problem.php?pid=2259 详见:https://www.cnblogs.com/Zinn/p/10054569 ...
- dx工具(android将jar包转成dex格式二进制jar包工具)
博客分类: android 时钟 dx工具二进制jar包 好吧,不得不承认这个工具真心难找,也不知道自己sdk里以前怎么就有了,还好给了师傅一份,现在重装系统从网上找这个工具都找不到. 将platf ...