observances

web * programming * the higher end

Virtual Keyboard Login – Version wicked.evil [avoid screenshots]

Mon, 28th Jul, '08

Ok, so we had virtual keyboards for some time on login pages being served worldwide. In fact so long that we had this. So we have virtual keyboards here again, and some smartness, some.

Earlier in this blog we covered some crypt way to send passwords to the server from the browser, and thanks to the response, i feel motivated enough. Now we are onto making a virtual keyboard, and yeah, this is a proof-of-concept and you are free to take it to the moon alongwith you.

We are just going to blank out all buttons just before the user is going to click on one. Basically do a backgroundColor = fontColor on all buttons to make it difficult what is written on the buttons on mouseover and restore on mouseout. Normally a user figures out which button to click on and then positions the mouse on the button and clicks, so if the button is showing what is written on it, definitely some proof-of-concept program can take a snapshot of the web page to figure out which button was clicked on. We are just going to wipe the face of the button off. For some more fun, we are going to randomize the order of buttons at will by calling randomizekeys() and supplying the order of the keys as an argument. And yeah, the styling class is closely tied to the javascript functions, so keep that in mind while playing with styles or the javascript. So here we go[look at the onload handler in the body tag] …

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">

    <title>Virtual Login Panel</title>
    <style>
    .loginnumkey {
        background:#000;
        color:#FFF;
        padding:5px 0 5px 0;
        min-width:40px;
        font-size:16px;
        font-family:tahoma;
        margin:1px;
    }
    </style>
    <script>
    function randomizekeys(assigncode, numkeysclass)
    {
        var j = 0;
        var els = document.getElementsByTagName('input');
        var elsLen = els.length;
        var pattern = new RegExp('\\b'+numkeysclass+'\\b');
        for (var i = 0; i < elsLen; i++)
        {
            if ( pattern.test(els[i].className) && j < assigncode.length)
            {
                els[i].value = assigncode[j];
                j++;
            }
        }
    }
    function keysoff(numkeysclass)
    {
        var i = 0;
        var els = document.getElementsByTagName('input');
        var elsLen = els.length;
        var pattern = new RegExp('\\b'+numkeysclass+'\\b');
        for (i = 0; i < elsLen; i++)
        {
            if ( pattern.test(els[i].className) )
            {
                els[i].style.backgroundColor = '#FFF';
            }
        }
    }
    function keyson(numkeysclass)
    {
        var i = 0;
        var els = document.getElementsByTagName('input');
        var elsLen = els.length;
        var pattern = new RegExp('\\b'+numkeysclass+'\\b');
        for (i = 0; i < elsLen; i++)
        {
            if ( pattern.test(els[i].className) )
            {
                els[i].style.backgroundColor = '#000';
            }
        }
    }
    function clicknumkey(inputid, inputvalue)
    {
        document.getElementById(inputid).value =
		document.getElementById(inputid).value + inputvalue;
    }
    </script>
</head>

