是否可以直接为可执行文件设置域名映射? 就好像我们编辑/ etc / hosts /然后运行可执行文件一样。
例:
$ ping google.com PING google.com (74.125.232.48) 56(84) bytes of data. $ magic-command -m google.com=127.0.0.1 ping google.com PING google.com (127.0.0.1) 56(84) bytes of data.
拦截大多数对libc的调用是有创意的使用LD_PRELOAD和RTLD_NEXT的。 谷歌这些string,那里有很多信息。 拦截调用open ,用/etc/hostsreplace自己的文件。 它应该工作。