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的更多相关文章

  1. [原]MobileSubstrate 工作流程

    [附-腾讯安全管家替换 MobileSubstrate 的流程] com.qq.mqqsecure.deb-postinst--->QSCommand--->QSTempRunner

  2. iOS逆向开发(4):注入目标函数 | fishhook | MobileSubstrate | MSHookFunction | iOSOpenDev

    从获得APP的所有类声明,到锁定目标类与函数,现在是时候注入函数了. 所谓"注入函数",小程的意思是让APP执行到小程写的代码中,跟"钩子"的概念一致.小程把个 ...

  3. 【腾讯Bugly干货分享】移动App入侵与逆向破解技术-iOS篇

    本文来自于腾讯bugly开发者社区,非经作者同意,请勿转载,原文地址:http://dev.qq.com/topic/577e0acc896e9ebb6865f321 如果您有耐心看完这篇文章,您将懂 ...

  4. IOS_ios逆向工程-静态分析

    返回博客列表 原 ios逆向工程-静态分析 余成海 发布时间: 2014/11/03 19:17 阅读: 11201 收藏: 17 点赞: 5 评论: 6 最近在学习IOS逆向工程,查看网络上的资料也 ...

  5. (转)iOS安全 对本地文件的保护

    开篇先扯几句题外话,许多朋友都问我怎么不写防啊,我确实有点犹豫.hackers总是想象如果自己是开发者会怎么写,然后才能找到入手点.同理,开发者们也要想象自己是hackers会怎么做,才能采取相应的防 ...

  6. Reveal分析IOS界面,plist文件读取

    Reveal分析IOS界面,需要得到app的 softwareVersionBundleId上传到iphone中 , 而IOS8的iTunesMetadata.plist (设备路径/var/mobi ...

  7. iOS底层基础知识-文件目录结构

    一:iOS沙盒知识 出于安全考虑,iOS系统把每个应用以及数据都放到一个沙盒(sandbox)里面,应用只能访问自己沙盒目录里面的文件.网络资源等(也有例外,比如系统通讯录.照相机.照片等能在用户授权 ...

  8. 用Reveal分析第三方App的UI

    文章出自:听云博客 Reveal简介: 这是个神奇的工具,它能常透彻地分析个App的UI结构. 这个工具包括两部分,部分是在PC上运行的一个独立应用,即Reveal.app,另一部分代码在你要分析的某 ...

  9. 关于调试日志Log

    __VA_ARGS__  是一个可变参数的宏,这个可变参数的宏是新的C99规范中新增的,目前似乎只有gcc支持(VC6.0的编译器不支持).宏前面加上##的作用在于,当可变参数的个数为0时,这里的## ...

随机推荐

  1. Maven入门:Maven的基本概念

    本文转自:http://www.tianmaying.com/tutorial/maven-basic 看这篇文章之前,你应该先Run起来一个简单的Maven项目,先有个感性认识,然后再来听听对这些基 ...

  2. canvas 绘制图像

    结果: 代码: <!DOCTYPE html> <html> <head lang="en"> <meta charset="U ...

  3. v-if和v-show的区别

    v-if 是“真实”的条件渲染,因为它会确保条件块(conditional block)在切换的过程中,完整地销毁(destroy)和重新创建(re-create)条件块内的事件监听器和子组件. v- ...

  4. 简直offer-第四章解决面试题思路(二叉树中和为某一值的路径)

    题目:输入一颗二叉树和一个整数,打印出二叉树中节点值的和为输入整数的所有路径.从树的根节点往下一直到叶子节点形成一条路径. 思路:很明显用前序遍历可以从根节点开始遍历到叶子节点,然后将遍历的节点添加到 ...

  5. LeetCode Split Array into Consecutive Subsequences

    原题链接在这里:https://leetcode.com/problems/split-array-into-consecutive-subsequences/description/ 题目: You ...

  6. rest_framework使用完之后的简单总结

    首先先大致概括一下使用流程,因为还不是对这个框架很熟悉(其实有很多知识可以对比formModel的) 其实还是遵循django的MTV的模式,还是得从url开始 1.rest_framework有一个 ...

  7. 百度分享和bshare

    社会法社交分享组件bshare http://www.bshare.cn/ 百度share也不错

  8. MySQL连接查询、联合查询、子查询

    参考地址:http://blog.csdn.net/u011277123/article/details/54863371 1.MySQL连接查询 连接查询:将多张表(>=2)进行记录的连接(按 ...

  9. android Shape使用(转)

    在Android中常常会使用shape来定义控件的一些显示属性,那么怎么来用那,今天我们就来看一些shape的使用,大家看完这篇以后就会对shape有了大体的了解,下面的是稍作总结请大家仔细的观看: ...

  10. 获取access_token错误 40164

    没有添加IP白名单