- Back to Home »
- Show Password Fields
Sunday, October 9, 2011
Show Password Fields
A simple Javascript bookmarklet shows password field values.
In form fields where a password is entered, it is usually obscured by asterisks or bullets to prevent someone from seeing what you type. This is a great feature but where a long password is being typed or a remembered password is filled in by the browser, you might want to actually see the actual password itself.
SHOW PASSWORD BOOKMARKLET
Here is a bookmarklet (a snippet of Javascript that can be pasted into the address bar of your web browser), that will show any passwords on a page that contain password form fields..
javascript: (function() { var s="", F=document.forms,j,f,i; for(j=0; j<f.length; ++j) { f = F[j]; for (i=0; i< f.length; ++i) { if(f[i].type && f[i].type.toLowerCase() == "password") s += f[i].value + "\n"; } } if (s) alert("Password fields:\n\n" + s); else alert("No password fields on this page."); } )();
Just paste the above javascript into the address bar of your browser and press Enter, or create a bookmarklet link with the javascript as the URL. On this page you’ll see the password for the mock sign on form below.
User Name: | |
Password: |
FORMATTED JAVASCRIPT CODE
If you’re interested in what is happening to make this work the formatted code is below.
Essentially, the variable F is set to the collection of forms on the page, which is looped through, examining every input field in each form testing if it’s of type “password.” If it is a “password” field, its value is appended to the string variable s. Once all the input fields in all the forms on the page have been sniffed, the string value is displayed in an alert.
javascript: (function() { var s="", F=document.forms,j,f,i; for(j=0; j<f.length; ++j) { f = F[j]; for (i=0; i< f.length; ++i) { if(f[i].type && f[i].type.toLowerCase() == "password") s += f[i].value + "\n"; } } if (s) alert("Password fields:\n\n" + s); else alert("No password fields on this page."); } )();
But Firefox already…
And yes, we know Firefox will show you passwords in the clear with Tools/Options/Security/Show Passwords.
This javascript, however, is easier to access if you have created a bookmarklet for it, plus it works in other browsers.