Python Exec, Python Meterpreter, Python Reverse TCP Stager - Metasploit


This page contains detailed information about how to use the payload/cmd/unix/python/meterpreter/reverse_tcp metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.

Module Overview


Name: Python Exec, Python Meterpreter, Python Reverse TCP Stager
Module: payload/cmd/unix/python/meterpreter/reverse_tcp
Source code: modules/payloads/adapters/cmd/unix/python.rb
Disclosure date: -
Last modification time: 2022-02-24 09:04:51 +0000
Supported architecture(s): cmd
Supported platform(s): Unix
Target service / protocol: -
Target network port(s): -
List of CVEs: -

Execute a Python payload from a command. Run a meterpreter server in Python (compatible with 2.5-2.7 & 3.1+). Connect back to the attacker

Module Ranking and Traits


Module Ranking:

  • normal: The exploit is otherwise reliable, but depends on a specific version and can't (or doesn't) reliably autodetect. More information about ranking can be found here.

Basic Usage


msf > use payload/cmd/unix/python/meterpreter/reverse_tcp
msf payload(reverse_tcp) > show options
    ... show and set options ...
msf payload(reverse_tcp) > generate

To learn how to generate payload/cmd/unix/python/meterpreter/reverse_tcp with msfvenom, please read this.

Required Options


  • LHOST: The listen address (an interface may be specified)

Go back to menu.

Msfconsole Usage


Here is how the cmd/unix/python/meterpreter/reverse_tcp payload module looks in the msfconsole:

msf6 > use payload/cmd/unix/python/meterpreter/reverse_tcp

msf6 payload(cmd/unix/python/meterpreter/reverse_tcp) > show info

       Name: Python Exec, Python Meterpreter, Python Reverse TCP Stager
     Module: payload/cmd/unix/python/meterpreter/reverse_tcp
   Platform: Unix
       Arch: cmd
Needs Admin: No
 Total size: 569
       Rank: Normal

Provided by:
  Spencer McIntyre

Basic options:
Name   Current Setting  Required  Description
----   ---------------  --------  -----------
LHOST                   yes       The listen address (an interface may be specified)
LPORT  4444             yes       The listen port

Description:
  Execute a Python payload from a command. Run a meterpreter server in 
  Python (compatible with 2.5-2.7 & 3.1+). Connect back to the 
  attacker

Module Options


This is a complete list of options available in the cmd/unix/python/meterpreter/reverse_tcp payload:

msf6 payload(cmd/unix/python/meterpreter/reverse_tcp) > show options

Module options (payload/cmd/unix/python/meterpreter/reverse_tcp):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LHOST                   yes       The listen address (an interface may be specified)
   LPORT  4444             yes       The listen port

Advanced Options


Here is a complete list of advanced options supported by the cmd/unix/python/meterpreter/reverse_tcp payload:

msf6 payload(cmd/unix/python/meterpreter/reverse_tcp) > show advanced

Module advanced options (payload/cmd/unix/python/meterpreter/reverse_tcp):

   Name                         Current Setting  Required  Description
   ----                         ---------------  --------  -----------
   AutoLoadStdapi               true             yes       Automatically load the Stdapi extension
   AutoRunScript                                 no        A script to run automatically on session creation.
   AutoSystemInfo               true             yes       Automatically capture system information on initialization.
   AutoUnhookProcess            false            yes       Automatically load the unhook extension and unhook the process
   AutoVerifySessionTimeout     30               no        Timeout period to wait for session validation to occur, in seconds
   EnableStageEncoding          false            no        Encode the second stage payload
   EnableUnicodeEncoding        false            yes       Automatically encode UTF-8 strings as hexadecimal
   HandlerSSLCert                                no        Path to a SSL certificate in unified PEM format, ignored for HTTP transports
   HttpCookie                                    no        An optional value to use for the Cookie HTTP header
   HttpHostHeader                                no        An optional value to use for the Host HTTP header
   HttpReferer                                   no        An optional value to use for the Referer HTTP header
   InitialAutoRunScript                          no        An initial script to run on session creation (before AutoRunScript)
   MeterpreterTryToFork         true             no        Fork a new process if the functionality is available
   PayloadProcessCommandLine                     no        The displayed command line that will be used by the payload
   PayloadUUIDName                               no        A human-friendly name to reference this unique payload (requires tracking)
   PayloadUUIDRaw                                no        A hex string representing the raw 8-byte PUID value for the UUID
   PayloadUUIDSeed                               no        A string to use when generating the payload UUID (deterministic)
   PayloadUUIDTracking          false            yes       Whether or not to automatically register generated UUIDs
   PingbackRetries              0                yes       How many additional successful pingbacks
   PingbackSleep                30               yes       Time (in seconds) to sleep between pingbacks
   PythonMeterpreterDebug       false            no        Enable debugging for the Python meterpreter
   ReverseAllowProxy            false            yes       Allow reverse tcp even with Proxies specified. Connect back will NOT go through proxy but directly to LHOST
   ReverseListenerBindAddress                    no        The specific IP address to bind to on the local system
   ReverseListenerBindPort                       no        The port to bind to on the local system if different from LPORT
   ReverseListenerComm                           no        The specific communication channel to use for this listener
   ReverseListenerThreaded      false            yes       Handle every connection in a new thread (experimental)
   SessionCommunicationTimeout  300              no        The number of seconds of no activity before this session should be killed
   SessionExpirationTimeout     604800           no        The number of seconds before this session should be forcibly shut down
   SessionRetryTotal            3600             no        Number of seconds try reconnecting for on network failure
   SessionRetryWait             10               no        Number of seconds to wait between reconnect attempts
   StageEncoder                                  no        Encoder to use if EnableStageEncoding is set
   StageEncoderSaveRegisters                     no        Additional registers to preserve in the staged payload if EnableStageEncoding is set
   StageEncodingFallback        true             no        Fallback to no encoding if the selected StageEncoder is not compatible
   StagerRetryCount             10               no        The number of times the stager should retry if the first connect fails
   StagerRetryWait              5                no        Number of seconds to wait for the stager between reconnect attempts
   VERBOSE                      false            no        Enable detailed status messages
   WORKSPACE                                     no        Specify the workspace for this module

Go back to menu.


Go back to menu.

See Also


Check also the following modules related to this module:

Authors


  • Spencer McIntyre

Version


This page has been produced using Metasploit Framework version 6.1.36-dev. For more modules, visit the Metasploit Module Library.

Go back to menu.