Update js_obfuscate

bug/bundler_fix
sinn3r 2014-09-20 23:38:35 -05:00
parent a9420befa4
commit 9191af6241
2 changed files with 21 additions and 12 deletions

View File

@ -561,9 +561,10 @@ module Msf
# @param iteration [FixNum] number of times to obfuscate
# @return [::Rex::Exploitation::JSObfu]
#
def js_obfuscate(js, iteration)
def js_obfuscate(js, opts={})
iterations = (opts[:iterations] || datastore['JsObfuscate']).to_i
obfu = ::Rex::Exploitation::JSObfu.new(js)
obfu.obfuscate(:iterations=>iteration)
obfu.obfuscate(:iterations=>iterations)
obfu
end

View File

@ -303,38 +303,46 @@ describe Msf::Exploit::Remote::BrowserExploitServer do
%Q|alert("hello, world");|
end
let(:default_jsobfuscate) do
0
end
before do
subject.datastore['JsObfuscate'] = default_jsobfuscate
end
context 'when iteration is set' do
it 'returns a ::Rex::Exploitation::JSObfu object' do
iteration = 1
obj = server.js_obfuscate(js, iteration)
opts = {:iterations=>0}
obj = server.js_obfuscate(js, opts)
expect(obj).to be_kind_of(::Rex::Exploitation::JSObfu)
end
it 'does not obfuscate if iteration is 0' do
iteration = 0
obj = server.js_obfuscate(js, iteration)
opts = {:iterations=>0}
obj = server.js_obfuscate(js, opts)
expect(obj.to_s).to include js
end
it 'obfuscates if iteration is 1' do
iteration = 1
obj = server.js_obfuscate(js, iteration)
opts = {:iterations=>1}
obj = server.js_obfuscate(js, opts)
expect(obj.to_s).not_to include js
end
end
context 'when iteration is nil' do
let (:iteration) do
nil
let (:opts) do
{:iterations=>nil}
end
it 'should return a ::Rex::Exploitation::JSObfu object' do
obj = server.js_obfuscate(js, iteration)
obj = server.js_obfuscate(js, opts)
expect(obj).to be_kind_of(::Rex::Exploitation::JSObfu)
end
it 'should not obfuscate' do
obj = server.js_obfuscate(js, iteration)
obj = server.js_obfuscate(js, opts)
expect(obj.to_s).to include(js)
end
end