Password Question

I was sent an access database to work on.  But they told me there was a problem.  The database was on a standalone and was not setup for a password.

But now when you try to open up the database a window opens up asking for a password.  So obviously no one knows what the password is and the database can't be opened.

Is there a way around this, and how could a password accidently be setup?  Thanks for the help.
ecohouse2Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CareyMBilyeuCommented:
Copy and paste this code into a module and follow the directions. I am assuming that you are working on an Access 97 project, this won't work on Access 2000. (Yet)!!!

'--------------------------------------------------
'   basDatabasePassword
'
'   Get the database password of a Jet 3.0/3.5 database.
'
'   --------------------------
'   This code is provided for the express purpose of destorying the burgeoning
'   shareware industry of Jet 3.x/3.5x database password crackers. You should
'   keep in mind that it is still quite illegal to break into a database you have
'   no authorization to view. Please don't do anything that would cause me to
'   have less respect for you than for the lifeless souls who try to charge money
'   for code of this nature on a "per database" basis.
'
'   TO USE:
'   1) Create a new module in any VBA host like Access, Excel, or Visual Basic
'   2) Hit <Ctrl+G> to get to the debug window
'   3) Run the following line of code in the debug window (replacing c:\foo.mdb with
'           the full path/name to your database:
'
'               ? StPasswordOfStDatabase("c:\foo.mdb")
'
'   The function will return the Database Password to you.
'
'   --------------------------
'   Sample code to allow you to prove to yourself that the function
'   works (the following code can be run from the debug window).
'   Change the password from 01234567890123456789 to any
'   arbitrary value 1-20 characters in length:
'
'   Set dbe = CreateObject("dao.dbengine.35")
'   Set db = dbe.CreateDatabase("c:\temp35.mdb", ";LANGID=0x0409;CP=1252;COUNTRY=0")
'   db.NewPassword "", "01234567890123456789"
'   db.Close: Set db = Nothing: Set dbe = Nothing
'   Debug.Print StPasswordOfStDatabase("c:\temp35.mdb")
'   --------------------------
'
'   (c) 1998 Trigeminal Software, Inc. All Rights Reserved
'--------------------------------------------------
Option Compare Binary
Option Explicit

