Giter Site home page Giter Site logo

motioncaptcha's Introduction

MotionCAPTCHA is a jQuery CAPTCHA plugin that requires users to sketch the shape they see in the canvas in order to submit a form.

At the moment, it's just a proof-of-concept, (no IE support) but the next releases will see progressive enhancement and the ability to use this in production environments as a serious CAPTCHA alternative.

Don't try to use MotionCAPTCHA v0.2 in production - watch and wait for the full release!

Update 22-08-11: For everyone who's been watching, my apologies for not updating you sooner. The response to MotionCATPCHA has been amazing, and I still have big plans for it, but work and other distractions got in the way - to everyone who still wants to see MotionCATPCHA become fully-fledged and being used on live sites and apps, watch out for a codesmash day in September (possibly the 10th!)

In the meantime, please try it out, suggest features and report bugs - if you want to help out turning this thing into a reality, fork away.

How It Works

In v1.0, the plugin will use progressive enhancement so that the form uses a standard server-side (e.g. PHP) CAPTCHA script, and then on page load, the plugin switches that for the MotionCAPTCHA canvas, only if the browser is grown up enough.

For now, here's how it works (if you need a step-by-step guide, there's a How-To below):

  • You manually disable your form, by emptying the form's action attribute, and placing its value in a hidden <input> with a specific ID. You should also put disabled="disabled" on the submit button, for added points.
  • You add a few HTML lines to your form to initialise the MotionCAPTCHA canvas, and add the plugin's scripts to your page.
  • The user draws the shape and, if it checks out, the plugin inserts the form's action into the <form> tag. The user can submit the form, happy days.

I know this is going to be unpopular in its current state, because you're making it impossible for people to submit the form without JavaScript or Canvas support - BUT, who gives a crap, it's fun. And in future, it'll degrade gracefully, etc etc.

Technology / Credits

The MotionCAPTCHA plugin combines one of the brushes ('Ribbon' - and a lot of the logic) from Mr Doob's Harmony canvas experiment, with gesture recognition algorithms and vector shapes based entirely on the $1 Unistroke Gesture Recognizer by Jacob O. Wobbrock, Ph.D. and Andrew D. Wilson, Ph.D., and the later Protractor algorithm improvement by Yang Li, Ph.D.

The idea originally came from Paul Irish's blog, where he combined the Ribbon brush and the Unistroke recognizer on the background of his site - you get a pretty special easter-egg if you draw a star. Great song.

In my book, all of these people are ace - I just borrowed from them and spliced their works into one unholy mess (actually it's fairly tidy, though I'm hoping people will suggest performance improvements.)

Quick Roadmap

v0.3

  • Try to fix up IE support via excanvas or similar library
  • Add a real functionality for a 'new shape' button (a shape-switcharoo method)

v1.0

  • a) Combine with a simple PHP CAPTCHA and server-side checking script, for progressive enhancement. By default, form is submitted with regular CAPTCHA. On page load, if browser supports JavaScript and HTML5 Canvas, regular CAPTCHA is switched for mighty MotionCAPTCHA, and that would be checked on the server instead.
  • b) See (a)

v1.1

  • Perform (or add option/scripts to perform) server-side validation of the vector shape drawn by the user. Thought this was in the roadmap already (thanks RobIII for pointing out!)

Changelog

v0.2

  • Added mobile support for current functionality. Should work in Android and iOS (iPhones/iPads) now.
  • A few speed improvements and code cleanups.

