Skip to main content

Image-Based Bot Detector

Image-Based Bot Detector is a variant of image-based CAPTCHAs that uses human ability to recognize a distorted region on the image he never seen before.

Licence
Download Image-Based Bot Detector

Requires .NET Framework 2.0

Overview, help

In order to use it you have to set TemplateImageFolder property to relative virtual path of the template images folder - for example, "~/templates" and to add registration of HttpHandler in web.config.
<httpHandlers>
<add verb="GET" path="ImageBasedBotDetector.ashx"
type="Marss.Web.UI.Controls.ImageBasedBotDetector, Marss.Web"/>
</httpHandlers>
There are 3 types of predefined distortion (Stretched, Random, Volute) and user-defined (Custom) distortion. In order to use predefined distortion it needs to set DistortionType property. User-defined distortion can be used in derived classes with overriden DrawCustom method.

If you want to use template images that are placed elsewhere then a subfolder of your web application - for example, from database - you have to override GetTemplateImage method.

To check whether user passed the test IsValid property is used. Also user can be locked after a predefined number of unsuccessful attempts to pass the test (FailedAttemptsBeforeLocking property, default value is 5).

Public properties
TemplateImageFolderGets or sets template image folder.
FailedAttemptsBeforeLockingGets or sets the number of unsuccessful attempts before locking.
IsValidGets result of test passing.
IsLockedGets or sets value indicating where user is locked.
DistortionTypeGets or sets distortion type. Available types:
  • Stretched - image within distorted area is stretched.
  • Random - points within distorted area is mixed in a random way.
  • Volute - image within distorted area is volute.
  • Custom - custom distortion. Have to be used together with overriden DrawCustom method.
Public events
LockedOccurs when detector has been locked because of exceeding the failed attempts limit.
public event EventHandler Locked

Protected virtual methods
GetTemplateImageGets template image.
protected virtual System.Drawing.Image GetTemplateImage()
See example of usage.
DrawCustomDistorts specified rectangle of image in a user defined way. Have to be used coupled with DistortionType=Custom
protected virtual void DrawCustom(System.Drawing.Bitmap bitmap, System.Drawing.Image img, Rectangle distortedRectangle)
where
bitmap - the output image,
img - the template (input) image,
distortedRectangle - area on the image to be distorted.

Comments