Click here to Skip to main content
Licence CPOL
First Posted 5 Oct 2006
Views 109,748
Downloads 8,262
Bookmarked 58 times

Retrieve SQL Server Password

By Rajneesh Noonia | 5 Oct 2006
This tool is used to retrieve the forgotten SQL Server Password and passwords of registered servers.
 
Part of The SQL Zone sponsored by
See Also
4 votes, 40.0%
1
1 vote, 10.0%
2
2 votes, 20.0%
3
1 vote, 10.0%
4
2 votes, 20.0%
5
2.83/5 - 10 votes
μ 2.83, σa 3.05 [?]
Sample Image - SQLServerPasswords.jpg

Introduction

This tool is used to retrieve the forgotten SQL Server Password. SQL Server creates the user's password hash, which is stored in the master database (sysxlogins).The user's password is converted to Unicode with the salt tacked on the end, and this is used to produce a hash with SHA 1. The same salt is added to the password when a user attempts to log in, and the resulting hash is compared to the one on record. If they match, access is granted. The hash is produced twice, against the case-sensitive password and again against the uppercase form. The uppercase 'version' is obviously a good deal easier to crack; and once we know it, finding the case-sensitive version is child's play. Indeed, there's little point in using case-sensitive passwords on your system if the crypto scheme is going to create hashes from the uppercase version, using the same salt, and then store them. Case-sensitive passwords are an improvement only so long as we're kept in the dark about their uppercase companions.
This uses Brute- force algorithm to attach SQL Server Password. Clearly Complex and long password may take few days to retrieve.

Registered Servers

Password and login ID of a registered SQL Server user in Enterprise Manager for SQL Server can be easily retrieved using SQL DMO (Distributed Management Object). Create file SQLPasswords.vbs and open it in Notepad. Add the following code and save it:

Dim pApplication
Set pApplication = CreateObject("SQLDMO.Application")
Call EnumGroups(pApplication.ServerGroups)

Sub EnumGroups(ByVal pGroups)
    Dim pServerGroup
    Dim pRegServer
    
    For Each pServerGroup In pGroups
        If pServerGroup.RegisteredServers.Count > 0 Then
     Msgbox "Group :" &  pServerGroup.Name
            For Each pRegServer In pServerGroup.RegisteredServers
                Msgbox "Name:" & pRegServer.Name
                Msgbox "Login:" & pRegServer.Login
                Msgbox "Password:" & pRegServer.Password
            Next
        End If
        If pServerGroup.ServerGroups.Count > 0 Then
            Call EnumGroups(pServerGroup.ServerGroups)
        End If
    Next
    
End Sub

Run the script and this will retrieve the passwords of registered servers using your account. If the 'Always prompt for login name and password' checkbox is not set when registering a SQL Server, the login ID and password is weakly encrypted and stored in the following registry key: HKEY_CURRENT_USER\SOFTWARE\Microsoft\MSSQLServer\SQLEW\Registered Server X.

Recommendations

To securely use SQL Server, Microsoft recommends using Windows Integrated Security. In Windows Integrated Security mode, passwords are never stored as your Windows Domain sign-on is used as the security identifier to the database server.

History

  • 5th October, 2006: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Rajneesh Noonia

Software Developer (Senior)

United Kingdom United Kingdom

Member
I am an Techinical Lead working with Seria India Ltd. (Previously Known as Xansa),Noida, India. I have worked with Microsoft Visual Basic 6.0 , SQL Server,COM ,WIN32 API. I have been playing with the .NET Framework since it was in beta but have been using it commercially since late 2004.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMy vote of 3 Pinmembermirajvsen2:18 28 Sep '11  
GeneralMy vote of 1 PinmemberM Saqib Ali22:50 4 Aug '11  
Generaloutput in some Korean language Pinmemberyrajudba1:06 27 Jul '11  
GeneralSQL Server Password Recovery Pinmemberjames84215:38 10 May '11  
GeneralRetrieve SQL Server Password Pinmemberyitiana1:11 1 Sep '10  
GeneralMy vote of 1 PinmemberMalleo0:40 7 Aug '10  
GeneralRe: My vote of 1 Pinmemberyitiana1:09 1 Sep '10  
GeneralNot know what file to use PinmemberMalleo0:39 7 Aug '10  
GeneralRe: Not know what file to use PinmemberGary Heath1:46 27 Jan '12  
GeneralRetrieve SQL Server Password Pinmemberyitiana1:08 21 Jul '10  
Generalnot working with sql server 2005 Pinmemberpokiri4:13 8 Nov '08  
GeneralDoes this work for SQL 7.0? My password from sysxlogins is only 34 chars long Pinmemberwsiler11:52 16 Apr '08  
GeneralNo connection at ALL PinmemberAWebDude6:50 20 Oct '06  
QuestionHow to create stong passwords PinmemberRajneesh Noonia23:15 15 Oct '06  
GeneralIts not that easy Pinmemberfbachan21:34 9 Oct '06  
GeneralRe: Its not that easy PinmemberRajneesh Noonia21:40 9 Oct '06  
GeneralRe: Its not that easy Pinmembernixze6:24 11 Jan '10  
GeneralA bit rich PinmemberDarka2:07 6 Oct '06  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web03 | 2.5.120210.1 | Last Updated 6 Oct 2006
Article Copyright 2006 by Rajneesh Noonia
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid