disable shift key at startup! (1 Viewer)

MeU&Us

Registered User.
Local time
Today, 09:00
Joined
Dec 28, 2008
Messages
31
hi
im developing database in access 2007. i need to bypass / disable the shift key at startup, thus not enabling the user to use the shift key and enable the navigation pane, default menu and access options.
i have gone through all the forum, searched a lot, tried AllowBypassKey2kTo2k7 solution, but im not able to get the result.
the solution given by ghudson in this forum shows no message box after password input, whether you input it correct or wrong.
the solution given by MadMaxx in this forum shows error number 2950.

im helpless...
can anyone help me pls!!!!!
 

MeU&Us

Registered User.
Local time
Today, 09:00
Joined
Dec 28, 2008
Messages
31
i have tried that too, no result, ........
 

spikepl

Eledittingent Beliped
Local time
Today, 07:00
Joined
Nov 3, 2010
Messages
6,142
OOps - it applies to .ADP only - my bad :(
 

Evagrius

Registered User.
Local time
Yesterday, 23:00
Joined
Jul 10, 2010
Messages
170
MeU&US - can you please post your solution. This is something I would like to do but I don't understand how to allow myself access once I disable the shift key. Thank you.
 

MeU&Us

Registered User.
Local time
Today, 09:00
Joined
Dec 28, 2008
Messages
31
i ll post it, but once you have disabled it, and you dont have any control to enable it again, you simply cant enable it, thats what i guess..... any ways i ll post it for you, ...im at work now...
 

Cowboy_BeBa

Registered User.
Local time
Today, 13:00
Joined
Nov 30, 2010
Messages
188
hey,

i recently had to do something very similar and i also managed to put in a backdoor allowing you to reenable it if a password is entered,

im a bit busy now but by tomorrow ill put together an example db that illustrates how its done (i would post my db, but its huge so wont upload here.... and to be honest the reason i went to greath lengths to disable and add a backdoor is because i didnt want anyone to see it), but ill make sure the example db is easy to follow
 

Cowboy_BeBa

Registered User.
Local time
Today, 13:00
Joined
Nov 30, 2010
Messages
188
just took a look at the code i used to see how long itd take me to create an example file, but it looks like thats not necesary, youll need to create a button to run this code. if you dont want the users to know about the button you can hide this code on the click event of a picture or a box or pretty much anything you can put on a form, the database i was designing had a password field on the main menu for admins to view more details than other staff, so i managed to create a master password (which only i know) that when entered shows the button, this was how i kept the button completely invisible to the client, but that idea only works if the db your building already has a password field

anyway whatever control you use youll need to name it "bDisableBypassKey" then on the click event copy the following code, change "PASSWORD" to whatever you want the password to be, once this code is run it should disable the bypasskey when an incorrect password is entered and enable it when the correct passwords entered

after you do this create a new module called Key and copy and paste the contents of the attached text file into it

test it out and let me know if it works

Private Sub bDisableBypassKey_Click()
On Error GoTo Err_bDisableBypassKey_Click
'This ensures the user is the programmer needing to disable the Bypass Key
Dim strInput As String
Dim strMsg As String
Beep
strMsg = "Do you want to enable the Bypass Key?" & vbCrLf & vbLf & _
"Please key the programmer's password to enable the Bypass Key."
strInput = InputBox(Prompt:=strMsg, title:="Disable Bypass Key Password")
If strInput = "PASSWORD" Then
SetProperties "AllowBypassKey", dbBoolean, True
Beep
MsgBox "The Bypass Key has been enabled."
Else
Beep
SetProperties "AllowBypassKey", dbBoolean, False
MsgBox "The Bypass Key has bee disabled"
Exit Sub
End If
Exit_bDisableBypassKey_Click:
Exit Sub
Err_bDisableBypassKey_Click:
MsgBox "bDisableBypassKey_Click", Err.Number, Err.Description
Resume Exit_bDisableBypassKey_Click
End Sub
 

Attachments

  • key module.txt
    780 bytes · Views: 1,351

NigelShaw

Registered User.
Local time
Today, 06:00
Joined
Jan 11, 2008
Messages
1,573
Hi,
did you know that database properties can be changed from a differnt access database? That means that even though you have the shiftBypassKey turned off, it can be turned back on without opening your database. Then, a simple turn on can allow access to everything..........

There is even a tool floating around on here that will allow this.

to combat, i added a few options which i will post late tonight. When the database is opening, it will look for a specific file in the database location. (The file is a text file uniquely named by me). When i add the text file, it means i purposely want to access the source code. If the txt file is NOT there, then the ShiftByPassKey is turned back on again. This means that even if the property has been turned off by another source, it will fix itself.

The thing is people are nosey and will try and get access. You have to cover yourself.

i also have another tool that acts like a facard. a backend database is placed in the db location along with a lot of other redundant files made up like FRhcom.dll, TrapWin.dll, WSCop.ocx. These all do nothing but sit in the file and shroud a hidden backend. When the front end opens for example, it will look for WScop.ocx & MyDb.accdb. If MyDb.accdb is found, the nthe program closed unexpectedly and a marker is set. If WSCop.ocx is found, it is renamed to MyDb.accdb so it can be accessed. When the program closes, it renames the MyDb.accdb back to WSCop.ocx. Its only purpose is to hide the DB file so prying eys cannot try and break in to it.

hth


nigel
 

Cowboy_BeBa

Registered User.
Local time
Today, 13:00
Joined
Nov 30, 2010
Messages
188
wouldnt that mean that someone could find and delete the file and turn the key back on?

kind of freaky that even though ive coded the bypass key with extra security and a password someone can still enable the key by creating another file... i guess its yet more proof that microsoft sucks when it comes to security
 

NigelShaw

Registered User.
Local time
Today, 06:00
Joined
Jan 11, 2008
Messages
1,573
Hi

No it's the other way round. Scenario

Someone tries to open the db
Db runs code on startup and checks for txt file
File not there so right click disable property set to true again even if someone has reset it externally.

The chances of someone guessing the name of your text file would be very slim especially if you named it like 48537932fhyfryn476fd.txt

If the file isn't there, the property is forced on.

I'll post a sample.


Cheers

Nigel
 

novtalath

Registered User.
Local time
Today, 06:00
Joined
Dec 30, 2008
Messages
19
@Nigel - yes. But where did you place the code for that check. Isn't the shift key to bypass ALL THE CODE?

I have followed your way of thinking as I think it is quite good solution to add extra security but even without that 'check file' it still allows bypass :/
 

NigelShaw

Registered User.
Local time
Today, 06:00
Joined
Jan 11, 2008
Messages
1,573
@Nigel - yes. But where did you place the code for that check. Isn't the shift key to bypass ALL THE CODE?

I have followed your way of thinking as I think it is quite good solution to add extra security but even without that 'check file' it still allows bypass :/

Yes the shift bypass in a way does bypass the code but you can still run conditions for example-

My code can if chosen, to check for runtime. If not runtime, bail. The same for the bypass. My sample will show how it works and I will comment the process to help you to understand.

Cheers

Nigel
 

NigelShaw

Registered User.
Local time
Today, 06:00
Joined
Jan 11, 2008
Messages
1,573
Hi,

right. Here is the code first-
Code:
Option Compare Database
Public Function RunAtStart()
'    KillIt
    DetermineByPass

End Function

Public Function KillIt() As Integer

    If SysCmd(SYSCMD_RUNTIME) = 0 Then
        MsgBox ("This Application cannot be opened directly with Microsoft Access," & vbCrLf & _
        "and can ONLY be opened with the desktop shortcut." & vbCrLf & vbCrLf & _
        "Please double click the shortcut on your desktop to open This Application." & vbCrLf & vbCrLf & _
        "This application will now close."), vbOKOnly, "My Application Name"
        Application.Quit
    End If
End Function

Public Function DetermineByPass()
    If Len(Dir(CurrentProject.Path & "\LetMeIn.txt")) = 0 Then
        SetStartupProperties (False)
    Else
        SetStartupProperties (True)
    End If
End Function

Public Sub SetStartupProperties(bolParameter As Boolean)

    ChangeProperty "StartupShowDBWindow", dbBoolean, bolParameter
    ChangeProperty "AllowBreakIntoCode", dbBoolean, bolParameter
    ChangeProperty "AllowSpecialKeys", dbBoolean, bolParameter
    ChangeProperty "AllowBypassKey", dbBoolean, bolParameter
    ChangeProperty "StartupShowStatusBar", dbBoolean, bolParameter
    ChangeProperty "AllowBuiltinToolbars", dbBoolean, bolParameter
    ChangeProperty "AllowFullMenus", dbBoolean, bolParameter
    ChangeProperty "AllowShortcutMenus", dbBoolean, bolParameter

End Sub

Public Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
    Dim dbs As Database, prp As Property
    Const conPropNotFoundError = 3270

    Set dbs = CurrentDb
    On Error GoTo Change_Err
    dbs.Properties(strPropName) = varPropValue
    ChangeProperty = True

Change_Bye:
    Exit Function

Change_Err:
    If Err = conPropNotFoundError Then  ' Property not found.
        Set prp = dbs.CreateProperty(strPropName, _
        varPropType, varPropValue)
        dbs.Properties.Append prp
        Resume Next
    Else
        ' Unknown error.
        ChangeProperty = False
        Resume Change_Bye
    End If
End Function

Process

1. Add an AutoExec and set it to RunCode - RunAtStart()
2. save everything and close the db
3. open the db and close it again to initiate the properties settings
4. when db opens even with shift button, the nav bars etc are not visible
5. close it and do it again. Even with right shift button, still not visible.
6. create a text file called "LetMeIn.txt"
7. put it in the same location as the db.
8. open the db and close it to re-initiate the properties
9. open the db and everything is visible.
10. remove the text file, open and close the db, re-open and all is gone

What happens.

you are correct in saying that the shift bypass will stop the code so the first thing we do is to set the properties to false. This is done by setting the Boolean call 'bolParameter'. To do this, call the function-
Code:
SetStartupProperties (False)
there is a function called 'SetStartupProperties(bolParameter As Boolean) which is the setter

The properties will stay hidden until such time that they are set to true and even then, the db has to be opened and closed and opened again. Sure, someone who knows exactly what they are doing will get around it as nothing is ever 100% secure but its a good preventative. you could always use the
Code:
SetStartupProperties (False)
in an Open form event if someone does get past the staller. This will at least reset the properties to false.
by placing the text file in the same location, the code will see it and allow the properties to be changed-
Code:
 If Len(Dir(CurrentProject.Path & "\LetMeIn.txt")) = 0 Then
        SetStartupProperties (False)
    Else
        SetStartupProperties (True)
    End If
once you have placed the text file in the same location, you will need to open, close and re-open the db to initiate the property rules.

i have added another routine here too called KillIT
if you uncomment it and then try to run the db from the actual file rather than from a shortcut, it will boot you out. I put this in to force the user to open via a shortcut as the shortcut can have commands attached like /R for runtime only. Its another good deterant.

Hope this is useful to you or anyone else who finds it. Remember to tip my scales or click the 'Thanks' button if it helps you out :)


Cheers


N
 

novtalath

Registered User.
Local time
Today, 06:00
Joined
Dec 30, 2008
Messages
19
Good stuff man. Thanks for that example :)
Thanks button used :D

Edit: Now when I look at it longer it is too simple to find the solution by yourself ;)

Edit 2: Just one remark I have to make. For me for some reason it didn't work at first (I love to use Option Explicit) so after quick struggle I had to change:

Code:
Dim prp as Property
into
Code:
Dim prp as DAO.Property
and it started to work. Thanks again. I will put that into good use :)
 
Last edited:

Users who are viewing this thread

Top Bottom