飘云 发表于 2015-7-15 15:32:50

利用 DYLD_INTERPOSE 宏 完成OS X系统函数hook

参考官方头文件:http://www.opensource.apple.com/ ... /dyld-interposing.h

原帖地址:http://www.dllhook.com/post/103.html
//演示代码
// #import <mach-o/dyld-interposing.h>
// from dyld-interposing.h
#define DYLD_INTERPOSE(_replacement,_replacee) __attribute__((used)) static struct{ const void* replacement; const void* replacee; } _interpose_##_replacee __attribute__ ((section ("__DATA,__interpose"))) = { (const void*)(unsigned long)&_replacement, (const void*)(unsigned long)&_replacee };

ssize_t hacked_write(int fildes, const void *buf, size_t nbyte)
{
    printf("[++++]into hacked_write---by piaoyun");
    return write(fildes, buf, nbyte);
}

DYLD_INTERPOSE(hacked_write, write);没错,就是这么简单!! 编译成dylib注入即可!

menglv 发表于 2015-7-15 19:36:15

这是个好东西,谢谢楼主分享.

xie83544109 发表于 2015-7-15 23:32:22

{:soso_e113:}
虽然看不懂,感觉很强大

0xcb 发表于 2015-7-17 19:22:42

https://github.com/facebook/fishhook

smallhorse 发表于 2015-7-18 00:06:22

{:soso_e102:}期待着macing...........

qweokup 发表于 2015-7-18 21:43:17

谢谢楼主分享.

huzhao23 发表于 2015-7-19 00:01:37

赞一个,学习了哈

niusiqiang 发表于 2015-7-21 20:50:39

xiex谢谢分享,棒棒的
页: [1]
查看完整版本: 利用 DYLD_INTERPOSE 宏 完成OS X系统函数hook