ASP.Net模块阻止DOS攻击
我想以编程方式保护我的 ASP.Net 4.0 网站免受有害的重复请求。如果我注意到某个 IP 的请求数量很高,那么我想将该 IP 阻止一段时间(例如,如果有人编写 FOR 循环并一遍又一遍地请求该网页)。我知道最好的防御措施不是向未经身份验证的用户提供数据,但不幸的是,某些公共页面数据量很大,我对此无能为力。
我今天查看了一些解决方案,但没有一个令我满意。我猜这是一个非常常见的问题,我不想从头开始实现这样的事情。
我看到作为模块实现的解决方案,我会喜欢做同样的事情,但做得更好。我需要以下功能:
- 检测到非人类模式后阻止 IP
- 最好实现为 HttpModule
- 允许爬虫通过
- 阻止应在一定时间间隔后过期
- 轻量级:该模块不应减慢网站速度或访问数据库
I would like to programmatically protect my ASP.Net 4.0 website from harmful repeated requests. If I notice high request number from an IP then I would like to block that IP for a certain time (ex. in case someone writes a FOR cycle and requests the webpage over and over). I know that the best defense is not to server data to unauthenticated users but unfortunately some public pages are data-heavy and there is nothing I can do about it.
I looked at some solutions today but none of them satisfied me. I am guessing that this is a very common issue and I would not like to implement something like this from scratch.
I saw a solution implemented as a module and I would like to do the same but better. I need the following features:
- Block IP after detecting a non-human pattern
- Preferably implemented as an HttpModule
- Allow the crawlers through
- Block should expire after a certain interval
- Lightweight: the module should not slow down the website or access the database
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决上述问题有两种方法:
对于第一种方法,
来源:https://www.iis.net /downloads/microsoft/dynamic-ip-restrictions:
对于第二种方法,
它带有一个 HttpModule,可以保护您的整个网站。
调用示例:
LoginController 示例:
在 web.config 中,您需要使用 HttpModule 指定要保护的路径。
来源/来源:https://github.com/oazabir/HackerSpray
There are 2 approaches for the above problem:
For 1st approach,
source: https://www.iis.net/downloads/microsoft/dynamic-ip-restrictions:
For 2nd Approach,
It comes with a HttpModule, which protects your entire website.
Example calls:
LoginController Example:
In the web.config, you need to specify which paths to protect using the HttpModule.
Credits / Source: https://github.com/oazabir/HackerSpray