Sunday, December 15, 2024

ASP.NET: Easily Block DoS Attacks

Share

Denial of Service (DoS) attacks are becoming a more and more common way to bring websites and servers down.

They are very easy to do and pretty hard to protect against, which is why they are so popular.

The only thing you can do to prevent such an attack is to block the response to the attackers. You have no control over the requests, so you have to catch the attacker as early as possible after the request has been received by the web server.

There are two challenges to blocking the attacks

  • Identify the attackers
  • Block the response only to the attackers

To catch the request as early as possible, an HttpModule is the right place.

It is executed before any page or any other handler so the impact on the server can be minimized.

This HttpModule monitors all requests and block requests coming from IP addresses that make many requests in a short period of time.

After a while the attacking IP address gets released from blocking.

The module is a high performance and lightweight protection from DoS attacks and very easy to implement.

Implementation

Download the DosAttackModule.cs file below and put it into the App_Code folder of your website. Then add the following lines to the web.config’s section:

<httpModules>

  <add type="DosAttackModule" name="DosAttackModule"/>

</httpModules>

Download

DosAttackModule.zip (1,13 KB)

Comments

Tag:

Add to Del.icio.us | Digg | Reddit | Furl

Bookmark Murdok:

Mads Kristensen currently works as a Senior Developer at Traceworks located
in Copenhagen, Denmark. Mads graduated from Copenhagen Technical Academy with a multimedia degree in
2003, but has been a professional developer since 2000. His main focus is on ASP.NET but is responsible for Winforms, Windows- and
web services in his daily work as well. A true .NET developer with great passion for the simple solution.

Home

Table of contents

Read more

Local News