|
57 | 57 | reference_name: 'windows/meterpreter/reverse_tcp'
|
58 | 58 | )
|
59 | 59 | }
|
60 |
| - |
| 60 | + |
61 | 61 | # let(:shellcode) { "\x50\x51\x58\x59" }
|
62 |
| - |
| 62 | + |
63 | 63 | # let(:var_name) { 'buf' }
|
64 | 64 |
|
65 | 65 | subject(:payload_generator) {
|
|
130 | 130 | template: File.join(Msf::Config.data_directory, 'templates', 'template_x86_windows.exe')
|
131 | 131 | }
|
132 | 132 | }
|
133 |
| - |
| 133 | + |
134 | 134 | it { is_expected.to raise_error(ArgumentError, "Invalid Payload Selected") }
|
135 | 135 | end
|
136 | 136 |
|
|
495 | 495 | expect{payload_generator.generate_raw_payload}.to raise_error(Msf::IncompatiblePlatform, "You must select a platform for a custom payload")
|
496 | 496 | end
|
497 | 497 | end
|
498 |
| - |
| 498 | + |
499 | 499 | let(:generator_opts) {
|
500 | 500 | {
|
501 | 501 | add_code: false,
|
|
632 | 632 | template: File.join(Msf::Config.data_directory, 'templates', 'template_x86_windows.exe')
|
633 | 633 | }
|
634 | 634 | }
|
635 |
| - |
| 635 | + |
636 | 636 | it 'returns the original shellcode' do
|
637 | 637 | expect(payload_generator.add_shellcode(shellcode)).to eq shellcode
|
638 | 638 | end
|
|
658 | 658 | template: File.join(Msf::Config.data_directory, 'templates', 'template_x86_windows.exe')
|
659 | 659 | }
|
660 | 660 | }
|
661 |
| - |
| 661 | + |
662 | 662 |
|
663 | 663 | it 'returns the original shellcode' do
|
664 | 664 | expect(payload_generator.add_shellcode(shellcode)).to eq shellcode
|
|
775 | 775 | template: File.join(Msf::Config.data_directory, 'templates', 'template_x86_windows.exe')
|
776 | 776 | }
|
777 | 777 | }
|
778 |
| - |
| 778 | + |
779 | 779 | before(:example) do
|
780 | 780 | load_and_create_module(
|
781 | 781 | module_type: 'nop',
|
|
861 | 861 | # x86/alpha_mixed
|
862 | 862 | # }
|
863 | 863 | # }
|
864 |
| - |
| 864 | + |
865 | 865 | let(:generator_opts) {
|
866 | 866 | {
|
867 | 867 | add_code: false,
|
|
925 | 925 | template: File.join(Msf::Config.data_directory, 'templates', 'template_x86_windows.exe')
|
926 | 926 | }
|
927 | 927 | }
|
928 |
| - |
| 928 | + |
929 | 929 | it 'returns an array of all encoders with a compatible arch' do
|
930 | 930 | payload_generator.get_encoders.each do |my_encoder|
|
931 | 931 | expect(my_encoder.arch).to include 'x86'
|
|
959 | 959 | reference_name: 'x86/shikata_ga_nai'
|
960 | 960 | )
|
961 | 961 | }
|
962 |
| - |
| 962 | + |
963 | 963 | it 'returns an empty array' do
|
964 | 964 | expect(payload_generator.get_encoders).to be_empty
|
965 | 965 | end
|
|
1128 | 1128 | payload_generator.generate_java_payload
|
1129 | 1129 | end
|
1130 | 1130 | end
|
1131 |
| - |
| 1131 | + |
1132 | 1132 | let(:generator_opts) {
|
1133 | 1133 | {
|
1134 | 1134 | add_code: false,
|
|
1148 | 1148 | template: File.join(Msf::Config.data_directory, 'templates', 'template_x86_windows.exe')
|
1149 | 1149 | }
|
1150 | 1150 | }
|
1151 |
| - |
| 1151 | + |
1152 | 1152 | it 'raises an InvalidFormat exception' do
|
1153 | 1153 | expect{ payload_generator.generate_java_payload }.to raise_error(Msf::InvalidFormat)
|
1154 | 1154 | end
|
|
1358 | 1358 | expect{payload_generator.generate_payload}.to raise_error(Msf::PayloadSpaceViolation, "The payload exceeds the specified space")
|
1359 | 1359 | end
|
1360 | 1360 | end
|
| 1361 | + context 'when the payload format is invalid for the platform' do |
| 1362 | + let!(:payload_module) { |
| 1363 | + load_and_create_module( |
| 1364 | + ancestor_reference_names: %w{ |
| 1365 | + stagers/osx/x86/reverse_tcp |
| 1366 | + stages/osx/x86/isight |
| 1367 | + }, |
| 1368 | + module_type: 'payload', |
| 1369 | + reference_name: 'osx/x86/isight/reverse_tcp' |
| 1370 | + ) |
| 1371 | + } |
| 1372 | + let(:generator_opts) { |
| 1373 | + { |
| 1374 | + datastore: { 'LHOST' => '192.168.172.1', 'LPORT' => '8443' } , |
| 1375 | + format: 'elf', |
| 1376 | + framework: framework, |
| 1377 | + keep: false, |
| 1378 | + payload: 'osx/x86/isight/reverse_tcp', |
| 1379 | + stdin: nil, |
| 1380 | + } |
| 1381 | + } |
| 1382 | + it 'should raise an error' do |
| 1383 | + expect{payload_generator.generate_payload}.to raise_error(Msf::PayloadGeneratorError, "The payload could not be generated, check options") |
| 1384 | + end |
| 1385 | + end |
1361 | 1386 |
|
1362 | 1387 | end
|
0 commit comments