Pages

Monday, 15 October 2012

CAPTCHA Using Java Script

A CAPTCHA is a program that can generate and grade tests that humans can pass but current computer programs cannot. For example, humans can read distorted text as the one shown below, but current computer programs can't:The term CAPTCHA (for Completely Automated Public Turing Test To Tell Computers and Humans Apart) was coined in 2000 by Luis von Ahn, Manuel Blum, Nicholas Hopper and John Langford of Carnegie Mellon University. At the time, they developed the first CAPTCHA to be used by Yahoo.


Applications of CAPTCHAs

CAPTCHAs have several applications for practical security, including (but not limited to):
  • Preventing Comment Spam in Blogs. Most bloggers are familiar with programs that submit bogus comments, usually for the purpose of raising search engine ranks of some website (e.g., "buy penny stocks here"). This is called comment spam. By using a CAPTCHA, only humans can enter comments on a blog. There is no need to make users sign up before they enter a comment, and no legitimate comments are ever lost!
  • Protecting Website Registration. Several companies (Yahoo!, Microsoft, etc.) offer free email services. Up until a few years ago, most of these services suffered from a specific type of attack: "bots" that would sign up for thousands of email accounts every minute. The solution to this problem was to use CAPTCHAs to ensure that only humans obtain free accounts. In general, free services should be protected with a CAPTCHA in order to prevent abuse by automated programs.
  • Online Polls. In November 1999, http://www.slashdot.org released an online poll asking which was the best graduate school in computer science (a dangerous question to ask over the web!). As is the case with most online polls, IP addresses of voters were recorded in order to prevent single users from voting more than once. However, students at Carnegie Mellon found a way to stuff the ballots using programs that voted for CMU thousands of times. CMU's score started growing rapidly. The next day, students at MIT wrote their own program and the poll became a contest between voting "bots." MIT finished with 21,156 votes, Carnegie Mellon with 21,032 and every other school with less than 1,000. Can the result of any online poll be trusted? Not unless the poll ensures that only humans can vote.
  • Preventing Dictionary Attacks. CAPTCHAs can also be used to prevent dictionary attacks in password systems. The idea is simple: prevent a computer from being able to iterate through the entire space of passwords by requiring it to solve a CAPTCHA after a certain number of unsuccessful logins.
  • Search Engine Bots. It is sometimes desirable to keep webpages unindexed to prevent others from finding them easily. There is an html tag to prevent search engine bots from reading web pages. The tag, however, doesn't guarantee that bots won't read a web page; it only serves to say "no bots, please." Search engine bots, since they usually belong to large companies, respect web pages that don't want to allow them in. However, in order to truly guarantee that bots won't enter a web site, CAPTCHAs are needed.
  • Worms and Spam. CAPTCHAs also offer a plausible solution against email worms and spam: "I will only accept an email if I know there is a human behind the other computer." A few companies are already marketing this idea.
More

Implementation Captcha Using Java Script 
Here  I'm implement captcha using java script. My captcha will generate a random number and ask user for add it, if user provide right answer then page goes forward otherwise it'll show message try again.I have just print a message whether user result is wrong or right you can implement your login as you wish..


Controls :
  • 2 span 1 for hold captcha and other one for message
  • 1Text box
  • 1 Button
HTML Code :
<html >
<head>
    <title>Girfa : Captcha Demo</title>
    <script language="javascript">
        var x=0;
        var y=0;
        var z=0;
        function makecaptcha()
        {
            x=parseInt(Math.random()*10);
            y=parseInt(Math.random()*10);
            z=x+y;           
            s1.innerHTML=" " +x+" + " + y +" ";
        }
        function validatecaptcha()
        {       
            if(document.forms[0].Text1.value == z)
            {
                s2.innerHTML="Ok Implement your logic";
                s2.style.color='black';
            }
            else
            {
                s2.innerHTML="Try Again Wrong Result";
                s2.style.color='red';
                makecaptcha();
            }
        }
    </script>
</head>
<body onload="makecaptcha()">
   <form>
    <div>
    Enter Result : &nbsp;&nbsp;<span id="s1" style="background-color:Aqua;border:solid 1px blue;color:red;font-size:x-large"></span>
    &nbsp;&nbsp;
    <input type=text id="Text1" />&nbsp;&nbsp;
    <span id="s2"></span>
    <br /><br />

    <input type="button" value="Submit" onclick="validatecaptcha()" />
    </div>
    </form>
</body>
</html>

 

No comments:

Post a Comment