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. 2017年--10年java大神告诉你开发最常用的百分之二十的技术有哪些?

    首先题主说的20%我不知道从哪方面去理解.接下来我会将自己多年来工作中会经常使用到的技术列出来. 1.html.css 2.java工作原理(jvm) 3.java语法.数据结构和算法 4.java语 ...

  2. ORM版,学生管理系统02

    学生管理系统 urls.py url(r'^student_list/$',views.student_list,name="student_list"), url(r'^dele ...

  3. [转载]Lwip之IP/MAC地址冲突检测

    from: http://blog.csdn.net/tianjueyiyi/article/details/51097447 LWIP是个轻量级的TCP/IP协议栈,之所以说轻量级,是因为作者将主体 ...

  4. NOIP模拟题 序列

    题目大意 给定长为$n$的序列$A$,定义长为$k$的区间中位数为从小到大排完序后第$\lfloor\frac{k}{2}\rfloor$个数的大小. 每次询问给定$l_1,r_1,l_2,r_2$有 ...

  5. 数据结构之最小生成树Prim算法

    普里姆算法介绍 普里姆(Prim)算法,是用来求加权连通图的最小生成树算法 基本思想:对于图G而言,V是所有顶点的集合:现在,设置两个新的集合U和T,其中U用于存放G的最小生成树中的顶点,T存放G的最 ...

  6. Python之numpy库

    NumPy库知识结构 更多详细内容参考:http://www.cnblogs.com/zhanglin-0/p/8504635.html

  7. ACM学习历程—HDU5700 区间交(树状数组 && 前缀和 && 排序)

    http://acm.hdu.edu.cn/showproblem.php?pid=5700 这是这次百度之星初赛2B的第五题.省赛回来看了一下,有这样一个思路:对于所有的区间排序,按左值排序. 然后 ...

  8. javax.servlet-api-xx.jar和servlet-api.jar区别

    一.简介支持servlet的jar包.应该叫servlet-api.jar如果编写过servlet就知道要用到HttpServletRequest和HttpServletResponse等对象,这些对 ...

  9. FPGA噪声干扰

    在FPGA高速AD采集设计中,PCB布线差会产生干扰.今天小编为大家介绍一些布线解决方案. 1.信号线的等长 以SDRAM或者DDRII为例,数据线,命令线,地址线以及时钟线最好等长,误差不要超过50 ...

  10. 【转】 Pro Android学习笔记(九三):AsyncTask(2):小例子

    目录(?)[-] 继承AsyncTask UI操作接口 使用AsyncTask 文章转载只能用于非商业性质,且不能带有虚拟货币.积分.注册等附加条件.转载须注明出处:http://blog.csdn. ...