@@ -55,41 +55,45 @@ def attempt_login(credential)
55
55
service_name : 'telnet'
56
56
}
57
57
58
- if connect_reset_safe == :refused
59
- result_options [ :status ] = Metasploit ::Model ::Login ::Status ::UNABLE_TO_CONNECT
60
- else
61
- if busy_message?
62
- self . sock . close unless self . sock . closed?
58
+ begin
59
+ if connect_reset_safe == :refused
63
60
result_options [ :status ] = Metasploit ::Model ::Login ::Status ::UNABLE_TO_CONNECT
64
- end
65
- end
66
-
67
- unless result_options [ :status ]
68
- unless password_prompt?
69
- send_user ( credential . public )
70
- end
71
-
72
- recvd_sample = @recvd . dup
73
- # Allow for slow echos
74
- 1 . upto ( 10 ) do
75
- recv_telnet ( self . sock , 0.10 ) unless @recvd . nil? or @recvd [ /#{ @password_prompt } / ]
61
+ else
62
+ if busy_message?
63
+ self . sock . close unless self . sock . closed?
64
+ result_options [ :status ] = Metasploit ::Model ::Login ::Status ::UNABLE_TO_CONNECT
65
+ end
76
66
end
77
67
78
- if password_prompt? ( credential . public )
79
- send_pass ( credential . private )
68
+ unless result_options [ :status ]
69
+ unless password_prompt?
70
+ send_user ( credential . public )
71
+ end
80
72
73
+ recvd_sample = @recvd . dup
81
74
# Allow for slow echos
82
75
1 . upto ( 10 ) do
83
- recv_telnet ( self . sock , 0.10 ) if @recvd == recvd_sample
76
+ recv_telnet ( self . sock , 0.10 ) unless @recvd . nil? or @recvd [ / #{ @password_prompt } / ]
84
77
end
85
- end
86
78
87
- if login_succeeded?
88
- result_options [ :status ] = Metasploit ::Model ::Login ::Status ::SUCCESSFUL
89
- else
90
- result_options [ :status ] = Metasploit ::Model ::Login ::Status ::INCORRECT
91
- end
79
+ if password_prompt? ( credential . public )
80
+ send_pass ( credential . private )
81
+
82
+ # Allow for slow echos
83
+ 1 . upto ( 10 ) do
84
+ recv_telnet ( self . sock , 0.10 ) if @recvd == recvd_sample
85
+ end
86
+ end
92
87
88
+ if login_succeeded?
89
+ result_options [ :status ] = Metasploit ::Model ::Login ::Status ::SUCCESSFUL
90
+ else
91
+ result_options [ :status ] = Metasploit ::Model ::Login ::Status ::INCORRECT
92
+ end
93
+
94
+ end
95
+ rescue ::EOFError , Errno ::ECONNRESET , Rex ::AddressInUse , Rex ::ConnectionError , Rex ::ConnectionTimeout , ::Timeout ::Error
96
+ result_options [ :status ] = Metasploit ::Model ::Login ::Status ::UNABLE_TO_CONNECT
93
97
end
94
98
95
99
::Metasploit ::Framework ::LoginScanner ::Result . new ( result_options )
0 commit comments