【发布时间】:2013-07-11 19:11:58
【问题描述】:
我的网络服务器遇到问题。 有人用泄露的 wordpress 感染了它。 问题如下,文件中某处存在一些恶意 phpscript。 恶意脚本在网络服务器 (/home) 上的每个文件中都放置了一个 iframe 但问题是我不知道脚本在哪里,我在 /home 中有数千个网络文件,它可能在任何地方。 我知道如何删除所有 iframe,但我的想法是删除触发器。 所以我在徘徊如何解决它,我可能有一个解决方案,但我需要你的建议
我注意到脚本不时执行,但完全随机(大约每周一次) 现在假设我使用以下 shell 命令(目前每 30 分钟运行一次)清除了所有恶意 iframe
find /home -type f | xargs sed -i 's$<iframe src="[^"]*" width="2" height="2" frameborder="0"></iframe>$ $g'
现在我所有的 php 文件都没有 iframe,我的想法是在 iframe 再次出现时提醒我。 像这样,如果我有 iframe 出现的大致时间,那么我可以查看 apache 日志以查看调用了哪个 webscript。
所以我创建了另一个 bash shell,我想听听你的建议,看看它是否可以。 我会在服务器上每 30 分钟运行一次,直到收到邮件。
然后我会查看 apache 日志以检查最近 30 分钟的日志。
这就是我正在考虑的 bash:
#!/bin/bash
find /home -type f | xargs grep -q '<iframe src="[^"]*" width="2" height="2" frameborder="0"></iframe>' #Find the string in all file on my all directory
if [ $? -eq 0 ] #if the result is not equal to zero
then
echo "At the following time : " $(date +%H-%M-%S) | mail -s "[Serveur Leaked] Bad iframe has been found " me@mymail #we send a mail with the date
find /home -type f | xargs sed -i 's$<iframe src="[^"]*" width="2" height="2" frameborder="0"></iframe>$ $g' #we replace the iframe with a whitespace
else
exit 1
fi
exit 0
我真的需要找到一个解决方案,因为正如我所说的,我每 30 分钟运行一次查找和替换 shell 命令,这需要很多过程。
但我不能让 iframe 在我的服务器上放置太久,否则我的网站会被 google 列入黑名单,我负担不起。
非常感谢您对未来的建议。
安塞尔
【问题讨论】:
-
我找到了可以帮助你的东西:unix.stackexchange.com/a/13462/40596
-
或许也可以将此问题发布到security.stackexchange.com。
-
如果您是唯一应该修改这些文件的人,那么您也许可以使用 filemtime() 来测试文件的最后修改时间与您的脚本上次运行的时间。