parent
00ad6afd4f
commit
2d8d876eaa
|
@ -44,22 +44,16 @@ RSpec.describe Msf::Exploit::Remote::BrowserAutopwn2 do
|
|||
note
|
||||
end
|
||||
|
||||
def mock_stop_job(arg)
|
||||
framework = double('Msf::Framework', datastore: {})
|
||||
jobs = subject.framework.jobs.delete_if {|e| e.first == arg.to_s}
|
||||
allow(jobs).to receive(:stop_job) { |arg| mock_stop_job(arg) }
|
||||
allow(framework).to receive(:jobs).and_return(jobs)
|
||||
allow(subject).to receive(:framework).and_return(framework)
|
||||
end
|
||||
|
||||
def create_fake_job(id)
|
||||
ctx = double('ctx')
|
||||
handler = create_fake_windows_meterpreter
|
||||
allow(ctx).to receive(:first).and_return(handler)
|
||||
job = [id.to_s, double('job')]
|
||||
allow(job).to receive(:ctx).and_return(ctx)
|
||||
|
||||
job
|
||||
instance_double(
|
||||
Rex::Job,
|
||||
ctx: double(
|
||||
'ctx',
|
||||
first: create_fake_windows_meterpreter
|
||||
),
|
||||
jid: id,
|
||||
stop: nil
|
||||
)
|
||||
end
|
||||
|
||||
def create_fake_exploit(opts={})
|
||||
|
@ -75,6 +69,7 @@ RSpec.describe Msf::Exploit::Remote::BrowserAutopwn2 do
|
|||
|
||||
mod = Msf::Exploit.new
|
||||
mod.extend(Msf::Exploit::Remote::BrowserExploitServer)
|
||||
mod.extend(Msf::Simple::Exploit)
|
||||
|
||||
allow(mod).to receive(:fullname).and_return(full_name)
|
||||
allow(mod).to receive(:rank).and_return(rank)
|
||||
|
@ -181,7 +176,6 @@ RSpec.describe Msf::Exploit::Remote::BrowserAutopwn2 do
|
|||
allow(p).to receive(:fullname).and_return(fullname)
|
||||
allow(p).to receive(:shortname).and_return(shortname)
|
||||
allow(p).to receive(:workspace).and_return(workspace)
|
||||
allow(p).to receive(:exploit_simple)
|
||||
|
||||
p
|
||||
end
|
||||
|
@ -371,21 +365,56 @@ RSpec.describe Msf::Exploit::Remote::BrowserAutopwn2 do
|
|||
allow(framework).to receive(:exploits).and_return(exploits)
|
||||
|
||||
# Prepare jobs
|
||||
jobs = {'0' => create_fake_job(0)}
|
||||
allow(jobs).to receive(:stop_job) { |arg| mock_stop_job(arg) }
|
||||
jobs = instance_double(Rex::JobContainer)
|
||||
job_by_id = {
|
||||
'0' => create_fake_job(0)
|
||||
}
|
||||
|
||||
allow(jobs).to receive(:[]).with('0').and_return(job_by_id['0'])
|
||||
allow(jobs).to receive(:each) { |&block|
|
||||
job_by_id.each(&block)
|
||||
}
|
||||
allow(jobs).to receive(:empty?) {
|
||||
job_by_id.empty?
|
||||
}
|
||||
allow(jobs).to receive(:length) {
|
||||
job_by_id.length
|
||||
}
|
||||
allow(jobs).to receive(:stop_job) { |job_number|
|
||||
job_id = job_number.to_s
|
||||
job = job_by_id[job_id]
|
||||
|
||||
if job
|
||||
job.stop
|
||||
|
||||
job_by_id.delete(job_id)
|
||||
end
|
||||
}
|
||||
|
||||
allow(framework).to receive(:jobs).and_return(jobs)
|
||||
|
||||
# Prepare payloads
|
||||
payloads = {}
|
||||
payloads = instance_double(Msf::PayloadSet)
|
||||
payload_class_by_reference_name = {}
|
||||
|
||||
allow(payloads).to receive(:[]=) do |reference_name, klass|
|
||||
payload_class_by_reference_name[reference_name] = klass
|
||||
end
|
||||
|
||||
allow(payloads).to receive(:keys) {
|
||||
payload_class_by_reference_name.keys
|
||||
}
|
||||
|
||||
available_payloads.each do |p|
|
||||
payloads[p.fullname] = "__SYMBOLIC__"
|
||||
end
|
||||
|
||||
allow(payloads).to receive(:create) { |arg| mock_payload_create(arg) }
|
||||
allow(framework).to receive(:payloads).and_return(payloads)
|
||||
|
||||
allow_any_instance_of(described_class).to receive(:cli).and_return(cli)
|
||||
|
||||
allow_any_instance_of(described_class).to receive(:framework).and_return(framework)
|
||||
allow_any_instance_of(Msf::Exploit).to receive(:framework).and_return(framework)
|
||||
allow_any_instance_of(described_class).to receive(:report_note) { |arg| mock_report_note(arg) }
|
||||
end
|
||||
|
||||
|
@ -435,8 +464,11 @@ RSpec.describe Msf::Exploit::Remote::BrowserAutopwn2 do
|
|||
end
|
||||
|
||||
describe '#rm_payload_jobs' do
|
||||
it 'empties jobs' do
|
||||
before(:each) do
|
||||
subject.instance_variable_set(:@payload_job_ids, job_ids)
|
||||
end
|
||||
|
||||
it 'empties jobs' do
|
||||
expect(subject.framework.jobs.length).to eq(1)
|
||||
subject.rm_payload_jobs
|
||||
expect(subject.framework.jobs).to be_empty
|
||||
|
|
Loading…
Reference in New Issue