Wednesday 15 July 2015

How to extact passwords from Oracle Database

The below steps which are meant to extract the password of the users from the oracle database.

Please Note: All the password are in the encrypted formatted.
                     If you are master in cracking it, then let me know too :) really helpful for me as well.

Mainly this steps are helpful when you are performing the database refresh or cloning purpose.

It might happen that the password of the same user may differ in PROD and TEST ( We are using the Oracle recommended process to follow the same password policy in all environments but sometimes while in hurry you might give some different passwords) and after cloning the user may face "not able to login into db due to username and password not correct".

To make it more clarity ,what I will do is..

Consider golia123 is the password in PROD environment and khataid is the password in TEST Environment and while DB refresh everything in PROD is migrated to TEST along with user credentials.After refresh when you are trying to connect to TEST with your TEST username/password  it will say cann't able to login as the password got changed.
So after refresh you have to run the password script which you have extracted  from the TEST environament (before the refresh activity) otherwise some user will face credentials problem.

Here I am trying with one user...

1.Spooling out all the passwords to a text file

2. Will try to connect to the DB with the current username/password.(which is present in the spool file).

3. I will change the password( alter user username identified by newpassword(which is different from the password present in the spool file)) --> now password got differ.

4. Again try with old username/pwd --> it will say username and password are not authenticate.

5.Now will use the the spooled encypted password for that particular use and again try to login with old username and password ---> it will allow me to login into the database.

Step1.  Spooling out all the password of the user in database by using below commands.

--- All passwords of the users before the refresh from SIT env.


2. Here the password of khataid is khataid which is in encrypted format i.e "84BE8EC9BA845EC0"

( Remember  84BE8EC9BA845EC0 = khataid )



 3. Now I am going to change the password of the khatai as "golia123" (without double quotes) by logging into sys user.

      Consider the database refresh has done
---  After refresh the password got changed to golia123



4. Here I will trying to connect to the oracle DB by using old password and below is the results(of course I have changed the password of the user khataid) --> expected results as o/p.

--> Not able to log in because the password got changed after database refresh.



5. Again I will connected as sys user and will use the command "alter user KHATAID identified by values '84BE8EC9BA845EC0';   ---> remember this ??
 
--- After refresh again I have to run the script which I have spolled out before the db cloning to avoid the credentials problem.

 (the password is the encypted one and it is nothing but khataid(old pasword)



In above alter statement if you see, I haven't given alter user khataid identified by khataid....I have given the encrypted password which I spooled out. and it was automatically taken as "khataid"

By using the below command,you can extract the passwords.

select 'alter user '||name||' identified by values '''||password||''';' from user$;


Hope it will help you.....Enjoy :) :)







No comments:

Post a Comment