Module: Msf::Exploit::JSObfu

Included in:
Remote::BrowserExploitServer, Remote::FirefoxPrivilegeEscalation, Payload::Firefox
Defined in:
lib/msf/core/exploit/jsobfu.rb

Instance Method Summary collapse

Instance Method Details

#initialize(info = {}) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/msf/core/exploit/jsobfu.rb', line 8

def initialize(info={})
  super
  register_advanced_options([
    OptInt.new('JsObfuscate', [false, "Number of times to obfuscate JavaScript", 0]),
    OptString.new('JsIdentifiers', [false, "Identifiers to preserve for JsObfu"])
  ], Exploit::JSObfu)
end

#js_obfuscate(js, opts = {}) ⇒ ::Rex::Exploitation::JSObfu

Returns an JSObfu object. A wrapper of ::Rex::Exploitation::JSObfu.new(js).obfuscate

Parameters:

  • js (String)

    JavaScript code

  • opts (Hash) (defaults to: {})

    obfuscation options

    • :iterations [FixNum] Number of times to obfuscate

    • :preserved_identifiers [Array] An array of identifiers to preserve during obfuscation

Returns:

  • (::Rex::Exploitation::JSObfu)


25
26
27
28
29
30
31
32
33
34
35
# File 'lib/msf/core/exploit/jsobfu.rb', line 25

def js_obfuscate(js, opts={})
  iterations = (opts[:iterations] || datastore['JsObfuscate']).to_i
  identifiers = opts[:preserved_identifiers].blank? ? (datastore['JsIdentifiers'] || '').split(',') : opts[:preserved_identifiers]
  obfu = ::Rex::Exploitation::JSObfu.new(js)
  obfu_opts = {}
  obfu_opts.merge!(iterations: iterations)
  obfu_opts.merge!(preserved_identifiers: identifiers)

  obfu.obfuscate(obfu_opts)
  obfu
end