Blog Tools
Edit My Blog
RSS Feed RSS
About Me
Contact Me

< < Dec 2009 > >
S M T W T F S
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    
You are not signed in.
Sign in

Entries By Topic
·All Topics RSS
·Classic ASP RSS
·CSS RSS
·Databases RSS
·eBay/PayPal RSS
·General RSS
·Hardware RSS
·Web Security RSS
·Windows XP RSS

Search
 
Recent Entries
·Classic ASP Master Pages
·eBay encourage/force you to lose money on postage
·CAPCTHAs and alternatives
·Obtaining Image Properties in ASP Without a Component
·New Microsoft Hotmail good reason not to use Microsoft Explorer
·Why are most real estate agents so bad at selling online
·Classic ASP Title Case
·Does stopfax.com.au really stop junk faxes?
·SQL Injection Protection - b.js
·Unfair eBay fees for used cars

John's Technology Blog

CAPCTHAs and alternatives

Posted at: December 9, 2009
Related Topic(s): Web Security, Classic ASP

Click here for daily freebies, competitions, surveys and the best offers - OUTPOSTOFFERS.COM - Australia

CAPTCHAs and their alternatives

The basic purpose of a CAPTCHA (Completely Automatic Public Turing Test to Tell Computers and Humans Apart) is to prevent robots from submitting web forms. By displaying an image that cannot be “read” by a computer, only a human can submit the form successfully.

Most of the time CAPTCHAs are an irritation to legitimate users, and can also cause issues with accessibility unless an alternative audible version of the text or numbers in the CAPTCHA image is also available.

My technique for CAPTCHA in Classic ASP is an image only system which works like this:

When the form is displayed two random numbers are generated. One is used as the number that is generated into an image. The other random number is used as the name of a session variable which contains the first number. This second number is stored as a hidden form field (it doesn't matter that this second number can be easily read). I use a random session variable name so as not to cause problems if the user has multiple forms open, this way each should submit without any conflict. On form submit the script gets the hidden field value and then the value of this session variable and compares this with the user's input. If they don't match the user (or robot) is redirected back to the form and two new random numbers are generated so the process repeats.

A more simple but less effective system that prevents some robots but avoids irritation to legitimate users and accessibility problems is to use a system similar to the CAPTCHA system described above where a random number is generated and added as a hidden form field and also stored in a session variable. On form post the hidden form field value is compared with the session variable value and succeeds only if they match. This means that the form can only be submitted if the user or robot visited the web form page first and posts the random number. This prevents robots that just simulate a form post to a URL from succeeding but doesn't stop the robot if they are willing to retrieve the web form page each time they post a form.

An improvement to this system would be to use a JavaScript script to add the value to the hidden field. Again, this would be fairly easy for a robot to simulate but would mean that the robot would have to be written specifically for the site.

Creating an image or audible CAPTCHA is not possible for some websites, for example in Classic ASP it usually requires a third party server component (although it can be done without one). There are other alternatives.

* Instead of creating a random number you could generate a random mathematical question, for example:

What is five plus twenty-three?

* You could create a database of random questions and answers, for example:

Which is not a colour? Blue, green, apple, orange or black?

* You could show several photos of different objects and ask the visitor to pick which picture contains a certain object.

All of these techniques are easy to produce using a system similar to what I described near the beginning of this article.

* You could create a textbox and set it to display:none in CSS. A robot is likely to fill this field so you can void any form submissions where this textbox is not empty.

* Dynamically change the names of form fields and store their new names in a session variable.

View Comments (0) | Add Comment | Permalink

Newer | Latest | Older

Free automotive classifieds, reviews, etc

Car and motorcycle books and repair manuals

ASP Hosting and Domain Names

For cheap asp and asp.net hosting I recommend CrystalTech, for cheap .com domains Cheeky Domains, or for .com.au domains Name Scout.

[Oztion is an Australian auction website which offers no listing fees]