Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Forgotten ACCESS Database Password 3

Status
Not open for further replies.

Mross

MIS
Mar 31, 2000
3
0
0
US
User has changed database password and can't remember - How can I get around this???? - (TOOLS-DATABASE UTILITIES-SECURITY-SET DATABASE PASSWORD) is how security was set.
 
If you use the Search tab in this forum you will find rhicks' link to some code for Access97.
 
Use the following code:<br><br>Option Compare Binary<br>Option Explicit<br><br>'Attribute VB_Name = &quot;basDatabasePassword&quot;<br>'--------------------------------------------------<br>'&nbsp;&nbsp;&nbsp;basDatabasePassword<br>'<br>'&nbsp;&nbsp;&nbsp;Get the database password of a Jet 3.0/3.5 database.<br>'<br>'&nbsp;&nbsp;&nbsp;--------------------------<br>'&nbsp;&nbsp;&nbsp;This code is provided for the express purpose of destorying the burgeoning<br>'&nbsp;&nbsp;&nbsp;shareware industry of Jet 3.x/3.5x database password crackers. You should<br>'&nbsp;&nbsp;&nbsp;keep in mind that it is still quite illegal to break into a database you have<br>'&nbsp;&nbsp;&nbsp;no authorization to view. Please don't do anything that would cause me to<br>'&nbsp;&nbsp;&nbsp;have less respect for you than for the lifeless souls who try to charge money<br>'&nbsp;&nbsp;&nbsp;for code of this nature on a &quot;per database&quot; basis.<br>'<br>'&nbsp;&nbsp;&nbsp;THIS DOES NOT WORK FOR AN ACCESS 2000 DATABASE OR JET 4.0+.<br>'<br>'&nbsp;&nbsp;&nbsp;TO USE:<br>'&nbsp;&nbsp;&nbsp;1) Create a new module in any VBA host like Access, Excel, or Visual Basic<br>'&nbsp;&nbsp;&nbsp;2) Hit &lt;Ctrl+G&gt; to get to the debug window<br>'&nbsp;&nbsp;&nbsp;3) Run the following line of code in the debug window (replacing c:\foo.mdb with<br>'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;the full path/name to your database:<br>'<br>'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;? StPasswordOfStDatabase(&quot;c:\foo.mdb&quot;)<br>'<br>'&nbsp;&nbsp;&nbsp;The function will return the Database Password to you.<br>'<br>'&nbsp;&nbsp;&nbsp;--------------------------<br>'&nbsp;&nbsp;&nbsp;Sample code to allow you to prove to yourself that the function<br>'&nbsp;&nbsp;&nbsp;works (the following code can be run from the debug window).<br>'&nbsp;&nbsp;&nbsp;Change the password from 01234567890123456789 to any<br>'&nbsp;&nbsp;&nbsp;arbitrary value 1-20 characters in length:<br>'<br>'&nbsp;&nbsp;&nbsp;Set dbe = CreateObject(&quot;dao.dbengine.35&quot;)<br>'&nbsp;&nbsp;&nbsp;Set db = dbe.CreateDatabase(&quot;c:\temp35.mdb&quot;, &quot;;LANGID=0x0409;CP=1252;COUNTRY=0&quot;)<br>'&nbsp;&nbsp;&nbsp;db.NewPassword &quot;&quot;, &quot;01234567890123456789&quot;<br>'&nbsp;&nbsp;&nbsp;db.Close: Set db = Nothing: Set dbe = Nothing<br>'&nbsp;&nbsp;&nbsp;Debug.Print StPasswordOfStDatabase(&quot;c:\temp35.mdb&quot;)<br>'&nbsp;&nbsp;&nbsp;--------------------------<br>'<br>'&nbsp;&nbsp;&nbsp;(c) 1998 Trigeminal Software, Inc. All Rights Reserved<br>'--------------------------------------------------<br><br>Public Function StPasswordOfStDatabase(stDatabase As String) As String<br>&nbsp;&nbsp;&nbsp;&nbsp;Dim hFile As Integer<br>&nbsp;&nbsp;&nbsp;&nbsp;Dim ich As Integer<br>&nbsp;&nbsp;&nbsp;&nbsp;Dim stBuffer As String<br>&nbsp;&nbsp;&nbsp;&nbsp;Dim rgbytRaw() As Byte<br>&nbsp;&nbsp;&nbsp;&nbsp;Dim rgbytPassword() As Byte<br>&nbsp;&nbsp;&nbsp;&nbsp;Dim rgbytNoPassword() As Byte<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;' Create the byte array with the 20 bytes that are present when there<br>&nbsp;&nbsp;&nbsp;&nbsp;' is no database password<br>&nbsp;&nbsp;&nbsp;&nbsp;rgbytNoPassword = ChrB(134) & ChrB(251) & ChrB(236) & ChrB(55) & ChrB(93) & _<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ChrB(68) & ChrB(156) & ChrB(250) & ChrB(198) & ChrB(94) & _<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ChrB(40) & ChrB(230) & ChrB(19) & ChrB(182) & ChrB(138) & _<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ChrB(96) & ChrB(84) & ChrB(148) & ChrB(123) & ChrB(54)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;' Grab the 20 bytes from the real file whose password<br>&nbsp;&nbsp;&nbsp;&nbsp;' we are supposed to retrieve<br>&nbsp;&nbsp;&nbsp;&nbsp;hFile = FreeFile<br>&nbsp;&nbsp;&nbsp;&nbsp;Open stDatabase For Binary As #hFile<br>&nbsp;&nbsp;&nbsp;&nbsp;Seek #hFile, 66 + 1<br>&nbsp;&nbsp;&nbsp;&nbsp;rgbytRaw = InputB(20, #hFile)<br>&nbsp;&nbsp;&nbsp;&nbsp;Close #hFile<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;' Enough prep, lets get the password now.<br>&nbsp;&nbsp;&nbsp;&nbsp;ReDim rgbytPassword(0 To 19)<br>&nbsp;&nbsp;&nbsp;&nbsp;For ich = 0 To 19<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rgbytPassword(ich) = rgbytRaw(ich) Xor rgbytNoPassword(ich)<br>&nbsp;&nbsp;&nbsp;&nbsp;Next ich<br><br>&nbsp;&nbsp;&nbsp;&nbsp;' Add a trailing Null so one will always be found, even if the password is 20<br>&nbsp;&nbsp;&nbsp;&nbsp;' characters. Then grab up to the first null we find and return the password<br>&nbsp;&nbsp;&nbsp;&nbsp;stBuffer = StrConv(rgbytPassword, vbUnicode) & vbNullChar<br>&nbsp;&nbsp;&nbsp;&nbsp;StPasswordOfStDatabase = Left$(stBuffer, InStr(1, stBuffer, vbNullChar, vbBinaryCompare) - 1)<br>End Function<br><br>Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top