CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/spec/lib/msf/simple/payload_spec.rb
Views: 11704
1
require 'spec_helper'
2
3
RSpec.describe Msf::Simple::Payload do
4
include_context 'Msf::Simple::Framework#modules loading'
5
6
let(:generator_format) { 'raw' }
7
let(:generator_opts) {
8
{
9
'BadChars' => '',
10
'Encoder' => '',
11
'Options' => { 'LHOST' => '1.1.1.1', 'LPORT' => '8443' } ,
12
'Format' => generator_format,
13
'NoComment' => false,
14
'NopSledSize' => 0,
15
'MaxSize' => 0,
16
'Iterations' => 1,
17
'ForceEncode' => false
18
}
19
}
20
21
let!(:payload_module) {
22
load_and_create_module(
23
ancestor_reference_names: %w{
24
stagers/windows/reverse_tcp
25
stages/windows/meterpreter
26
},
27
module_type: 'payload',
28
reference_name: 'windows/meterpreter/reverse_tcp'
29
)
30
}
31
32
subject(:payload) {
33
described_class.generate_simple(payload_module, generator_opts)
34
}
35
36
it { expect { payload }.not_to raise_error }
37
38
# These are languages that are missing a to_comment implementation in Rex::Text.
39
UNSUPPORTED_LANGS = %w(vbapplication vbscript)
40
41
(::Msf::Simple::Buffer.transform_formats - UNSUPPORTED_LANGS).each do |format|
42
context "when given the transform format '#{format}'" do
43
let(:generator_format) { format }
44
it { expect { payload }.not_to raise_error }
45
end
46
end
47
end
48
49