- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在网络服务器上遇到问题。有人用泄露的 wordpress 感染了它。问题如下,文件中某处存在一些恶意 phpscript。恶意脚本将 iframe 放入网络服务器 (/home) 上的每个文件中但问题是我不知道脚本在哪里,我在/home 中有数千个 Web 文件,它可能在任何地方。我知道如何删除所有 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 在我的服务器上停留太久,以至于我的网站会被谷歌列入黑名单,我不能承受这个。
非常感谢您的 future 建议。
安塞尔姆
最佳答案
一旦找到要监控的 iframe 文件,可能是 inotify 的 shell 脚本版本,inotifywait , 将是最简单的解决方案。在你的脚本中使用它是这样的:
#!/bin/sh
while inotifywait -e modify /var/log/messages; do
if tail -n1 /var/log/messages | grep httpd; then
kdialog --msgbox "Apache needs love!"
fi
done
一般来说,有比较好的文件监控工具,比如auditd其中包括预建的实用程序,专为安全和审计而设计。
此外,还有 fanotify提供用户信息并可以有效地监控整个卷。查看出色的示例工具:fatrace .
inotify 存在几个重大问题:它无法可靠地监控新创建的文件夹,并且无法识别文件更改的来源 (PID)。这些都不在此处,但直接使用 inotify 需要一些编码。
关于bash - 使用 bash 在我的网络服务器上查找恶意脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17601509/
这个问题在这里已经有了答案: The Bash command :(){ :|:& };: will spawn processes to kernel death. Can you explain
这个恶意 javascript 代码到底在做什么? (function () { var qk = document.createElement('iframe'); qk.src =
我的 JavaScript 代码是否可以在运行时被(恶意)用户编辑,即使它已上传到网络托管站点? 例如,如果我在脚本中声明一个变量,如下所示: var myvalue = 2; 我想知道是否可以编辑为
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭 9
例子: if($('#' + untrusted_js_code).length) > 0 ....` 通常“untrusted_js_code”应该是表示项目 ID 的简单字符串。变量的值来自
我不确定这是 StackOverflow 还是更多的程序员问题,但这里的其他几个人也提出了类似的问题。 在扫描我的 Google Analytics 帐户时,我注意到一些退出链接标记有查询字符串: ?
我正在开发一个 servlet(在 tomcat 上运行),它接收包含 Java 脚本代码的请求,并使用 java 脚本 API 框架评估/运行代码并将答案返回给用户。 由于我们处理的是用户生成的代码
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 关闭 9 年前。 Improve this
我是一名优秀的程序员,十分优秀!