You are on page 1of 3

#$language = "VBScript"

#$interface = "1.0"
' Monte Tucker, 602-300-9665
' 10/30/2012
' This will run through all the passwords in the pwd array for each user in the
User array until one works or it runs out of passwords.
crt.Screen.Synchronous = True
vUser = Array(_
"user1",_
"user2",_
"user3",_
"user4")
vPass = Array(_
"password1",_
"password2",_
"password3",_
"password4")
pCount = 0
uCount = 0
Sub Main
crt.Screen.Synchronous = True
On Error Resume Next
'crt.Screen.Send VbCr
if objCurrentTab.Session.Connected = False then
crt.Session.Connect
end if
Do
uprompt = crt.Screen.WaitForStrings(">", "ssword:", "#", "gin:", "name:"
)
Select Case uprompt
Case 1 ' Found ">" (need to reissue 'enable' command).
crt.Screen.Send "en" & VbCr
Case 2 ' Found password prompt.
crt.Screen.Send vPass(pCount) & vbcr
' Increment counter so we send the next password if nece
ssary.
pCount = pCount + 1
If pCount > UBound(vPass) Then
' Sent all passwords in array and they all faile
d.
bAuthSuccess = False
Exit Do
End If
if objCurrentTab.Session.Connected = False then
crt.Session.Connect
end if
Case 3 ' Found "#" (password authentication was successful).
bAuthSuccess = True
Exit Do
Case 4 ' Found Login: prompt.
crt.Screen.Send vUser(uCount) & vbcr
' Increment counter so we send the next user if necessar
y.
uCount = uCount + 1
If uCount > UBound(vUser) Then

' Sent all users and passwords in array and they


all failed.
bAuthSuccess = False
Exit Do
End If
Case 5 ' Found Username: prompt.
crt.Screen.Send vUser(uCount) & vbcr
' Increment counter so we send the next user if necessar
y.
'

uCount = uCount + 1
Do
prompt = crt.Screen.WaitForStrings(">", "ssword:

", "#", "gin:", "name:")


Select Case prompt
Case 1 ' Found ">" (need to reissue 'ena
ble' command).
pwd = vPass(pCount)
crt.Screen.Send "en" & VbCr
'
he password I entered:" & vbcrlf &_
'
ount) & vbcrlf

Case 2 ' Found password prompt.


crt.Dialog.MessageBox "Here is t
vUser(uCount) & " / " & vPass(pC
crt.Screen.Send vPass(pCount) &

vbcr
' Increment counter so we send t
he next password if necessary.
pCount = pCount + 1
If pCount > UBound(vPass) Then
' Sent all passwords in
array and they all failed for that user.
bAuthSuccess = False
Exit Do
End If
if objCurrentTab.Session.Connect
ed = False then
crt.Session.Connect
end if
Case 3 ' Found "#" (password authenticat
ion was successful).
bAuthSuccess = True
user = vUser(uCount)
Exit Do
Case 4 ' Found Login: prompt.
crt.Screen.Send vUser(uCount) &
vbcr
Case 5 ' Found Username: prompt.
crt.Screen.Send vUser(uCount) &
vbcr
Case Else
End Select
Loop
uCount = uCount + 1
If uCount > UBound(vUser) Then

' Sent all users and passwords in array and they


all failed.
bAuthSuccess = False
Exit Do
End If
Case Else
crt.Dialog.MessageBox "Unhandled MatchIndex." &
vbcrlf &_
"You probably added a timeout or an addi
tional string " &_
"parameter to the WaitForStrings() call,
but forgot to " &_
"add code to handle that new case. Chec
k your code " &_
"and revise accordingly."
End Select
Loop
' Lets check to see if we successfully entered 'enable' mode.
If bAuthSuccess Then
crt.Dialog.MessageBox "Authentication was successful. Used vUser (uCount) an
d vPass(pCount)"
Else
crt.Dialog.MessageBox "Authentication was a failure."
End If
End Sub

You might also like