## https://sploitus.com/exploit?id=KITPLOIT:TOOLS-GITHUB-SKYTINA-CVE-2021-21978
# CVE-2021-21978
Versione con echo dello script di exploit, metodo più semplice
## 0\. Informazioni sulla vulnerabilitÃ
> L'interfaccia di amministrazione web di VMware View Planner ha un punto di ingresso per caricare file di log, senza autenticazione e il percorso del file di log scritto è controllabile dall'utente. Sovrascrivendo il file di log `log_upload_wsgi.py` caricato, è possibile ottenere RCE.
Codice della vulnerabilità :
root@kitploit:~
def application(environ, start_response):
logger.debug("application called")
if environ['REQUEST_METHOD'] == 'POST':
post = cgi.FieldStorage(
fp=environ['wsgi.input'],
environ=environ,
keep_blank_values=True
)
# TO DO: Puth path in some config or read from config is already available
resultBasePath = "/etc/httpd/html/vpresults"
try:
filedata = post["logfile"]
metaData = post["logMetaData"]
if metaData.value:
logFileJson = LogFileJson.from_json(metaData.value)
if not os.path.exists(os.path.join(resultBasePath, logFileJson.itrLogPath)):
os.makedirs(os.path.join(resultBasePath, logFileJson.itrLogPath))
if filedata.file:
if (logFileJson.logFileType == agentlogFileType.WORKLOAD_ZIP_LOG):
filePath = os.path.join(resultBasePath, logFileJson.itrLogPath, WORKLOAD_LOG_ZIP_ARCHIVE_FILE_NAME.format(str(logFileJson.workloadID)))
else:
filePath = os.path.join(resultBasePath, logFileJson.itrLogPath, logFileJson.logFileType)
with open(filePath, 'wb') as output_file:
while True:
data = filedata.file.read(1024)
# End of file
if not data:
break
output_file.write(data)