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