【问题标题】:Am I being hacked?我被黑了吗?
【发布时间】:2012-12-03 14:16:12
【问题描述】:

这只是我的 Apache 2.0 error_log 中的几行代码:

[Sun Nov 25 08:22:04 2012] [error] [client 64.34.195.190] File does not exist: /var/www/vhosts/default/htdocs/admin
[Sun Nov 25 14:14:32 2012] [error] [client 96.254.171.2] File does not exist: /var/www/vhosts/default/htdocs/azenv.php
[Wed Nov 28 03:02:01 2012] [error] [client 91.205.189.15] File does not exist: /var/www/vhosts/default/htdocs/user
[Wed Nov 28 03:44:35 2012] [error] [client 66.193.171.223] File does not exist: /var/www/vhosts/default/htdocs/vtigercrm
[Mon Dec 03 00:09:16 2012] [error] [client 82.223.239.68] File does not exist: /var/www/vhosts/default/htdocs/jmx-console
[Mon Dec 03 20:48:44 2012] [error] [client 221.2.209.46] File does not exist: /var/www/vhosts/default/htdocs/manager
[Thu Dec 06 07:37:04 2012] [error] [client 116.254.203.24] File does not exist: /var/www/vhosts/default/htdocs/w00tw00t.at.blackhats.romanian.anti-sec:)
[Thu Dec 06 07:37:05 2012] [error] [client 116.254.203.24] File does not exist: /var/www/vhosts/default/htdocs/phpMyAdmin
[Thu Dec 06 07:37:05 2012] [error] [client 116.254.203.24] File does not exist: /var/www/vhosts/default/htdocs/phpmyadmin
[Thu Dec 06 07:37:06 2012] [error] [client 116.254.203.24] File does not exist: /var/www/vhosts/default/htdocs/pma
[Thu Dec 06 07:37:06 2012] [error] [client 116.254.203.24] File does not exist: /var/www/vhosts/default/htdocs/myadmin
[Thu Dec 06 07:37:07 2012] [error] [client 116.254.203.24] File does not exist: /var/www/vhosts/default/htdocs/MyAdmin
[Thu Dec 13 02:19:53 2012] [error] [client 96.254.171.2] File does not exist: /var/www/vhosts/default/htdocs/judge.php

最常见的错误是对“phpMyAdmin”文件和“w00tw00t.at.blackhats.romanian.anti-sec:)”的请求。

我可以看到请求来自的 IP 地址。但谁是“客户”?

谢谢, 肖恩。

【问题讨论】:

    标签: apache


    【解决方案1】:

    这只是许多 Script Kiddies 部署的自动脚本,用于寻找您的 apache 版本/配置中的安全漏洞。签名 w00tw00t 通常由DFind 留下。

    只需使用像 fail2ban 这样配置的程序,如本示例所述,以避免被这些请求淹没:

    https://web.archive.org/web/20160617020600/http://www.userdel.com/post/18618537324/block-w00tw00t-scans-with-fail2ban

    这并不一定意味着您已被黑客入侵,但服务器已被扫描以查找漏洞。但是,如果您使用在这些日志中看到的任何软件,并且它是具有已知漏洞的旧版本,您应该检查您的服务器是否存在异常文件和登录活动。

    【讨论】:

      【解决方案2】:

      对此的请求通常在没有服务器标头的情况下发送。只需为没有您期望的服务器标头的请求创建一个默认虚拟主机并将其黑洞。记录中断的流量并执行反向 DNS 以查看它是否来自另一个网络服务器(被入侵?)并根据 whois 数据库联系所有者也很有趣。您永远不知道谁在可公开识别的服务器上运行愚蠢的脚本来扫描漏洞,然后通过 ToR 隧道利用它们。如果您不想引起注意,请使用燃烧器联系信息。

      【讨论】:

      • 我该怎么做?我会在默认文件中放入什么?谢谢!
      【解决方案3】:

      为了跟进@user823629 给出的答案,这是我在 Apache 2.4 上使用的默认虚拟主机配置:

      <VirtualHost *:80>
          # Default vhost for requests not matching IP or Host of other vhosts
          ServerName blackhole
          ErrorLog logs/error_log_default
          CustomLog logs/access_log_default combined
      
          Redirect 404 /
      </VirtualHost>
      
      <VirtualHost *:443>
          # Default vhost for requests not matching IP or Host of other vhosts
          ServerName blackhole
      
          ErrorLog logs/ssl_error_log_default
          CustomLog logs/ssl_access_log_default combined
          CustomLog logs/ssl_request_log_default   "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
      
          SSLEngine on
          SSLCertificateFile /etc/pki/tls/certs/localhost.crt
          SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
      
          Redirect 404 /
      </VirtualHost>
      

      它将所有请求重定向到默认的 404 页面。与任何其他站点不匹配的 SSL 请求将在第二个 VirtualHost 定义处结束,当然会导致证书错误,但这是意料之中的事。

      我把它放在conf.d 中并命名为conf.d/0_default.conf,这样它就出现在其他虚拟主机定义之前,并且它是默认的虚拟主机。这可以通过以下方式验证:

      apachectl -t -D DUMP_VHOSTS
      

      或在 Redhat/Fedora/CentOS 发行版上:

      httpd -t -D DUMP_VHOSTS
      

      如果出现以下情况,其他虚拟主机将在此默认虚拟主机之前匹配:

      1. 他们的 IP 地址和端口更明确地匹配 VirtualHost 定义(基于 IP 的虚拟主机),或者
      2. 请求包含与请求匹配的Host 标头(基于名称的虚拟主机)。否则,请求将回退到上面定义的默认黑洞虚拟主机。

      小心使用指定 IP 地址的 VirtualHost 定义。由于这些在黑洞之前匹配,因此错误的配置可能成为该 IP 的默认配置。必要时列出黑洞中的具体IP。

      有关虚拟主机匹配的更多详细信息,请参阅http://httpd.apache.org/docs/current/vhosts/details.html

      【讨论】:

        【解决方案4】:

        除非您实际使用 /var/www/vhosts/default/ 来托管网站,否则这意味着您的虚拟主机设置未捕获到默认主机的请求。

        暂时忽略这些是恶意请求,因为这些 vhosts/default/ 错误的根本原因是您可能为虚拟主机禁用了 SSL,而这些是 HTTPS 请求在默认服务器配置。

        您可以在 httpd.conf 中将 %v %V %p 添加到您的 Apache 访问日志参数中,以查看有关这些请求是什么以及处理它们的虚拟主机/服务器名称 (%v %V) 和端口 (%p) 的更多信息请求是通过(如果是 HTTPS,通常是端口 443)发出的。

        要修复 HTTPS 方面,我会启用 SSL,然后放入 RewriteRule 以将 HTTPS 请求发送到 HTTP(如果这是预期的行为)。 More info about how to do that here.

        否则要帮助脚本小子,上面提到的黑洞是要走的路。只要确保您没有错误地将请求 HTTPS 的合法网络爬虫/蜘蛛发送到同一个银河死亡 - 例如 Googlebot 通过 HTTPS 测试合法页面,因为这是 Google 希望网络进入的方向。

        【讨论】:

          猜你喜欢
          • 2018-08-27
          • 2010-10-30
          • 2020-01-22
          • 2019-01-06
          • 2016-06-12
          • 1970-01-01
          • 2011-07-16
          相关资源
          最近更新 更多