Update js_obfuscate
parent
a9420befa4
commit
9191af6241
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue