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/adapters/cmd/windows/python.rb
Views: 11777
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45module MetasploitModule6include Msf::Payload::Adapter78def initialize(info = {})9super(10update_info(11info,12'Name' => 'Python Exec',13'Description' => 'Execute a Python payload from a command',14'Author' => 'Spencer McIntyre',15'Platform' => 'win',16'Arch' => ARCH_CMD,17'License' => MSF_LICENSE,18'AdaptedArch' => ARCH_PYTHON,19'AdaptedPlatform' => 'python',20'RequiredCmd' => 'python'21)22)23register_advanced_options(24[25OptString.new('PythonPath', [true, 'The path to the Python executable', 'python'])26]27)28end2930def compatible?(mod)31# size is not unlimited due to the standard command length limit, the final size depends on the options that are32# configured but 3,000 is in a good range (can go up to 4,000 with default settings at this time)33if mod.type == Msf::MODULE_PAYLOAD && (mod.class.const_defined?(:CachedSize) && mod.class::CachedSize != :dynamic) && (mod.class::CachedSize >= 3_000)34return false35end3637super38end3940def generate41payload = super4243if payload.include?("\n")44payload = Msf::Payload::Python.create_exec_stub(payload)45end4647"#{datastore['PythonPath']} -c \"#{payload}\""48end49end505152