<body onload="javascript:randomizekeys('1095673824', 'loginnumkey');">

    <input type='text' id='passwordbox'>
    <br><br>
    <input type='button' id='lkey1' value='1' class='loginnumkey'
    onclick="javascript:clicknumkey('passwordbox', this.value);"
    onmouseover="javascript:keysoff('loginnumkey');"
    onmouseout="javascript:keyson('loginnumkey');">

    <input type='button' id='lkey2' value='2' class='loginnumkey'
    onclick="javascript:clicknumkey('passwordbox', this.value);"
    onmouseover="javascript:keysoff('loginnumkey');"
    onmouseout="javascript:keyson('loginnumkey');">

    <input type='button' id='lkey3' value='3' class='loginnumkey'
    onclick="javascript:clicknumkey('passwordbox', this.value);"
    onmouseover="javascript:keysoff('loginnumkey');"
    onmouseout="javascript:keyson('loginnumkey');">

    <br>

    <input type='button' id='lkey4' value='4' class='loginnumkey'
    onclick="javascript:clicknumkey('passwordbox', this.value);"
    onmouseover="javascript:keysoff('loginnumkey');"
    onmouseout="javascript:keyson('loginnumkey');">

    <input type='button' id='lkey5' value='5' class='loginnumkey'
    onclick="javascript:clicknumkey('passwordbox', this.value);"
    onmouseover="javascript:keysoff('loginnumkey');"
    onmouseout="javascript:keyson('loginnumkey');">

    <input type='button' id='lkey6' value='6' class='loginnumkey'
    onclick="javascript:clicknumkey('passwordbox', this.value);"
    onmouseover="javascript:keysoff('loginnumkey');"
    onmouseout="javascript:keyson('loginnumkey');">

    <br>

    <input type='button' id='lkey7' value='7' class='loginnumkey'
    onclick="javascript:clicknumkey('passwordbox', this.value);"
    onmouseover="javascript:keysoff('loginnumkey');"
    onmouseout="javascript:keyson('loginnumkey');">

    <input type='button' id='lkey8' value='8' class='loginnumkey'
    onclick="javascript:clicknumkey('passwordbox', this.value);"
    onmouseover="javascript:keysoff('loginnumkey');"
    onmouseout="javascript:keyson('loginnumkey');">

    <input type='button' id='lkey9' value='9' class='loginnumkey'
    onclick="javascript:clicknumkey('passwordbox', this.value);"
    onmouseover="javascript:keysoff('loginnumkey');"
    onmouseout="javascript:keyson('loginnumkey');">

    <br>

    <input type='button' id='lkey0' value='0' class='loginnumkey'
    onclick="javascript:clicknumkey('passwordbox', this.value);"
    onmouseover="javascript:keysoff('loginnumkey');"
    onmouseout="javascript:keyson('loginnumkey');">

    <input type='button' id='lkeyclear' value='reset' class='loginnumkey'
    onclick="javascript:document.getElementById('passwordbox').value='';"
    onmouseover="javascript:keysoff('loginnumkey');"
    onmouseout="javascript:keyson('loginnumkey');">

</body>

</html>

This may not work in IE, I mean this code snippet. If you want to make it work, just fiddle with i, j declarations in the function randomizekeys(), like moving them around in the function.

Posted by krahulg
Filed in Experiment, This Works
Tags: Javascript, login, secure, virtual keyboard
Leave a Comment »

  • Kumar Rahul's Facebook profile
    View kumar rahul ghosh's profile on LinkedIn

  • Blog Hotness

    • 14,325 cool/hot people have been here

  • Add to Technorati Favorites
    add to del.icio.us Add to Blinkslist add to furl Digg it add to ma.gnolia Stumble It! add to simpy seed the vine TailRank


  • Pressed Just Now

    • Web 2.0: The birth of Social Media and You
    • Why are all the tectonic faults vertical??
    • Virtual Keyboard Login – Version wicked.evil [avoid screenshots]
    • Social Networking Websites – Revenue Models
    • Animate this …
    • Walking the HTML DOM tree in PHP
    • Search Friendly URLs or No-Question-Marks-Or-Equals URLs
    • Add content dynamically as you reach end of page with AJAX
    • Preparing a secure login form with PHP & JavaScript
    • How long do your users stay on a page??
  • Top Posts

    • Walking the HTML DOM tree in PHP
    • Social Networking Websites - Revenue Models
    • Preparing a secure login form with PHP & JavaScript
    • Search Friendly URLs or No-Question-Marks-Or-Equals URLs
    • Virtual Keyboard Login - Version wicked.evil [avoid screenshots]
    • How long do your users stay on a page??
    • Add content dynamically as you reach end of page with AJAX
  • You said ...

    MiKu on Social Networking Websites …
    tw on Social Networking Websites …
    How to Get Six Pack … on Social Networking Websites …
    Thorix » Siche… on Preparing a secure login form …
    Stefan Wagner on Walking the HTML DOM tree in…
    Stefan Wagner on Walking the HTML DOM tree in…
    Stefan Wagner on Walking the HTML DOM tree in…
    krahulg on Walking the HTML DOM tree in…
    Melvin J. on Walking the HTML DOM tree in…
    krahulg on Automatic Javascript Bug Repor…
  • My Blog-O-Sphere

    • Big Money List
    • Chris Shiflett’s Blog
    • Position Is Everything
  • tags

    adsense ajax animate apache automatic browser Document Object Model DOM dynamic earthquakes error friendly urls hash htaccess Javascript login MATLAB md5 micro-payments mod_rewrite monetizing monitoring page optimization php prototype question reporting revenue models revenue sharing scriptaculous scroll secure security seismic activity seo settimeout sniff social networking tectonic faults tectonic plates timer url rewriting virtual keyboard web 1.0 web 2.0
  • Events I am attending


Theme: Simpla by Phu. Blog at WordPress.com.