How To Use

  1. Add the plugin scripts: (I'm using jQuery 1.6 from the google API, but you could load it locally - and MotionCAPTCHA is supported down to jQuery 1.4):

     <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script>
     <script src="jquery.motionCaptcha.0.2.min.js"></script>
     <link href="jquery.motionCaptcha.0.2.css"></script>
    
  2. Code the form as usual, with a unique ID (eg. '#mycoolform') and set the form action to blank (or '#') - eg:

     <form action="#" id="mycoolform" method="[get/post]">
    
  3. Add this placeholder <div> element to your form (NB. use <fieldset>s if you need it to validate) containing the blank canvas:

     <div id="mc">
         <p>Please draw the shape in the box to submit the form:</p>
         <canvas id="mc-canvas"></canvas>
     </div>
    
  4. Disable the submit button, eg:

     <input type="submit" disabled="disabled" value="Submit Form" />
    
  5. Add a hidden input to the form, with the form action as its value. Give it either a unique id, or the id 'mc-action', like so:

     <input type="hidden" id="fairly-unique-id" value="submitform.php" />
    
  6. Call the plugin on the form element. If you used any other ID than 'mc-action' for the hidden input, you'll just need to pass it to the plugin, like this:

     $('#form-id').motioncaptcha({
         action: '#fairly-unique-id'
     });
     
     // Or, if you just used 'mc-action' as the hidden input's ID:
     $('#form-id').motioncaptcha();
    
  7. Other options are available (defaults are shown):

     $('#form-id').motioncaptcha({
         // Basics:
         action: '#mc-action',        // the ID of the input containing the form action
         divId: '#mc',                // if you use an ID other than '#mc' for the placeholder, pass it in here
         cssClass: '.mc-active',      // this CSS class is applied to the 'mc' div when the plugin is active
         canvasId: '#mc-canvas',      // the ID of the MotionCAPTCHA canvas element
         
         // An array of shape names that you want MotionCAPTCHA to use:
         shapes: ['triangle', 'x', 'rectangle', 'circle', 'check', 'caret', 'zigzag', 'arrow', 'leftbracket', 'rightbracket', 'v', 'delete', 'star', 'pigtail'],
         
         // These messages are displayed inside the canvas after a user finishes drawing:
         errorMsg: 'Please try again.',
         successMsg: 'Captcha passed!',
         
         // This message is displayed if the user's browser doesn't support canvas:
         noCanvasMsg: "Your browser doesn't support <canvas> - try Chrome, FF4, Safari or IE9."
         
         // This could be any HTML string (eg. '<label>Draw this shit yo:</label>'):
         label: '<p>Please draw the shape in the box to submit the form:</p>'
     });
    

motioncaptcha's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

motioncaptcha's Issues

Images are predefined and insufficient cardinality.

The Captcha has 16 static images to validate with. This is the same folly of many previous captcha systems.

Even if there were 10,000 images, the same issue would occur.

A simple check for which image is presented can be defeated by passing the correct data points, even when you reach your road map's v1.0

To give you some quick history on previously broken captchas, they basically MD5'd the image, and passed in the text. You could pay $50 to crack thousands of captchas, and keep spamming wherever you like as you please.

The same issue exists here, you can grep the source to find the image, and return with data that is known to validate..

Image not showing

The canvas is there but the image to draw is not showing up. I noticed on your demo, the background-position is overwritten and removed by the JS. But in my firebug, I see that the background-position is -9999px -9999px:

mc-canvas {

background-attachment: scroll;
background-clip: border-box;
background-color: #FFFFFF;
background-image: url("motionCaptcha-shapes.jpg") !important;
background-origin: padding-box;
background-position: -9999px -9999px;
background-repeat: no-repeat;
background-size: auto auto;
height: 154px;
width: 220px;

}

Add a "switch back to captcha" button.

I have friends who's dyslexia prevents them from following a line with their finger, nothing to do with training or intelligence, its a full blown bonafied disability and asking them to trace a line is pretty much an impossible task as it will take them a very very long time to do if even possible.

Its the only thing that comes to mind regarding these.

Specifying drawing direction

This may seem rather pedantic, but it would probably help if some text along the lines of "starting from the dot" was added to the caption for the drawing canvas.

For example, the new text could read "Please draw the shape in the box starting from the dot to submit the form:" or something like it.

Get rid of canvas dependency

I started hacking on a simple library for drawing lines with HTML + CSS 3 last night. IE support is possible, right now I'm struggling with the DXImageTransform.Microsoft.Matrix to get the rotation origin right.

It doesn't perform well on very large drawings (the DOM get's fairly large because of many DIV elements), but it could be a good fit for MotionCAPTCHA.

https://github.com/Prinzhorn/draw-line

Just asking

Last update is 6 years old, it works fine, it recognize good or bad schema, my questions are :

What is wrong with this motion captcha ? Lack of accessibility ? Not mobile friendly ?
Why isn't there more engagement with it? Technical issue that allows bots to pass anyway ?

Maybe it can't work.

Hi, there exists a problem, if we verify whether a user is human or bots in browser, bots can simply ignore the CAPTCHA and send packages the same as a human who passed the CAPTCHA.

optional defaults: is it "action" or "actionId" ?

seems like the default values ask for 'action' but the code in the JS file is looking for 'actionId' . So after the user successfully draws the right shape, the action parameter of the form can get changed.

with Android

Hi

When we use it with Android, and Magnify the canvas,
it does not work, I could not draw any line on canvas.
but if I go back 100% display , it work.
Do you have any reason ?

Kazu

Add server-side validation for drawn points

How is this going to stop anything other than “human spammers” (which are close to non-existent compared to spam-bots anyways)? Any decent bot will (in time) just retrieve the “hidden” URL and use it to post it’s spam to. It doesn’t care if it has to parse the action attribute or some other field to get the URL to post the data to.

If you want this to be of any use at all, you’ll need to send the strokes themselves (or a “fingerprint” or “hash” of them) to the server and let the server decide whether the captcha is passed or not.

I'm sorry. I like your idea and out-of-the-box thinking. But it's practical use (fight automated spam) is close to zero.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.