Mac hook—DYLD_INSERT_LIBRARIES

1、gcc生成dylib。

gcc -dynamiclib -o mysharedlib.dylib mysharedlib.c

2、gcc生成dylib,指定flatnamespace。

gcc -flat_namespace -dynamiclib -o openhook.dylib openhook.c

3、如何Hook?

dani-:test leedani$ export DYLD_FORCE_FLAT_NAMESPACE=
dani-:test leedani$ export DYLD_INSERT_LIBRARIES=openhook.dylib
dani-:test leedani$ ./main
--------zz------hello,dani

4、Mac offers a way to override functions in a shared library with DYLD_INSERT_LIBRARIES environment variable (which is similar to LD_PRELOAD on Linux). When you make a twin brother of a function that is defined in an existing shared library, put it in you a shared library, and you register your shared library name in DYLD_INSERT_LIBRARIES, your function is used instead of the original one. This is my simple test. Here I’ve replaced f() in mysharedlib.dylib with f() in openhook.dylib.

5、关于DYLD_INSERT_LIBRARIES & DYLD_FORCE_FLAT_NAMESPACE

参考:

1、http://www.h4ck.org.cn/2013/04/hooking-library-calls-on-mac-using-dyld_insert_libraries/

2、http://blog.sina.com.cn/s/blog_45e2b66c0101cde0.html

最新文章

  1. redis安装
  2. python函数和常用模块(一),Day3
  3. Linq之常见关键字
  4. mybatis3 :insert返回插入的主键(selectKey)
  5. /Users/alamps/AndroidStudioProjects/Demo10ScrollView
  6. CSS3 Transitions, Transforms和Animation使用简介与应用展示
  7. linux mysql目录详解
  8. C++ 1
  9. CSS块级元素、内联元素概念
  10. jmock2.5基本教程(转)
  11. Java生成登陆时使用的图片验证码
  12. python mysql多条插入
  13. CCF-CSP 最大的矩形
  14. Java中的ReentrantLock和synchronized两种锁机制的对比
  15. Mysql update指定区间的数据
  16. MySql基础笔记(一)Mysql快速入门
  17. iOS10 11跳转系统设置等的URL收集
  18. MIME类型解析
  19. 如何构造分层次的 Json 数据
  20. python sockerserver tcp 文件下载 udp

热门文章

  1. TensorFlow官网访问不了
  2. Linux SSH的命令详解[转]
  3. 【vs2013】如何在VS的MFC中配置使用GDI+?
  4. HDU - 6333:Harvest of Apples (组合数前缀和&莫队)
  5. 给UIButton设置阴影及动画组
  6. LeetCode Subarray Product Less Than K
  7. UVA11178 Morley's Theorem
  8. gradle wrapper 简单使用
  9. Java各种集合容器的总结
  10. idea操作