Skip to content

Commit c8c3e1a

Browse files
committed
Fix rspec
1 parent 89aa00c commit c8c3e1a

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

spec/lib/msf/core/exploit/browser_autopwnv2_spec.rb

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def mock_note_destroy
1818
# This empties it
1919
notes = []
2020

21-
db = double('db')
21+
db = double('db1')
2222
allow(db).to receive(:notes).and_return(notes)
2323
allow(framework).to receive(:db).and_return(db)
2424

@@ -28,14 +28,14 @@ def mock_note_destroy
2828
def mock_report_note(arg)
2929
framework = double('Msf::Framework', datastore: {})
3030
notes = [create_fake_note('bap.clicks')]
31-
db = double('db')
31+
db = double('db2')
3232
allow(db).to receive(:notes).and_return(notes)
3333
allow(framework).to receive(:db).and_return(db)
3434
allow(subject).to receive(:framework).and_return(framework)
3535
end
3636

3737
def create_fake_note(tag, data='')
38-
note = double('note')
38+
note = double('note3')
3939

4040
allow(note).to receive(:ntype).and_return(tag)
4141
allow(note).to receive(:data).and_return(data)
@@ -65,6 +65,7 @@ def create_fake_exploit(opts={})
6565
datastore_options = opts[:datastore_options] || {}
6666
job_id = opts[:job_id] || 0
6767
requirements = opts[:requirements] || {}
68+
workspace = opts[:workspace] || 'default'
6869

6970
mod = Msf::Exploit.new
7071
mod.extend(Msf::Exploit::Remote::BrowserExploitServer)
@@ -75,6 +76,7 @@ def create_fake_exploit(opts={})
7576
allow(mod).to receive(:compatible_payloads).and_return(compat_payloads)
7677
allow(mod).to receive(:datastore).and_return(datastore_options)
7778
allow(mod).to receive(:job_id).and_return(job_id)
79+
allow(mod).to receive(:workspace).and_return(workspace)
7880
allow(mod).to receive(:exploit_simple)
7981
allow(mod).to receive(:vprint_status)
8082
allow(mod).to receive(:shortname).and_return(short_name)
@@ -139,6 +141,7 @@ def create_fake_payload(opts={})
139141
datastores = opts[:datastore_options]
140142
fullname = opts[:fullname]
141143
shortname = opts[:shortname]
144+
workspace = opts[:workspace] || 'default'
142145

143146
p = Msf::Payload.new
144147

@@ -154,8 +157,11 @@ def create_fake_payload(opts={})
154157
p.datastore[key] = value
155158
end
156159

160+
datastores['WORKSPACE'] = workspace
161+
157162
allow(p).to receive(:fullname).and_return(fullname)
158163
allow(p).to receive(:shoftname).and_return(shortname)
164+
allow(p).to receive(:workspace).and_return(workspace)
159165

160166
p
161167
end
@@ -329,10 +335,14 @@ def mock_exploit_create(full_name)
329335
notes = [create_fake_note("#{note_type_prefix}.#{profile_tag}", profile_packed_data)]
330336

331337
# Prepare framework.db
338+
w = double('workspace')
339+
allow(w).to receive(:name).and_return('WORKSPACE')
340+
332341
db = double('db')
333342
allow(db).to receive(:report_note).with(kind_of(Hash)) { |arg| mock_report_note(arg) }
334343
allow(db).to receive(:notes).and_return(notes)
335344
allow(db).to receive(:active).and_return(true)
345+
allow(db).to receive(:workspace).and_return(w)
336346
allow(framework).to receive(:db).and_return(db)
337347

338348
# Prepare framework.exploits
@@ -710,20 +720,6 @@ def get_stdout(&block)
710720
# You got me, I don't know how to implement this one because the super"
711721
end
712722

713-
describe '#show_payloads' do
714-
it 'shows payloads' do
715-
output = get_stdout { subject.show_payloads }
716-
expect(output).to include(windows_meterpreter_reverse_tcp)
717-
expect(output).to include(linux_meterpreter_reverse_tcp)
718-
end
719-
end
720-
721-
describe '#set_payload' do
722-
it 'shows set_payload' do
723-
output = get_stdout { subject.set_payload }
724-
expect(output).to include('\'set payload\' has been disabled for BrowserAutoPwn')
725-
end
726-
end
727723
end
728724

729725
describe '#log_click' do

0 commit comments

Comments
 (0)