Thursday, September 19, 2013

Retrive password from Toad for Oracle

One of the oldest feature Toad has is saving login passwords. This is accomplish easy with enabling check box "Save passwords" on login screen. 
The whole connection process is defined through three files located in %USERPROFILE%\AppData\Roaming\Quest Software\Toad for Oracle\11.6\User Files\, where "11.6" is Toad version and may vary in your cases: 
  1. CONNECTIONS.INI
  2. CONNECTIONACTIONS.INI
  3. CONNECTIONPWDS.INI
Passwords are stored in encrypted way in CONNECTIONPWDS.INI file. However they are not exposed in any normal way (you can read them) but only to use them as login without knowing password, which was once placed. But having stored passwords allow Toad many beautiful automation and wide a lot actions that might need password as input. 

The solution

The trick is based on another Toad for Oracle feature-get SQL for any kind of DDL action, which was performed through GUI, in this case creating db link. Here is what you have to do to retrieve scott password:
  1. Choose Database|Create|DB Link menu item
  2. Fill the Link Name and Database data as shown in the picture:

  3. Click on 'Set user/Pass to current'
  4. As you can see I have chosen scott user and password is automatically retrieved from saved passwords file.
  5. Choose Show SQL as shown in the picture and you'll get pure SQL which contains password
The trick is working for every user's password. 

Someone might say this is security issue, but I think it is not! Mentioned file with stored passwords is encrypted with two keys:

  1. Domain user name
  2. Some kind of workstation unique hash value
These ensures that password file cannot be copied to another workstation and Domain admins (or other privileged users on that workstation) cannot use that file in any way!