2013-10-22 02:02:01 +00:00
|
|
|
# -*- coding: binary -*-
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
module Rex
|
|
|
|
module Exploitation
|
|
|
|
module Js
|
|
|
|
|
|
|
|
#
|
|
|
|
# Provides networking functions in JavaScript
|
|
|
|
#
|
|
|
|
class Network
|
|
|
|
|
2013-11-02 19:52:50 +00:00
|
|
|
# @param [Hash] opts the options hash
|
|
|
|
# @option opts [Boolean] :obfuscate toggles js obfuscation. defaults to true.
|
2013-11-02 21:52:04 +00:00
|
|
|
# @option opts [Boolean] :inject_xhr_shim automatically stubs XHR to use ActiveXObject when needed.
|
2013-11-02 19:52:50 +00:00
|
|
|
# defaults to true.
|
|
|
|
# @return [String] javascript code to perform a synchronous ajax request to the remote
|
|
|
|
# and returns the response
|
|
|
|
def self.ajax_download(opts={})
|
|
|
|
should_obfuscate = opts.fetch(:obfuscate, true)
|
2013-10-22 02:02:01 +00:00
|
|
|
js = ::File.read(::File.join(Msf::Config.data_directory, "js", "network", "ajax_download.js"))
|
|
|
|
|
2013-11-02 19:52:50 +00:00
|
|
|
if should_obfuscate
|
|
|
|
js = ::Rex::Exploitation::ObfuscateJS.new(js,
|
|
|
|
{
|
|
|
|
'Symbols' => {
|
2013-11-02 21:46:33 +00:00
|
|
|
'Variables' => %w{ xmlHttp oArg }
|
2013-11-02 19:52:50 +00:00
|
|
|
}
|
2013-10-22 02:02:01 +00:00
|
|
|
}).obfuscate
|
2013-11-02 19:52:50 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
xhr_shim(opts) + js
|
2013-10-22 02:02:01 +00:00
|
|
|
end
|
|
|
|
|
2013-11-02 19:52:50 +00:00
|
|
|
# @param [Hash] opts the options hash
|
|
|
|
# @option opts [Boolean] :obfuscate toggles js obfuscation. defaults to true.
|
2013-11-02 21:52:04 +00:00
|
|
|
# @option opts [Boolean] :inject_xhr_shim automatically stubs XHR to use ActiveXObject when needed.
|
2013-11-02 19:52:50 +00:00
|
|
|
# defaults to true.
|
2014-03-04 23:01:53 +00:00
|
|
|
# @return [String] javascript code to perform a synchronous or asynchronous ajax request to
|
|
|
|
# the remote with the data specified.
|
2013-11-02 19:52:50 +00:00
|
|
|
def self.ajax_post(opts={})
|
|
|
|
should_obfuscate = opts.fetch(:obfuscate, true)
|
2013-11-02 21:46:33 +00:00
|
|
|
js = ::File.read(::File.join(Msf::Config.data_directory, "js", "network", "ajax_post.js"))
|
2013-10-31 18:55:22 +00:00
|
|
|
|
2013-11-02 19:52:50 +00:00
|
|
|
if should_obfuscate
|
2013-11-02 21:46:33 +00:00
|
|
|
js = ::Rex::Exploitation::ObfuscateJS.new(js,
|
2013-11-02 19:52:50 +00:00
|
|
|
{
|
|
|
|
'Symbols' => {
|
2014-03-04 23:01:53 +00:00
|
|
|
'Variables' => %w{ xmlHttp cb path data }
|
2013-11-02 19:52:50 +00:00
|
|
|
}
|
|
|
|
}).obfuscate
|
|
|
|
end
|
|
|
|
|
|
|
|
xhr_shim(opts) + js
|
|
|
|
end
|
2013-10-31 18:55:22 +00:00
|
|
|
|
2013-11-02 19:52:50 +00:00
|
|
|
# @param [Hash] opts the options hash
|
|
|
|
# @option opts [Boolean] :obfuscate toggles js obfuscation. defaults to true.
|
2013-11-02 21:52:04 +00:00
|
|
|
# @option opts [Boolean] :inject_xhr_shim false causes this method to return ''. defaults to true.
|
2013-11-02 19:52:50 +00:00
|
|
|
# @return [String] javascript code that adds XMLHttpRequest to the global scope if it
|
|
|
|
# does not exist (e.g. on IE6, where you have to use the ActiveXObject constructor)
|
|
|
|
def self.xhr_shim(opts={})
|
2013-11-02 21:52:04 +00:00
|
|
|
return '' unless opts.fetch(:inject_xhr_shim, true)
|
2013-11-02 19:52:50 +00:00
|
|
|
|
|
|
|
should_obfuscate = opts.fetch(:obfuscate, true)
|
|
|
|
js = ::File.read(::File.join(Msf::Config.data_directory, "js", "network", "xhr_shim.js"))
|
|
|
|
|
|
|
|
if should_obfuscate
|
2013-11-02 21:46:33 +00:00
|
|
|
js = ::Rex::Exploitation::ObfuscateJS.new(js,
|
2013-11-02 19:52:50 +00:00
|
|
|
{
|
|
|
|
'Symbols' => {
|
2013-11-02 21:46:33 +00:00
|
|
|
'Variables' => %w{ activeObjs idx }
|
2013-11-02 19:52:50 +00:00
|
|
|
}
|
2013-10-31 18:55:22 +00:00
|
|
|
}
|
2013-11-02 19:52:50 +00:00
|
|
|
).obfuscate
|
|
|
|
end
|
2013-11-02 21:46:33 +00:00
|
|
|
js
|
2013-10-31 18:55:22 +00:00
|
|
|
end
|
|
|
|
|
2013-10-22 02:02:01 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|