我试图使用iptables阻止所有autodiscover.xml请求到我们的服务器。我们的服务器上不存在自动发现文件,但是由于网站没有子域,所以请求正在攻击我们的服务器。这是我到目前为止输入的内容,但它们不起作用。见下面的日志。请求不断涌来。
iptables -I INPUT -p tcp --dport 80 -m string --string "POST /autodiscover" --algo bm -j DROP
iptables -I INPUT -p tcp --dport 443 -m string --string "POST /autodiscover" --algo bm -j DROP这在输入链的顶部产生了这样的结果:
DROP tcp -- anywhere anywhere tcp dpt:http STRING match "POST /autodiscover" ALGO name bm TO 65535
DROP tcp -- anywhere anywhere tcp dpt:https STRING match "POST /autodiscover" ALGO name bm TO 65535但是,我仍然收到Apache日志中的请求。
[09/Jan/2020:17:04:31 -0500] "POST /autodiscover/autodiscover.xml HTTP/1.1" 403 3668 "-" "Microsoft Office/16.0 (Windows NT 10.0; Microsoft Outlook 16.0.6701; Pro)"
[09/Jan/2020:17:12:59 -0500] "POST /autodiscover/autodiscover.xml HTTP/1.1" 403 3668 "-" "Microsoft Office/16.0 (Windows NT 10.0; Microsoft Outlook 16.0.6701; Pro)"发布于 2020-01-10 01:58:16
iptables是这里工作的错误工具。您的工作假设是,在TCP级别上看到的内容与浏览器发送的内容相同,但情况往往并非如此。
最大的例子是HTTPS,还有HTTP/2.更广泛地说,您还会发现压缩编码也会妨碍到这里的工作。
另一件事,将挫败你的尝试,并有可能打破其他流量,是连接保持生命。
由于您使用的是Apache,所以您应该在httpd中真正做到这一点。下面是一个这样的示例,用于防止将此类请求传递给后端(httpd用作反向代理),而我将其重定向到Exchange服务器之一:
ProxyPass /autodiscover/autodiscover.xml !
Redirect 302 /autodiscover/autodiscover.xml https://autodiscover.example.org/autodiscoverer.xml其他选项是禁止内容。在这里,我还展示了如果您不想禁止内部客户端(尽管实际上您可能仍然需要支持来自网络之外的用户),可以将其结合在一起。
RewriteEngine On
RewriteCond %{REMOTE_ADDR} !^10\.
RewriteCond %{REQUEST_URI} ^/autodiscover
RewriteRule .* - [F]另一个例子,即只有404 s的请求(同样,在反向代理环境中)
#
# Deal with some particularly noisy 404s that we don't want to throw back to the
# backend as they can take a long time to process.
#
ProxyPass /autodiscover/autodiscover.xml !
RewriteRule ^/autodiscover/autodiscover.xml$ - [R=404,L]https://serverfault.com/questions/998367
复制相似问题