Unhiding passwords masked behind asterisks
Scripts No Comments »Seen this field below before? Can't you remember what you used as a password, because it was saved and auto-completed by your browser?
It came to my attention that many people forget passwords from time to time. Blame our human nature. This post is especially for the forgetful between us.
Don't download an asterisk / password revealer yet, because you can do this without any software at all.
Using a simple javascript one-liner we can recover the lost password by displaying an alert for each password on the page.
Go ahead and try this code. It should display "asterisks" (or whatever you altered the password box with):
For those who are interested, I will dissect that line below:
First we can rewrite the same line as:
inputElements = document.body.getElementsByTagName("input");
for(i=0; i<inputElements.length; i++) {
try
{
if(f[i].getAttribute("type")=="password")
alert("Password: "+f[i].value)
} catch(e) {}
};
void(0);
We collect all input elements with the line inputElements = document.body.getElementsByTagName("input");
Next, we loop through all the elements using the for-statement.
That code is surrounded by a try/catch-block to avoid errors (which I experienced in IE).
If an input element has the password-type, an alert will show up with the element value.