2014-09-21 00:39:04 -05:00
|
|
|
# -*- coding: binary -*-
|
|
|
|
|
|
|
|
|
|
require 'rex/exploitation/jsobfu'
|
|
|
|
|
|
|
|
|
|
module Msf
|
|
|
|
|
module Exploit::JSObfu
|
|
|
|
|
|
|
|
|
|
def initialize(info={})
|
|
|
|
|
super
|
|
|
|
|
register_advanced_options([
|
2016-01-28 14:36:42 -06:00
|
|
|
OptInt.new('JsObfuscate', [false, "Number of times to obfuscate JavaScript", 0]),
|
2016-01-28 15:18:25 -06:00
|
|
|
OptString.new('JsIdentifiers', [false, "Identifiers to preserve for JsObfu"])
|
2014-09-21 00:39:04 -05:00
|
|
|
], Exploit::JSObfu)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Returns an JSObfu object. A wrapper of ::Rex::Exploitation::JSObfu.new(js).obfuscate
|
|
|
|
|
#
|
|
|
|
|
# @param js [String] JavaScript code
|
|
|
|
|
# @param opts [Hash] obfuscation options
|
|
|
|
|
# * :iterations [FixNum] Number of times to obfuscate
|
2016-01-28 14:36:42 -06:00
|
|
|
# * :preserved_identifiers [Array] An array of identifiers to preserve during obfuscation
|
2014-09-21 00:39:04 -05:00
|
|
|
# @return [::Rex::Exploitation::JSObfu]
|
|
|
|
|
#
|
|
|
|
|
def js_obfuscate(js, opts={})
|
|
|
|
|
iterations = (opts[:iterations] || datastore['JsObfuscate']).to_i
|
2016-02-02 11:25:39 -06:00
|
|
|
identifiers = opts[:preserved_identifiers].blank? ? (datastore['JsIdentifiers'] || '').split(',') : opts[:preserved_identifiers]
|
2014-09-21 00:39:04 -05:00
|
|
|
obfu = ::Rex::Exploitation::JSObfu.new(js)
|
2016-01-28 14:36:42 -06:00
|
|
|
obfu_opts = {}
|
|
|
|
|
obfu_opts.merge!(iterations: iterations)
|
|
|
|
|
obfu_opts.merge!(preserved_identifiers: identifiers)
|
|
|
|
|
|
|
|
|
|
obfu.obfuscate(obfu_opts)
|
2014-09-21 00:39:04 -05:00
|
|
|
obfu
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
2016-01-28 14:36:42 -06:00
|
|
|
end
|