Monday, April 20, 2009

Automating logins with KeePass's Auto-Type scripting and Firefox

First off, if you haven't been using a password database tool, I highly recommend using one. This forces you to stop using the same password for each account you have out on the Internet, and lets you keep the list centralized in an encrypted file. I highly recommend KeePass, as it is open-source and free.

I have enjoyed using KeePass to store my account information, but for logging into web pages I wanted it to be a more automated process, having it login for me instead of copying the URL, username, and password into the appropriate fields. I started playing with the Auto-Type feature within KeyPass, and after some tinkering I was able to login to my credit card company's interface. The way it works is you tell it which application to gain focus on, which URL to go to, and lastly to type in the username and password. An example Auto-Login script that logs me into my bank looks like this:

Note before proceeding: You must be have Firefox as your last focused window, otherwise your data will spill into another window.

In my example below, Auto-Type opens a new tab (^t) in Firefox, types in the URL ({URL}), hits enter ({ENTER}), gives the page some time to load ({DELAY 4000}), types in the username ({USERNAME}), tabs over to the password field ({TAB}), and lastly types in the password ({PASSWORD}).

Auto-Type: ^t{URL}{ENTER}{DELAY 4000}{USERNAME}{TAB}{PASSWORD}

Warning: If you do not have Firefox your last focused window, KeyPass will not know which window to gain focus on and most likely spill your details to your friend you're chatting with (or whatever window has focus). For this reason, I have left out having Auto-Type hit {ENTER} after my password, just for safety reasons. You've been warned!

For more information about Auto-Type, check out the KeyPass Auto-Type documentation.

No comments: