首页 > 其他 > 详细

Mac hook——DYLD_INSERT_LIBRARIES

时间:2014-05-12 02:14:12      阅读:1156      评论:0      收藏:0      [点我收藏+]

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-2:test leedani$ export DYLD_FORCE_FLAT_NAMESPACE=1
dani-2:test leedani$ export DYLD_INSERT_LIBRARIES=openhook.dylib
dani-2: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

bubuko.com,布布扣

 

参考:

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

 

Mac hook——DYLD_INSERT_LIBRARIES,布布扣,bubuko.com

Mac hook——DYLD_INSERT_LIBRARIES

原文:http://www.cnblogs.com/tekkaman/p/3721378.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!