如何在 IIS 7.5 中阻止空/空白用户代理

Jer*_*oyd 5 iis-7.5 ddos

我们正在经历大规模 DDOS 攻击,但这不是我们的 Cisco Guard 可以处理的典型僵尸网络,而是 BitTorrent 攻击。这对我来说是新的,所以我不确定如何阻止它。

以下是 IIS 每秒处理来自 BitTorrent 客户端的 40 到 100 个请求的统计数据。我们大约有 20% 的用户代理,但其他 75% 是空白的。

我们希望在服务器级别阻止空白用户代理。

最好的方法是什么?

Pet*_*orf 5

如果请求过滤无法处理此问题,您可以尝试“ URL Rewrite ”,这是 Microsoft 提供的免费附加组件,无论如何都非常有用。

创建一个像这样的规则:

<rule name="NoUserAgent" stopProcessing="true">
    <match url=".*" />
    <conditions>
        <add input="{HTTP_USER_AGENT}" pattern="^$" />
    </conditions>
    <action type="CustomResponse" statusCode="403" statusReason="Forbidden: Access is denied." statusDescription="You did not present a User-Agent header which is required for this site" />
</rule>
Run Code Online (Sandbox Code Playgroud)

在一项快速测试中,这对于空的用户代理和丢失的用户代理都有效。

我使用的正则表达式“^$”仅对空字符串有效。

您还可以返回 404 或您想要的任何其他内容,而不是 403。