|
11 | 11 |
|
12 | 12 |
|
13 | 13 | def mock_note_destroy
|
14 |
| - # The destory method doesn't pass the note as an argument like framework.jobs_stop_job. |
| 14 | + # The destory method doesn't pass the note as an argument startlike framework.jobs_stop_job. |
15 | 15 | # So here's I'm just gonna clear them all, and that sort of mimics #destroy.
|
16 | 16 | framework = double('Msf::Framework', datastore: {})
|
17 | 17 |
|
@@ -91,6 +91,19 @@ def create_fake_exploit(opts={})
|
91 | 91 | mod
|
92 | 92 | end
|
93 | 93 |
|
| 94 | + def create_fake_multi_handler |
| 95 | + compat_payloads = [ |
| 96 | + [windows_meterpreter_reverse_tcp, create_fake_windows_meterpreter] |
| 97 | + ] |
| 98 | + |
| 99 | + create_fake_exploit( |
| 100 | + full_name: 'multi/handler', |
| 101 | + short_name: 'multi/handler', |
| 102 | + compat_payloads: compat_payloads, |
| 103 | + job_id: 0, |
| 104 | + ) |
| 105 | + end |
| 106 | + |
94 | 107 | def create_fake_ms14_064
|
95 | 108 | compat_payloads = [
|
96 | 109 | [windows_meterpreter_reverse_tcp, create_fake_windows_meterpreter]
|
@@ -168,6 +181,7 @@ def create_fake_payload(opts={})
|
168 | 181 | allow(p).to receive(:fullname).and_return(fullname)
|
169 | 182 | allow(p).to receive(:shoftname).and_return(shortname)
|
170 | 183 | allow(p).to receive(:workspace).and_return(workspace)
|
| 184 | + allow(p).to receive(:exploit_simple) |
171 | 185 |
|
172 | 186 | p
|
173 | 187 | end
|
@@ -238,6 +252,7 @@ def mock_exploit_create(full_name)
|
238 | 252 | exploits << create_fake_ms14_064
|
239 | 253 | exploits << create_fake_flash_uncompress_zlib_uaf
|
240 | 254 | exploits << create_fake_flash_net_connection_confusion
|
| 255 | + exploits << create_fake_multi_handler |
241 | 256 |
|
242 | 257 | exploits
|
243 | 258 | }.call
|
@@ -382,6 +397,7 @@ def mock_exploit_create(full_name)
|
382 | 397 | mod.send(:initialize)
|
383 | 398 | mod.send(:datastore=, autopwn_datastore_options)
|
384 | 399 | allow(mod).to receive(:fullname).and_return('multi/browser/autopwn')
|
| 400 | + allow(mod).to receive(:datastore).and_return(autopwn_datastore_options) |
385 | 401 | mod
|
386 | 402 | end
|
387 | 403 |
|
@@ -561,7 +577,30 @@ def mock_exploit_create(full_name)
|
561 | 577 | end
|
562 | 578 | end
|
563 | 579 |
|
564 |
| - skip '#start_payload_listeners' do |
| 580 | + describe '#start_payload_listeners' do |
| 581 | + let(:active_payload) do |
| 582 | + create_fake_windows_meterpreter |
| 583 | + end |
| 584 | + |
| 585 | + let(:wanted_payloads) do |
| 586 | + [{ |
| 587 | + payload_name: active_payload.fullname, |
| 588 | + payload_lport: active_payload.datastore['LPORT'] |
| 589 | + }] |
| 590 | + end |
| 591 | + |
| 592 | + before(:each) do |
| 593 | + subject.instance_variable_set(:@wanted_payloads, wanted_payloads) |
| 594 | + subject.instance_variable_set(:@payload_job_ids, []) |
| 595 | + end |
| 596 | + |
| 597 | + context 'when a payload is listening' do |
| 598 | + it 'adds the job ID to the payload job ID list' do |
| 599 | + expect(subject.instance_variable_get(:@payload_job_ids).length).to eq(0) |
| 600 | + subject.start_payload_listeners |
| 601 | + expect(subject.instance_variable_get(:@payload_job_ids).length).to eq(1) |
| 602 | + end |
| 603 | + end |
565 | 604 | end
|
566 | 605 |
|
567 | 606 | describe '#parse_rank' do
|
@@ -656,8 +695,20 @@ def mock_exploit_create(full_name)
|
656 | 695 | end
|
657 | 696 | end
|
658 | 697 |
|
659 |
| - skip '#select_payload' do |
660 |
| - |
| 698 | + describe '#select_payload' do |
| 699 | + before(:each) do |
| 700 | + subject.instance_variable_set(:@wanted_payloads, []) |
| 701 | + end |
| 702 | + |
| 703 | + context 'when a ms14_064 is given' do |
| 704 | + it 'returns a windows payload' do |
| 705 | + m = create_fake_ms14_064 |
| 706 | + expected_payload = m.compatible_payloads.first.first |
| 707 | + selected_payload = subject.select_payload(m) |
| 708 | + expect(selected_payload.length).to eq(1) |
| 709 | + expect(selected_payload.first[:payload_name]).to eq(expected_payload) |
| 710 | + end |
| 711 | + end |
661 | 712 | end
|
662 | 713 |
|
663 | 714 | describe '#start_exploits' do
|
@@ -724,7 +775,14 @@ def get_stdout(&block)
|
724 | 775 | end
|
725 | 776 |
|
726 | 777 | skip '#start_service' do
|
727 |
| - # You got me, I don't know how to implement this one because the super" |
| 778 | + it 'prints the BrowserAutopwn URL' do |
| 779 | + # This code blows up, por que?? |
| 780 | + # 3 threads exist(s) when only 1 thread expected after suite runs |
| 781 | + allow_any_instance_of(Msf::Exploit::Remote::BrowserExploitServer).to receive(:super) |
| 782 | + allow(subject).to receive(:show_ready_exploits) |
| 783 | + allow_any_instance_of(Rex::Socket).to receive(:source_address).and_return(nil) |
| 784 | + subject.start_service |
| 785 | + end |
728 | 786 | end
|
729 | 787 |
|
730 | 788 | end
|
|
0 commit comments