Skip to content

Commit 0e4fc48

Browse files
committed
Fix rapid7#9602, a little defensive programming
Check for a nil message and unnecessary auth failures while looping.
1 parent 95a0196 commit 0e4fc48

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/msf/core/exploit/fortinet.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,22 @@ def authenticate(service_name, username = 'Fortimanager_Access', password = nil)
2929
password || ''
3030
))
3131

32+
tried = false
33+
3234
loop do
3335
message = session.next_message
3436

37+
return false unless message
38+
3539
case message.type
3640
when USERAUTH_SUCCESS
3741
debug { 'Received SSH_MSG_USERAUTH_SUCCESS' }
3842
return true
3943
when USERAUTH_FAILURE
4044
debug { 'Received SSH_MSG_USERAUTH_FAILURE' }
45+
46+
break if tried
47+
4148
debug { 'Sending SSH_MSG_USERAUTH_REQUEST (keyboard-interactive)' }
4249

4350
send_message(userauth_request(
@@ -54,6 +61,8 @@ def authenticate(service_name, username = 'Fortimanager_Access', password = nil)
5461
'',
5562
''
5663
))
64+
65+
tried = true
5766
when USERAUTH_INFO_REQUEST
5867
debug { 'Received SSH_MSG_USERAUTH_INFO_REQUEST' }
5968

0 commit comments

Comments
 (0)