Answers:
您可以使用审核来找到它。如果尚不可用,请安装发行版并启用审核。
在/ etc / hosts上设置审核监视
/sbin/auditctl -w /etc/hosts -p war -k hosts-file
-w watch /etc/hosts
-p warx watch for write, attribute change, execute or read events
-k hosts-file is a search key.
等到主机文件更改,然后使用ausearch查看记录的内容
/sbin/ausearch -f /etc/hosts | more
您将获得大量输出,例如
time-> Wed Oct 12 09:34:07 2011 type = PATH msg = audit(1318408447.180:870):item = 0 name =“ / etc / hosts” inode = 2211062 dev = fd:00 mode = 0100644 ouid = 0 ogid = 0 rdev = 00:00 obj = system_u:object_r:etc_t:s0 type = CWD msg = audit(1318408447.180:870):cwd =“ / home / iain” type = SYSCALL msg = audit(1318408447.180:870):arch = c000003e syscall = 2成功=是退出= 0 a0 = 7fff73641c4f a1 = 941 a2 = 1b6 a3 = 3e7075310c项目= 1 ppid = 7259 pid = 7294 au id = 1001 uid = 0 gid = 0 euid = 0 suid = 0 fsuid = 0 egid = 0 sgid = 0 fsgid = 0 tty = pts0 ses = 123 comm =“ touch” exe =“ / bin / touch” subj = user_u:system_r:unconfined_t:s0 key =“ hosts-file”
在这种情况下,我使用touch命令更改了文件timstamp,它的pid为7294,而其ppid为7259(我的shell)。
ausearch
<no matches>
也许最好使用像Incron这样的东西
http://inotify.aiken.cz/?section=incron&page=about&lang=zh-CN
然后,您可以获取它以触发脚本以进行某种诊断