Public Function StPasswordOfStDatabase(stDatabase As String) As String
    Dim hFile As Integer
    Dim ich As Integer
    Dim stBuffer As String
    Dim rgbytRaw() As Byte
    Dim rgbytPassword() As Byte
    Dim rgbytNoPassword() As Byte
   
    ' Create the byte array with the 20 bytes that are present when there
    ' is no database password
    rgbytNoPassword = ChrB(134) & ChrB(251) & ChrB(236) & ChrB(55) & ChrB(93) & _
                                ChrB(68) & ChrB(156) & ChrB(250) & ChrB(198) & ChrB(94) & _
                                ChrB(40) & ChrB(230) & ChrB(19) & ChrB(182) & ChrB(138) & _
                                ChrB(96) & ChrB(84) & ChrB(148) & ChrB(123) & ChrB(54)
                               
    ' Grab the 20 bytes from the real file whose password
    ' we are supposed to retrieve
    hFile = FreeFile
    Open stDatabase For Binary As #hFile
    Seek #hFile, 66 + 1
    rgbytRaw = InputB(20, #hFile)
    Close #hFile
   
    ' Enough prep, lets get the password now.
    ReDim rgbytPassword(0 To 19)
    For ich = 0 To 19
        rgbytPassword(ich) = rgbytRaw(ich) Xor rgbytNoPassword(ich)
    Next ich

    ' Add a trailing Null so one will always be found, even if the password is 20
    ' characters. Then grab up to the first null we find and return the password
    stBuffer = StrConv(rgbytPassword, vbUnicode) & vbNullChar
    StPasswordOfStDatabase = Left$(stBuffer, InStr(1, stBuffer, vbNullChar, vbBinaryCompare) - 1)
End Function


0
JimMorganCommented:
It is so unusual for someone to actually set a password for the database as opposed to passwords for users.

This isn't something that would be done inadvertently.  Perhaps the DB is corrupted.  I'd try the repair within Access and if that didn't work, then JetComp.EXE before I went any further.

If the code brings up a password that seems to be pure garbage, then my reaction would be that it is severly corrupted.

Jim
0
ecohouse2Author Commented:
Carey,

When I tried to find out the password I entered the code in the debug like you said, but I keep getting an error message saying "Sub of function not defined".  What do I have to do to get around this.

Also I remember that there was some keystroke that could bypass the password window.  Of course I can't remember it.  But I have used it before.  Would you happen to know what that is?  

Thanks for the help.
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

CareyMBilyeuCommented:
In a new Access database, copy the code below.
________________________________________Option Compare Binary
Option Explicit

Public Function StPasswordOfStDatabase(stDatabase As String) As String
    Dim hFile As Integer
    Dim ich As Integer
    Dim stBuffer As String
    Dim rgbytRaw() As Byte
    Dim rgbytPassword() As Byte
    Dim rgbytNoPassword() As Byte
     
    ' Create the byte array with the 20 bytes that are present when there
    ' is no database password
    rgbytNoPassword = ChrB(134) & ChrB(251) & ChrB(236) & ChrB(55) & ChrB(93) & _
                                ChrB(68) & ChrB(156) & ChrB(250) & ChrB(198) & ChrB(94) & _
                                ChrB(40) & ChrB(230) & ChrB(19) & ChrB(182) & ChrB(138) & _
                                ChrB(96) & ChrB(84) & ChrB(148) & ChrB(123) & ChrB(54)
                                 
    ' Grab the 20 bytes from the real file whose password
    ' we are supposed to retrieve
    hFile = FreeFile
    Open stDatabase For Binary As #hFile
    Seek #hFile, 66 + 1
    rgbytRaw = InputB(20, #hFile)
    Close #hFile
     
    ' Enough prep, lets get the password now.
    ReDim rgbytPassword(0 To 19)
    For ich = 0 To 19
        rgbytPassword(ich) = rgbytRaw(ich) Xor rgbytNoPassword(ich)
    Next ich

    ' Add a trailing Null so one will always be found, even if the password is 20
    ' characters. Then grab up to the first null we find and return the password
    stBuffer = StrConv(rgbytPassword, vbUnicode) & vbNullChar
    StPasswordOfStDatabase = Left$(stBuffer, InStr(1, stBuffer, vbNullChar, vbBinaryCompare) - 1)
End Function
________________________________________

Bring up the immediate window (Control G) and type in the following line and then hit enter:

? StPasswordOfStDatabase("c:\YourDatebaseName.mdb")

Remember to put in the correct db path as well. This should work.
0
ecohouse2Author Commented:
Thanks once again for the help.  But the code locks up at this point:

   Open stDatabase For Binary As #hFile

I get an error message saying the path is not found.   So I put in a line of code like this:

stDatabase = (c:\.....) showing where the database is located and I then got an error message saying type mismatch.  Any ideas?
0
ecohouse2Author Commented:
After playing around a bit I was able to get a printout of the password.  But this is what it looked like in the debug window:

½½lk¨´@¥ÄÑNòš’ÊSÐ

I tried pasting this into the password field of the database in question and it didn't work.  

Do you have any idea what I need to do now to get this to work. I also want to thank you for all your help with this problem.
0
CareyMBilyeuCommented:
What version of Access are you using?

I am pretty sure that this is for Access 97 only.

Carey
0
ecohouse2Author Commented:
This is Access97.  Is it possible that the database could be corrupted then?
0
JimMorganCommented:
As I said a few days ago, it you get what looks like garbage data, then it appears that the database would be corrupted.  Corrupted in this case would mean that the pointers where all the data is stored does not match with the real data.

Try to repair and compact the DB from Access (no open databases).  Use Tool > Database Utilities > Repair & same thing but Compact.  If this doesn't work then get JetComp.EXE off Microsoft's site and try it.

Jim
0
JimMorganCommented:
I had another thought that the db might be encrypted so I passworded and encrypted a DB.  I was still able to get a valid password name from the DB with the code that Carey supplied.

Therefore, there is no doubt in my mind that if that code was used exactly, that the DB is corrupted.

Jim
0
ecohouse2Author Commented:
I also think that the database is corrupted.  

When I try to repair the database I get an error message "Unrecognized Database Format".

Which version of the jetcomp.exe should I download?
0
JimMorganCommented:
I didn't know that they had a new one out.  I use version 1.0.1526.0 date 5/5/98.  They may have another version for Access 2000.

About this time I would be asking my client to send me any backups they had before this one crashed.  I'm not sure that you will be even able to fix this with JetComp.

Jim
0
ecohouse2Author Commented:
Well unfortunately they of course didn't back it up even though it was a small database.  So I guess it's another lesson learned the hard way.

After trying all of these things nothing worked so the database is unfortunately corrupted.  But thanks for all the help.
0
JimMorganCommented:
Well Carey did provide the code to read the password and I provided the information that the database was probably corrupted.  We are unable to fix things beyond our control but we were able to at least give you the correct information so that you could arrive at a final determination.

Jim
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ecohouse2Author Commented:
I appreciate both your guys help.  People have to learn to back up their databases or these things will happen.
0
CareyMBilyeuCommented:
Ecohouse2; Sorry I couldn't be of more help, maybe next time.

Carey
0
JimMorganCommented:
Carey:

Seeing that ecohouse2 is new to EE, I'm sure that he did not know that he could have asked Customer Service to split the points.  Therefore, I am going to ask you a question and give you 50 points too.

Jim
0
ecohouse2Author Commented:
That's true about me not knowing about splitting the points.  Sorry about that.
0
JimMorganCommented:
Now you know.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.