Backdoor routine
Posted by Richie on July 24, 2001 12:13 PM
Hi everybody,
I'm writing a routine that will enable selected users to gain access to a program after a number of options have been disabled on start-up, eg the Alt+F11 shortcut to the VBE. (The routine is copied from a Web page - Nathan's Excel Page I think).
What I would like to do is to display in a message box the number of incorrect password attempts made by a user. The problem I am having is that 'attempts' never seems to progress beyond 1. Any ideas? (Sample code follows)
'
' Open the backdoor!
'
' Actions to take place following a keystroke combination of
' ALT+CTRL+SHIFT+ENTER
'
Sub Backdoor()
Application.ScreenUpdating = False
SystemPassword = "letmein"
Message = "Enter the password." ' Set prompt.
Title = "Password verification." ' Set title.
Default = "***" ' Set default.
' Display message, title, and default value.
' Display dialog box at position x, y.
PasswordEntry = InputBox _
(Message, Title, Default, 3500, 2000)
' no password entered
If PasswordEntry = "" Then
Beep
MsgBox "You have not entered a Password." & _
Chr$(10) & Chr$(10) & _
"Please try again.", vbOKOnly + vbCritical, _
"Error - No Password Entered."
End
' incorrect password entered
ElseIf PasswordEntry <> SystemPassword Then
Attempts = Attempts + 1
Beep
MsgBox "You have entered an incorrect Password." & _
Chr$(10) & Chr$(10) & _
"Incorrect attempts so far: " & Attempts _
& Chr$(10), _
vbOKOnly + vbCritical, _
"Error - Incorrect Password."
End
End If
' correct password entered
MsgBox "System Backdoor Successfully Opened.", _
vbOKOnly, "System Development."
Attempts = 0 ' clear incorrect attempts
Application.OnKey "%{F11}" ' re-enable VBE key combo
End Sub