Hotpatch

Hotpatch 是一个允许正在运行的进程动态加载一个 so 库的 C 库,类似于 Win32 上的 CreateRemoteThread() API。

和其他现有的动态加载方案相比,Hotpatch 的优点是在加载 so 库之后将会恢复原先进程的运行状态

开发者可以利用 Hotpatch 实现:

  • 加载 so 库到一个已经运行的进程中。
  • 调用该 so 库中的自定义函数。
  • 向该函数传递序列化的参数。

它包含三部分: hotpatch.h 头文件,libhotpatch.so 库和命令行辅助程序 hotpatcher

目前的局限有:

  • 用户只能向拥有权限的进程注入 so 库(当然 root 用户可以向所有进程注入)。
  • 目前仅支持 64 位 Linux,32 位支持将在下一个版本中完成。
  • 在编译共享库时需要加上连接器参数 -fPIC -nostartfiles
  • 对于一个正在运行进程仅能动态加载一次 so 库文件。

详细说明及 API 列表

Github 仓库

消息来源

Read More:

  • » No related posts

17 Comments

  1. 1 wecing Commented @ 2011-10-10 14:45Reply to this comment

    俺秃然想起Quake 2了。

  2. 2 csslayer Commented @ 2011-10-10 16:01Reply to this comment

    老实说第一条不算局限吧…… = =b 明明是正常安全就应该这样。。。。。。

  3. 3 Sunday Commented @ 2011-10-10 16:45Reply to this comment

    CreateRemoteThread 。。。。。。现在在windoows上这个函数几乎与后门木马画上了等于号!

  4. 4 un Commented @ 2011-10-10 19:45Reply to this comment

    是新的内核API吗??

  5. 5 kidfruit Commented @ 2011-10-10 22:55Reply to this comment

    @csslayer: 我觉得第一条算是一种局限,因为这种动态加载往往需要向其他进程注入,这种一般来说都不是自己能拿到权限的,就比如木马这种特殊情况吧。

  6. 6 stlxv Commented @ 2011-10-11 8:50Reply to this comment

    如论如何都看不出这个库的特别之处。

  7. 7 terryfe Commented @ 2011-10-11 8:58Reply to this comment

    跟dlopen有什么区别?

  8. 8 zmwgreenrain Commented @ 2011-10-11 11:28Reply to this comment

    更好的支持代码注入吗?

  9. 9 Iven Commented @ 2011-10-11 12:28Reply to this comment

    黑白兄,这个翻译是不是有点问题……原文似乎是:“使另外一个正在运行的进程动态加载一个 so 库文件”,而不是“允许正在运行的进程动态加载一个 so 库的 C 库”。

  10. 10 黑日白月 Commented @ 2011-10-11 13:01Reply to this comment

    @Iven:

    看完 README 之后,个人还是认为这两个是同一个意思滴~

  11. 11 Mike Commented @ 2011-10-11 13:47Reply to this comment

    注入没啥意思,有意思的是注入后,在库里面写上 raise (SIGKILL);

  12. 12 Mike Commented @ 2011-10-11 13:48Reply to this comment

    加载 so 库之后将会恢复原先进程的运行状态

    这个没看懂。。。

  13. 13 bcbc Commented @ 2011-10-11 16:05Reply to this comment

    如果是合法用途,我想通过主程序自己的命令行参数来更新自己更为靠谱,不要手动输入pid。

  14. 14 bcbc Commented @ 2011-10-11 16:07Reply to this comment

    也就是说不要通过第三方程序来更新。hotpatch应该将自己作为一个库嵌入主程序。

  15. 15 bcbc Commented @ 2011-10-11 16:14Reply to this comment

    @kidfruit: 这样的话hotpatch应该助了Linux病毒木马一臂之力,哈哈

  16. 16 damn Commented @ 2011-10-11 16:42Reply to this comment

    tomoyo、selinux这类hips显得越来越必要了。

  17. 17 芳草集 Commented @ 2011-10-20 13:47Reply to this comment

    个人还是认为这两个是同一个意思滴~